Skip to content

Commit

Permalink
Merge "REST: Add "mul" language code handling e2e tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jun 18, 2024
2 parents 1b8e276 + cfe78ba commit 1408b6e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 2 additions & 0 deletions repo/config/Wikibase.ci.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@
'count' => 100,
'seconds' => 86400,
] ];

$wgWBRepoSettings['tmpEnableMulLanguageCode'] = boolval( getallheaders()[ 'X-Wikibase-Ci-Enable-Mul' ] ?? false );
11 changes: 11 additions & 0 deletions repo/rest-api/tests/mocha/api-testing/PatchItemAliasesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ describe( newPatchItemAliasesRequestBuilder().getRouteDescription(), () => {
formatTermsEditSummary( 'update-languages-short', 'de', editSummary )
);
} );

it( 'can add a "mul" alias', async () => {
const alias = `mul-alias-${utils.uniq()}`;
const response = await newPatchItemAliasesRequestBuilder(
testItemId,
[ { op: 'add', path: '/mul', value: [ alias ] } ]
).withHeader( 'X-Wikibase-Ci-Enable-Mul', 'true' ).makeRequest();

expect( response ).to.have.status( 200 );
assert.deepEqual( response.body.mul, [ alias ] );
} );
} );

describe( '400 Bad Request', () => {
Expand Down
19 changes: 10 additions & 9 deletions repo/rest-api/tests/mocha/api-testing/PatchItemDescriptionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,16 @@ describe( newPatchItemDescriptionsRequestBuilder().getRouteDescription(), () =>
);
} );

it( 'invalid language code', async () => {
const language = 'invalid-language-code';
const response = await newPatchItemDescriptionsRequestBuilder(
testItemId,
[ { op: 'add', path: `/${language}`, value: 'potato' } ]
).assertValidRequest().makeRequest();

assertValidError( response, 422, 'patched-descriptions-invalid-language-code', { language } );
assert.include( response.body.message, language );
[ 'invalid-language-code', 'mul' ].forEach( ( language ) => {
it( `invalid language code: "${language}"`, async () => {
const response = await newPatchItemDescriptionsRequestBuilder(
testItemId,
[ { op: 'add', path: `/${language}`, value: 'potato' } ]
).withHeader( 'X-Wikibase-Ci-Enable-Mul', 'true' ).assertValidRequest().makeRequest();

assertValidError( response, 422, 'patched-descriptions-invalid-language-code', { language } );
assert.include( response.body.message, language );
} );
} );

it( 'patched label and description already exists in a different item', async () => {
Expand Down
11 changes: 11 additions & 0 deletions repo/rest-api/tests/mocha/api-testing/PatchItemLabelsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ describe( newPatchItemLabelsRequestBuilder().getRouteDescription(), () => {
formatTermsEditSummary( 'update-languages-short', 'ar', editSummary )
);
} );

it( 'can add a "mul" label', async () => {
const label = `mul-label-${utils.uniq()}`;
const response = await newPatchItemLabelsRequestBuilder(
testItemId,
[ { op: 'add', path: '/mul', value: label } ]
).withHeader( 'X-Wikibase-Ci-Enable-Mul', 'true' ).makeRequest();

expect( response ).to.have.status( 200 );
assert.strictEqual( response.body.mul, label );
} );
} );

describe( '422 error response', () => {
Expand Down

0 comments on commit 1408b6e

Please sign in to comment.