Skip to content

Commit

Permalink
REST: Remove redundant OpenAPI tests
Browse files Browse the repository at this point in the history
Change-Id: I331a1424c31ed3ad537329c316935d23514ee051
  • Loading branch information
Silvan-WMDE committed Oct 2, 2024
1 parent ed2b9f1 commit 2e81bef
Show file tree
Hide file tree
Showing 21 changed files with 4 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ function makeUnique( text ) {
describe( newAddPropertyAliasesInLanguageRequestBuilder().getRouteDescription(), () => {

let existingPropertyId;
const languageWithExistingAlias = 'en';

before( async () => {
const createPropertyResponse = await createEntity( 'property', {
aliases: [ {
language: languageWithExistingAlias,
language: 'en',
value: makeUnique( 'en-alias' )
} ],
datatype: 'string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ describe( newAddPropertyStatementRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '400 Bad Request is valid for invalid statement param type', async () => {
const response = await newAddPropertyStatementRequestBuilder(
propertyId,
'invalid statement param type'
).makeRequest();

expect( response ).to.have.status( 400 );
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found is valid for non-existent Property', async () => {
const response = await newAddPropertyStatementRequestBuilder( 'P9999999', validStatementSerialization )
.makeRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ describe( newCreateItemRequestBuilder().getRouteDescription(), () => {
localSiteId = await getLocalSiteId();
} );

it( '201 - minimal item', async () => {
const response = await newCreateItemRequestBuilder( {
labels: { en: 'potato' }
} ).makeRequest();

expect( response ).to.have.status( 201 );
expect( response ).to.satisfyApiSpec;
} );

it( '201 - full item', async () => {
const linkedArticle = utils.title( 'Potato' );
await createWikiPage( linkedArticle );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,4 @@ describe( newGetItemAliasesInLanguageRequestBuilder().getRouteDescription(), ()
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no aliases in the requested language', async () => {
const response = await newGetItemAliasesInLanguageRequestBuilder( itemId, 'de' ).makeRequest();
expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ describe( newGetItemAliasesRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Item without aliases', async () => {
const createItemResponse = await createEntity( 'item', {} );

const response = await newGetItemAliasesRequestBuilder( createItemResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetItemAliasesRequestBuilder( testItemId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,4 @@ describe( newGetItemDescriptionRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no description in the requested language', async () => {
const response = await newGetItemDescriptionRequestBuilder( itemId, 'de' ).makeRequest();
expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ describe( newGetItemDescriptionsRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Item without descriptions', async () => {
const createItemResponse = await createEntity( 'item', {} );

const response = await newGetItemDescriptionsRequestBuilder( createItemResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetItemDescriptionsRequestBuilder( testItemId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,4 @@ describe( newGetItemLabelRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no label in the requested language', async () => {
const response = await newGetItemLabelRequestBuilder( itemId, 'ko' ).makeRequest();

expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
11 changes: 0 additions & 11 deletions repo/rest-api/tests/mocha/openapi-validation/GetItemLabelsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ describe( newGetItemLabelsRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Item without labels', async () => {
const createItemResponse = await createEntity( 'item', {
descriptions: { en: { language: 'en', value: 'some description' } }
} );

const response = await newGetItemLabelsRequestBuilder( createItemResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetItemLabelsRequestBuilder( testItemId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ describe( newGetItemStatementsRequestBuilder().getRouteDescription(), () => {
latestRevisionId = createItemResponse.entity.lastrevid;
} );

it( '200 OK response is valid for an Item with no statements', async () => {
const response = await newGetItemStatementsRequestBuilder( itemId ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Item with statements', async () => {
const statementPropertyId = ( await createUniqueStringProperty() ).entity.id;
const { id } = await createItemWithStatements( [
Expand Down
16 changes: 0 additions & 16 deletions repo/rest-api/tests/mocha/openapi-validation/GetItemTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ describe( newGetItemRequestBuilder().getRouteDescription(), () => {
latestRevisionId = createItemResponse.entity.lastrevid;
} );

it( '200 OK response is valid for an "empty" item', async () => {
const response = await newGetItemRequestBuilder( itemId ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for a non-empty item', async () => {
const id = await createItemWithAllFields();
const response = await newGetItemRequestBuilder( id ).makeRequest();
Expand Down Expand Up @@ -100,15 +93,6 @@ describe( newGetItemRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '400 Bad Request response is valid for an invalid field', async () => {
const response = await newGetItemRequestBuilder( 'Q123' )
.withQueryParam( '_fields', 'unknown_field' )
.makeRequest();

expect( response ).to.have.status( 400 );
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid for a non-existing item', async () => {
const response = await newGetItemRequestBuilder( 'Q99999' ).makeRequest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,4 @@ describe( newGetPropertyAliasesInLanguageRequestBuilder().getRouteDescription(),
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no aliases in the requested language', async () => {
const response = await newGetPropertyAliasesInLanguageRequestBuilder( propertyId, 'de' )
.makeRequest();

expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { utils } = require( 'api-testing' );
const { expect } = require( '../helpers/chaiHelper' );
const { createEntity, createUniqueStringProperty } = require( '../helpers/entityHelper' );
const { createEntity } = require( '../helpers/entityHelper' );
const { newGetPropertyAliasesRequestBuilder } = require( '../helpers/RequestBuilderFactory' );

describe( newGetPropertyAliasesRequestBuilder().getRouteDescription(), () => {
Expand Down Expand Up @@ -36,15 +36,6 @@ describe( newGetPropertyAliasesRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for a Property without aliases', async () => {
const createPropertyResponse = await createUniqueStringProperty();

const response = await newGetPropertyAliasesRequestBuilder( createPropertyResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetPropertyAliasesRequestBuilder( testPropertyId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,4 @@ describe( newGetPropertyDescriptionRequestBuilder().getRouteDescription(), () =>
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no description in the requested language', async () => {
const response = await newGetPropertyDescriptionRequestBuilder( propertyId, 'ko' ).makeRequest();

expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { utils } = require( 'api-testing' );
const { expect } = require( '../helpers/chaiHelper' );
const { createEntity, createUniqueStringProperty } = require( '../helpers/entityHelper' );
const { createEntity } = require( '../helpers/entityHelper' );
const { newGetPropertyDescriptionsRequestBuilder } = require( '../helpers/RequestBuilderFactory' );

describe( newGetPropertyDescriptionsRequestBuilder().getRouteDescription(), () => {
Expand Down Expand Up @@ -30,16 +30,6 @@ describe( newGetPropertyDescriptionsRequestBuilder().getRouteDescription(), () =
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for a Property without descriptions', async () => {
const createPropertyResponse = await createUniqueStringProperty();

const response = await newGetPropertyDescriptionsRequestBuilder( createPropertyResponse.entity.id )
.makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetPropertyDescriptionsRequestBuilder( testPropertyId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,4 @@ describe( newGetPropertyLabelRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no label in the requested language', async () => {
const response = await newGetPropertyLabelRequestBuilder( propertyId, 'ko' ).makeRequest();

expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { expect } = require( '../helpers/chaiHelper' );
const { createEntity, createUniqueStringProperty } = require( '../helpers/entityHelper' );
const { createUniqueStringProperty } = require( '../helpers/entityHelper' );
const { newGetPropertyLabelsRequestBuilder } = require( '../helpers/RequestBuilderFactory' );

describe( newGetPropertyLabelsRequestBuilder().getRouteDescription(), () => {
Expand All @@ -22,18 +22,6 @@ describe( newGetPropertyLabelsRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for a Property without labels', async () => {
const createPropertyResponse = await createEntity( 'property', {
descriptions: { en: { language: 'en', value: 'some description' } },
datatype: 'string'
} );

const response = await newGetPropertyLabelsRequestBuilder( createPropertyResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetPropertyLabelsRequestBuilder( testPropertyId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ describe( newGetPropertyStatementsRequestBuilder().getRouteDescription(), () =>
latestRevisionId = createPropertyResponse.entity.lastrevid;
} );

it( '200 OK response is valid for an Property with no statements', async () => {
const response = await newGetPropertyStatementsRequestBuilder( propertyId ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Property with statements', async () => {
const statementPropertyId = ( await createUniqueStringProperty() ).entity.id;
const { id } = await createPropertyWithStatements( [
Expand Down
27 changes: 0 additions & 27 deletions repo/rest-api/tests/mocha/openapi-validation/GetPropertyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ async function createPropertyWithAllFields() {

describe( newGetPropertyRequestBuilder().getRouteDescription(), () => {

let propertyId;

before( async () => {
const createPropertyResponse = await entityHelper.createEntity(
'property',
{ datatype: 'string' }
);
propertyId = createPropertyResponse.entity.id;
} );

it( '200 OK response is valid for an "empty" property', async () => {
const response = await newGetPropertyRequestBuilder( propertyId ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for a non-empty property', async () => {
const { entity: { id } } = await createPropertyWithAllFields();
const response = await newGetPropertyRequestBuilder( id ).makeRequest();
Expand All @@ -81,16 +64,6 @@ describe( newGetPropertyRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '400 Bad Request response is valid for an invalid field', async () => {
const response = await newGetPropertyRequestBuilder( 'Q123' )
.withQueryParam( '_fields', 'unknown_field' )
.assertInvalidRequest()
.makeRequest();

expect( response ).to.have.status( 400 );
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid for a non-existing property', async () => {
const response = await newGetPropertyRequestBuilder( 'P99999' ).makeRequest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,4 @@ describe( newGetSitelinkRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '404 Not Found response is valid if there is no sitelink for the requested site id', async () => {
const itemId = ( await createEntity( 'item', {} ) ).entity.id;
const response = await newGetSitelinkRequestBuilder( itemId, siteId ).makeRequest();

expect( response ).to.have.status( 404 );
expect( response ).to.satisfyApiSpec;
} );

} );
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ describe( newGetSitelinksRequestBuilder().getRouteDescription(), () => {
expect( response ).to.satisfyApiSpec;
} );

it( '200 OK response is valid for an Item without sitelinks', async () => {
const createItemResponse = await createEntity( 'item', {} );

const response = await newGetSitelinksRequestBuilder( createItemResponse.entity.id ).makeRequest();

expect( response ).to.have.status( 200 );
expect( response ).to.satisfyApiSpec;
} );

it( '304 Not Modified response is valid', async () => {
const response = await newGetSitelinksRequestBuilder( testItemId )
.withHeader( 'If-None-Match', `"${lastRevisionId}"` )
Expand Down

0 comments on commit 2e81bef

Please sign in to comment.