From 8a6ab4aa6c660cb2d837246d194072fce9bbafd0 Mon Sep 17 00:00:00 2001 From: Daniel Kinzler Date: Fri, 1 Dec 2023 12:48:59 +0100 Subject: [PATCH] Use beta for tests (#1339) 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 --- DUMMY | 0 config.frontend.test.yaml | 4 ++-- config.fullstack.test.yaml | 4 ++-- test/features/pcs.js | 4 ++-- test/utils/assert.js | 9 +++++++-- test/utils/server.js | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 DUMMY diff --git a/DUMMY b/DUMMY new file mode 100644 index 000000000..e69de29bb diff --git a/config.frontend.test.yaml b/config.frontend.test.yaml index fa7aa672b..e755a420d 100644 --- a/config.frontend.test.yaml +++ b/config.frontend.test.yaml @@ -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.]+"$/' @@ -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: diff --git a/config.fullstack.test.yaml b/config.fullstack.test.yaml index 337931907..1206e69a0 100644 --- a/config.fullstack.test.yaml +++ b/config.fullstack.test.yaml @@ -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.]+"$/' @@ -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: diff --git a/test/features/pcs.js b/test/features/pcs.js index 2c5fa1f03..680104219 100644 --- a/test/features/pcs.js +++ b/test/features/pcs.js @@ -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'); @@ -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'); diff --git a/test/utils/assert.js b/test/utils/assert.js index c2fc159ed..4ebe5e1b6 100644 --- a/test/utils/assert.js +++ b/test/utils/assert.js @@ -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); } diff --git a/test/utils/server.js b/test/utils/server.js index 19d8b6d33..fbc2d44fe 100644 --- a/test/utils/server.js +++ b/test/utils/server.js @@ -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 } }