commit 9d9307780f9d0ae69339cfdd5c3e147b460e21e1
parent 7bfedfcd97c61067034be540203fae9440b6508c
Author: Florian Quèze <florian@queze.net>
Date: Tue, 30 Sep 2025 20:41:00 +0000
Bug 1991615 - merge test_wikipedia.js into test_searchconfigs.js, r=Standard8.
Differential Revision: https://phabricator.services.mozilla.com/D266780
Diffstat:
3 files changed, 161 insertions(+), 173 deletions(-)
diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/test_searchconfig.js b/toolkit/components/search/tests/xpcshell/searchconfigs/test_searchconfig.js
@@ -3,6 +3,165 @@
"use strict";
+// Wikipedia locale-to-domain mapping configuration
+const WIKIPEDIA_LOCALES_INFO = [
+ [["af"]],
+ [["an"]],
+ [["ar"]],
+ [["ast"]],
+ [["az"]],
+ [["be"]],
+ [["bg"]],
+ [["bn"]],
+ [["br"]],
+ [["bs"]],
+ [["ca", "ca-valencia"], "ca", "ca"],
+ [["cs"], "cs", "cz"],
+ [["cy"]],
+ [["da"]],
+ [["de"]],
+ [["dsb"]],
+ [["el"]],
+ [["eo"]],
+ [["cak", "es-AR", "es-CL", "es-ES", "es-MX", "trs"], "es", "es"],
+ [["et"]],
+ [["eu"]],
+ [["fa"]],
+ [["fi"]],
+ [["fr", "ff", "son"], "fr", "fr"],
+ [["fy-NL"], "fy", "fy-NL"],
+ [["ga-IE"], "ga", "ga-IE"],
+ [["gd"]],
+ [["gl"]],
+ [["gn"]],
+ [["gu-IN"], "gu", "gu"],
+ [["hi-IN"], "hi", "hi"],
+ [["he"]],
+ [["hr"]],
+ [["hsb"]],
+ [["hu"]],
+ [["hy-AM"], "hy", "hy"],
+ [["ia"]],
+ [["id"]],
+ [["is"]],
+ [["ja", "ja-JP-macos"], "ja", "ja"],
+ [["ka"]],
+ [["kab"]],
+ [["kk"]],
+ [["km"]],
+ [["kn"]],
+ [["ko"], "ko", "kr"],
+ [["it", "fur", "sc"], "it", "it"],
+ [["lij"]],
+ [["lo"]],
+ [["lt"]],
+ [["ltg"]],
+ [["lv"]],
+ [["mk"]],
+ [["mr"]],
+ [["ms"]],
+ [["my"]],
+ [["nb-NO"], "no", "NO"],
+ [["ne-NP"], "ne", "ne"],
+ [["nl"]],
+ [["nn-NO"], "nn", "NN"],
+ [["oc"]],
+ [["pa-IN"], "pa", "pa"],
+ [["pl", "szl"], "pl", "pl"],
+ [["pt-BR", "pt-PT"], "pt", "pt"],
+ [["rm"]],
+ [["ro"]],
+ [["ru"]],
+ [["si"]],
+ [["sk"]],
+ [["sl"]],
+ [["sq"]],
+ [["sr"]],
+ [["sv-SE"], "sv", "sv-SE"],
+ [["ta"]],
+ [["te"]],
+ [["th"]],
+ [["tl"]],
+ [["tr"]],
+ [["uk"]],
+ [["ur"]],
+ [["uz"]],
+ [["vi"]],
+ [["wo"]],
+ [["zh-CN"], "zh", "zh-CN"],
+ [["zh-TW"], "zh", "zh-TW"],
+];
+
+const wikipediaConfig = {
+ identifierStartsWith: "wikipedia",
+ default: {
+ // Not default anywhere.
+ },
+ available: {
+ excluded: [
+ // Should be available everywhere.
+ ],
+ },
+ details: [
+ // Details will be populated in populateWikipediaConfig.
+ ],
+};
+
+/**
+ * Generates the expected details for the given locales and inserts
+ * them into the wikipediaConfig.
+ *
+ * @param {string[]} locales
+ * The locales for this details entry - which locales this variant of
+ * Wikipedia is expected to be deployed to.
+ * @param {string} [subDomainName]
+ * The expected sub domain name for this variant of Wikipedia. If not
+ * specified, defaults to the first item in the locales array.
+ * @param {string} [telemetrySuffix]
+ * The expected suffix used when this variant is reported via telemetry. If
+ * not specified, defaults to the first item in the array. If this is the
+ * empty string, then it "wikipedia" (i.e. no suffix) will be the expected
+ * value.
+ */
+function generateExpectedDetails(locales, subDomainName, telemetrySuffix) {
+ if (!subDomainName) {
+ subDomainName = locales[0];
+ }
+ if (telemetrySuffix == undefined) {
+ telemetrySuffix = locales[0];
+ }
+ wikipediaConfig.details.push({
+ domain: `${subDomainName}.wikipedia.org`,
+ telemetryId: telemetrySuffix ? `wikipedia-${telemetrySuffix}` : "wikipedia",
+ required_aliases: ["@wikipedia"],
+ included: [{ locales }],
+ });
+}
+
+/**
+ * Populates the Wikipedia configuration with locale-to-domain mappings.
+ * For the "en" version of Wikipedia, we ship it to all locales where other
+ * Wikipedias are not shipped.
+ */
+async function populateWikipediaConfig() {
+ const allLocales = await test.getLocales();
+
+ // Build list of locales for en.wikipedia.org
+ let enLocales = [];
+ for (let locale of allLocales) {
+ if (!WIKIPEDIA_LOCALES_INFO.find(d => d[0].includes(locale))) {
+ enLocales.push(locale);
+ }
+ }
+
+ console.log("en.wikipedia.org expected locales are:", enLocales);
+ generateExpectedDetails(enLocales, "en", "");
+
+ for (let details of WIKIPEDIA_LOCALES_INFO) {
+ generateExpectedDetails(...details);
+ }
+}
+
const test = new SearchConfigTest([
{
identifier: "amazondotcom-us",
@@ -153,6 +312,7 @@ const test = new SearchConfigTest([
},
],
},
+ wikipediaConfig,
{
identifier: "yahoo-jp",
aliases: [],
@@ -178,6 +338,7 @@ const test = new SearchConfigTest([
]);
add_setup(async function () {
+ await populateWikipediaConfig();
await test.setup();
});
diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/test_wikipedia.js b/toolkit/components/search/tests/xpcshell/searchconfigs/test_wikipedia.js
@@ -1,171 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const testConfiguration = {
- identifierStartsWith: "wikipedia",
- default: {
- // Not default anywhere.
- },
- available: {
- excluded: [
- // Should be available everywhere.
- ],
- },
- details: [
- // Details generated below.
- ],
-};
-
-/**
- * Generates the expected details for the given locales and inserts
- * them into the testConfiguration.
- *
- * @param {string[]} locales
- * The locales for this details entry - which locales this variant of
- * Wikipedia is expected to be deployed to.
- * @param {string} [subDomainName]
- * The expected sub domain name for this variant of Wikipedia. If not
- * specified, defaults to the first item in the locales array.
- * @param {string} [telemetrySuffix]
- * The expected suffix used when this variant is reported via telemetry. If
- * not specified, defaults to the first item in the array. If this is the
- * empty string, then it "wikipedia" (i.e. no suffix) will be the expected
- * value.
- */
-function generateExpectedDetails(locales, subDomainName, telemetrySuffix) {
- if (!subDomainName) {
- subDomainName = locales[0];
- }
- if (telemetrySuffix == undefined) {
- telemetrySuffix = locales[0];
- }
- testConfiguration.details.push({
- domain: `${subDomainName}.wikipedia.org`,
- telemetryId: telemetrySuffix ? `wikipedia-${telemetrySuffix}` : "wikipedia",
- required_aliases: ["@wikipedia"],
- included: [{ locales }],
- });
-}
-
-// This is an array of an array of arguments to be passed to generateExpectedDetails().
-// These are the locale, sub domain name and telemetry id suffix expectations for
-// the test to check.
-// Note that the expectations for en.wikipedia.com are generated in add_setup.
-const LOCALES_INFO = [
- [["af"]],
- [["an"]],
- [["ar"]],
- [["ast"]],
- [["az"]],
- [["be"]],
- [["bg"]],
- [["bn"]],
- [["br"]],
- [["bs"]],
- [["ca", "ca-valencia"], "ca", "ca"],
- [["cs"], "cs", "cz"],
- [["cy"]],
- [["da"]],
- [["de"]],
- [["dsb"]],
- [["el"]],
- [["eo"]],
- [["cak", "es-AR", "es-CL", "es-ES", "es-MX", "trs"], "es", "es"],
- [["et"]],
- [["eu"]],
- [["fa"]],
- [["fi"]],
- [["fr", "ff", "son"], "fr", "fr"],
- [["fy-NL"], "fy", "fy-NL"],
- [["ga-IE"], "ga", "ga-IE"],
- [["gd"]],
- [["gl"]],
- [["gn"]],
- [["gu-IN"], "gu", "gu"],
- [["hi-IN"], "hi", "hi"],
- [["he"]],
- [["hr"]],
- [["hsb"]],
- [["hu"]],
- [["hy-AM"], "hy", "hy"],
- [["ia"]],
- [["id"]],
- [["is"]],
- [["ja", "ja-JP-macos"], "ja", "ja"],
- [["ka"]],
- [["kab"]],
- [["kk"]],
- [["km"]],
- [["kn"]],
- [["ko"], "ko", "kr"],
- [["it", "fur", "sc"], "it", "it"],
- [["lij"]],
- [["lo"]],
- [["lt"]],
- [["ltg"]],
- [["lv"]],
- [["mk"]],
- [["mr"]],
- [["ms"]],
- [["my"]],
- [["nb-NO"], "no", "NO"],
- [["ne-NP"], "ne", "ne"],
- [["nl"]],
- [["nn-NO"], "nn", "NN"],
- [["oc"]],
- [["pa-IN"], "pa", "pa"],
- [["pl", "szl"], "pl", "pl"],
- [["pt-BR", "pt-PT"], "pt", "pt"],
- [["rm"]],
- [["ro"]],
- [["ru"]],
- [["si"]],
- [["sk"]],
- [["sl"]],
- [["sq"]],
- [["sr"]],
- [["sv-SE"], "sv", "sv-SE"],
- [["ta"]],
- [["te"]],
- [["th"]],
- [["tl"]],
- [["tr"]],
- [["uk"]],
- [["ur"]],
- [["uz"]],
- [["vi"]],
- [["wo"]],
- [["zh-CN"], "zh", "zh-CN"],
- [["zh-TW"], "zh", "zh-TW"],
-];
-
-const test = new SearchConfigTest(testConfiguration);
-
-add_setup(async function () {
- const allLocales = await test.getLocales();
-
- // For the "en" version of Wikipedia, we ship it to all locales where other
- // Wikipedias are not shipped. We form the list based on all-locales to avoid
- // needing to update the test whenever all-locales is updated.
- let enLocales = [];
- for (let locale of allLocales) {
- if (!LOCALES_INFO.find(d => d[0].includes(locale))) {
- enLocales.push(locale);
- }
- }
-
- console.log("en.wikipedia.org expected locales are:", enLocales);
- generateExpectedDetails(enLocales, "en", "");
-
- for (let details of LOCALES_INFO) {
- generateExpectedDetails(...details);
- }
-
- await test.setup();
-});
-
-add_task(async function test_searchConfig_wikipedia() {
- await test.run();
-});
diff --git a/toolkit/components/search/tests/xpcshell/searchconfigs/xpcshell.toml b/toolkit/components/search/tests/xpcshell/searchconfigs/xpcshell.toml
@@ -55,5 +55,3 @@ support-files = [
]
["test_selector_db_out_of_date.js"]
-
-["test_wikipedia.js"]