Skip to content

Commit

Permalink
Use beta for tests (#1339)
Browse files Browse the repository at this point in the history
mocha: Target the beta mediawiki instance instead of parsoid on beta

* Use working endpoints for mathoid
* PCS: Make content-language test case-insensitive

Language codes are not case sensitive, so accept any case.
This also improves output of assert.deepEqual.

Bug: T350353
Change-Id: I9474e4c88dba127c15b82b7c18c6f5957d46a697
  • Loading branch information
brightbyte committed Dec 1, 2023
1 parent d544e9d commit 8a6ab4a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Empty file added DUMMY
Empty file.
4 changes: 2 additions & 2 deletions config.frontend.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
test:
parsoid: &parsoid_test_options
disabled_storage: false
host: http://parsoid-external-ci-access.beta.wmflabs.org/w/rest.php
host: https://en.wikipedia.beta.wmflabs.org/w/rest.php
content_types:
html: '/^text\/html; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/HTML\/[\d.]+"$/'
data-parsoid: '/^application\/json; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/data-parsoid/[\d.]+"$/'
Expand All @@ -24,7 +24,7 @@ default_project: &default_project
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"
baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}"
mathoid: &mathoid_options
host: https://mathoid.beta.math.wmflabs.org
host: https://mathoid-beta-svc.wmcloud.org
# 10 days Varnish caching, one day client-side
cache-control: s-maxage=864000, max-age=86400
mobileapps:
Expand Down
4 changes: 2 additions & 2 deletions config.fullstack.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test:
default: false
# eswiki beta has parsoid storage disabled for testing purposes
es.wikipedia.beta.wmflabs.org: true
host: http://parsoid-external-ci-access.beta.wmflabs.org/w/rest.php
host: https://en.wikipedia.beta.wmflabs.org/w/rest.php
content_types:
html: '/^text\/html; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/HTML\/[\d.]+"$/'
data-parsoid: '/^application\/json; charset=utf-8; profile="https:\/\/www\.mediawiki\.org\/wiki\/Specs\/data-parsoid/[\d.]+"$/'
Expand All @@ -26,7 +26,7 @@ default_project: &default_project
apiUriTemplate: "{{'https://{domain}/w/api.php'}}"
baseUriTemplate: "{{'https://{domain}/api/rest_v1'}}"
mathoid: &mathoid_options
host: https://mathoid.beta.math.wmflabs.org
host: https://mathoid-beta-svc.wmcloud.org
# 10 days Varnish caching, one day client-side
cache-control: s-maxage=864000, max-age=86400
mobileapps:
Expand Down
4 changes: 2 additions & 2 deletions test/features/pcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('Page Content Service: transforms', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers['content-language'], 'sr-Cyrl');
assert.deepEqual(res.headers['content-language'].toLowerCase(), 'sr-cyrl');
assert.checkString(res.headers['cache-control'], /private/, 'Must not be cached');
assert.checkString(res.body, /Ово је тестна страница - 1/, 'Must not convert cyrillic with cyrillic variant');
assert.checkString(res.body, /Ово је тестна страница - 2/, 'Must convert latin with cyrillic variant');
Expand All @@ -207,7 +207,7 @@ describe('Page Content Service: transforms', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers['content-language'], 'sr-Latn');
assert.deepEqual(res.headers['content-language'].toLowerCase(), 'sr-latn');
assert.checkString(res.headers['cache-control'], /private/, 'Must not be cached');
assert.checkString(res.body, /Ovo je testna stranica - 1/, 'Must convert cyrillic with latin variant');
assert.checkString(res.body, /Ovo je testna stranica - 2/, 'Must not convert latin with latin variant');
Expand Down
9 changes: 7 additions & 2 deletions test/utils/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ function isDeepEqual(result, expected, message) {

function deepEqual(result, expected, message) {
try {
if (typeof expected === 'string') {
assert.ok(result === expected || (new RegExp('^' + expected + '$').test(result)));
if ( expected === result ) {
return;
} else if (typeof expected === 'string') {
assert.ok(
new RegExp('^' + expected + '$').test(result),
`Expected: ${expected}; Result: ${result}`
);
} else {
assert.deepEqual(result, expected, message);
}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TestRestbase {
apiBase,
apiPath,
apiURL,
parsoidURI: 'http://parsoid-external-ci-access.beta.wmflabs.org/w/rest.php',
parsoidURI: 'https://en.wikipedia.beta.wmflabs.org/w/rest.php',
conf
}
}
Expand Down

0 comments on commit 8a6ab4a

Please sign in to comment.