Bug 1855970 - Add test for review quality explainer link glean event r=perry.mcmanis

Differential Revision: https://phabricator.services.mozilla.com/D192006
This commit is contained in:
Katherine Patenio 2023-10-26 20:04:09 +00:00
Родитель 1c1dcc9c78
Коммит d9a5545618
2 изменённых файлов: 53 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,12 @@ class AnalysisExplainer extends MozLitElement {
productUrl: { type: String, reflect: true },
};
static get queries() {
return {
reviewQualityExplainerLink: "#review-quality-url",
};
}
getGradesDescriptionTemplate() {
return html`
<section id="analysis-explainer-grades-wrapper">
@ -134,6 +140,7 @@ class AnalysisExplainer extends MozLitElement {
@click=${this.handleReviewQualityUrlClicked}
>
<a
id="review-quality-url"
data-l10n-name="review-quality-url"
target="_blank"
href="${window.RPMGetFormatURLPref(

Просмотреть файл

@ -288,6 +288,33 @@ add_task(async function test_powered_by_fakespot_link() {
});
});
add_task(async function test_review_quality_explainer_link() {
await Services.fog.testFlushAllChildren();
Services.fog.testResetFOG();
await BrowserTestUtils.withNewTab(
{
url: "about:shoppingsidebar",
gBrowser,
},
async browser => {
await clickReviewQualityExplainerLink(
browser,
MOCK_ANALYZED_PRODUCT_RESPONSE
);
}
);
await Services.fog.testFlushAllChildren();
let qualityExplainerEvents =
Glean.shopping.surfaceShowQualityExplainerUrlClicked.testGetValue();
assertEventMatches(qualityExplainerEvents[0], {
category: "shopping",
name: "surface_show_quality_explainer_url_clicked",
});
});
function clickReAnalyzeLink(browser, data) {
return SpecialPowers.spawn(browser, [data], async mockData => {
let shoppingContainer =
@ -415,3 +442,22 @@ function clickPoweredByFakespotLink(browser, data) {
fakespotLink.click();
});
}
function clickReviewQualityExplainerLink(browser, data) {
return SpecialPowers.spawn(browser, [data], async mockData => {
let shoppingContainer =
content.document.querySelector("shopping-container").wrappedJSObject;
shoppingContainer.data = Cu.cloneInto(mockData, content);
await shoppingContainer.updateComplete;
let analysisExplainerEl = shoppingContainer.analysisExplainerEl;
await analysisExplainerEl.updateComplete;
let reviewQualityLink = analysisExplainerEl.reviewQualityExplainerLink;
// Prevent link navigation for test.
reviewQualityLink.href = undefined;
await reviewQualityLink.updateComplete;
reviewQualityLink.click();
});
}