Skip to content

Commit

Permalink
Bug 1889702 - Change search-config-v2 validation to allow only requir…
Browse files Browse the repository at this point in the history
…e a telemetrySuffix with a partnerCode when it is for a distribution. r=mcheang

Differential Revision: https://phabricator.services.mozilla.com/D206676
  • Loading branch information
Standard8 committed Apr 11, 2024
1 parent b5e9f5a commit d2bf175
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
7 changes: 2 additions & 5 deletions toolkit/components/search/schema/search-config-v2-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
},
"telemetrySuffix": {
"title": "Telemetry Suffix",
"description": "Suffix that is appended to the search engine identifier following a dash, i.e. `<identifier>-<suffix>`. There should always be a suffix supplied if the partner code is different.",
"description": "Suffix that is appended to the search engine identifier following a dash, i.e. `<identifier>-<suffix>`. There should always be a suffix supplied if the partner code is different for a reason other than being on a different platform.",
"type": "string",
"pattern": "^[a-zA-Z0-9-]*$"
},
Expand Down Expand Up @@ -384,10 +384,7 @@
}
}
},
"required": ["environment"],
"dependencies": {
"partnerCode": ["telemetrySuffix"]
}
"required": ["environment"]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,32 @@ add_task(
}
);

add_task(
{ skip_if: () => !SearchUtils.newSearchConfigEnabled },
async function test_search_config_valid_partner_codes() {
delete SearchUtils.newSearchConfigEnabled;
SearchUtils.newSearchConfigEnabled = true;

let selector = new SearchEngineSelector(() => {});

for (let entry of await selector.getEngineConfiguration()) {
if (entry.recordType == "engine") {
for (let variant of entry.variants) {
if (
"partnerCode" in variant &&
"distributions" in variant.environment
) {
Assert.ok(
variant.telemetrySuffix,
`${entry.identifier} should have a telemetrySuffix when a distribution is specified with a partnerCode.`
);
}
}
}
}
}
);

add_task(
{ skip_if: () => !SearchUtils.newSearchConfigEnabled },
async function test_search_config_override_validates_to_schema() {
Expand Down

0 comments on commit d2bf175

Please sign in to comment.