Skip to content

Commit

Permalink
Merge "REST: Optimize DELETE related tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Sep 19, 2023
2 parents 6cb72bd + 6176416 commit be0485a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
17 changes: 7 additions & 10 deletions repo/rest-api/tests/mocha/api-testing/AuthTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const {
getRequestsOnItem,
getRequestsOnProperty
} = require( '../helpers/happyPathRequestBuilders' );
const { newAddPropertyStatementRequestBuilder } = require( '../helpers/RequestBuilderFactory' );

describe( 'Auth', () => {

Expand Down Expand Up @@ -68,19 +67,17 @@ describe( 'Auth', () => {
...editRequestsWithInputs,
...getRequestsOnItem.map( useRequestInputs( itemRequestInputs ) ),
...getRequestsOnProperty.map( useRequestInputs( propertyRequestInputs ) )
].forEach( ( { newRequestBuilder } ) => {
].forEach( ( { newRequestBuilder, requestInputs } ) => {
describe( `Authentication - ${newRequestBuilder().getRouteDescription()}`, () => {

afterEach( async () => {
if ( newRequestBuilder().getMethod() === 'DELETE' ) {
itemRequestInputs.statementId = ( await rbf.newAddItemStatementRequestBuilder(
itemRequestInputs.itemId,
newStatementWithRandomStringValue( itemRequestInputs.statementPropertyId )
).makeRequest() ).body.id;

propertyRequestInputs.statementId = ( await newAddPropertyStatementRequestBuilder(
propertyRequestInputs.propertyId,
newStatementWithRandomStringValue( propertyRequestInputs.statementPropertyId )
const addStatementRequestBuilder = requestInputs.mainTestSubject === requestInputs.itemId ?
rbf.newAddItemStatementRequestBuilder :
rbf.newAddPropertyStatementRequestBuilder;
requestInputs.statementId = ( await addStatementRequestBuilder(
requestInputs.mainTestSubject,
newStatementWithRandomStringValue( requestInputs.statementPropertyId )
).makeRequest() ).body.id;
}
} );
Expand Down
20 changes: 7 additions & 13 deletions repo/rest-api/tests/mocha/api-testing/ConditionalRequestsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const {
createUniqueStringProperty,
createEntity
} = require( '../helpers/entityHelper' );
const {
newAddItemStatementRequestBuilder,
newAddPropertyStatementRequestBuilder
} = require( '../helpers/RequestBuilderFactory' );
const rbf = require( '../helpers/RequestBuilderFactory' );
const { makeEtag } = require( '../helpers/httpHelper' );
const {
editRequestsOnItem,
Expand Down Expand Up @@ -343,15 +340,12 @@ describe( 'Conditional requests', () => {

afterEach( async () => {
if ( newRequestBuilder().getMethod() === 'DELETE' ) {
// restore the item state in between tests that removed the statement
itemRequestInputs.statementId = ( await newAddItemStatementRequestBuilder(
itemRequestInputs.itemId,
newStatementWithRandomStringValue( itemRequestInputs.statementPropertyId )
).makeRequest() ).body.id;

propertyRequestInputs.statementId = ( await newAddPropertyStatementRequestBuilder(
propertyRequestInputs.propertyId,
newStatementWithRandomStringValue( propertyRequestInputs.statementPropertyId )
const addStatementRequestBuilder = requestInputs.mainTestSubject === requestInputs.itemId ?
rbf.newAddItemStatementRequestBuilder :
rbf.newAddPropertyStatementRequestBuilder;
requestInputs.statementId = ( await addStatementRequestBuilder(
requestInputs.mainTestSubject,
newStatementWithRandomStringValue( requestInputs.statementPropertyId )
).makeRequest() ).body.id;
}
} );
Expand Down

0 comments on commit be0485a

Please sign in to comment.