Skip to content

Commit a197076

Browse files
author
Micah Tigley
committed
Bug 1947634 - Add tests for CPM tile interaction Glean events. r=rsafaeian,credential-management-reviewers
Depends on D237950 Differential Revision: https://phabricator.services.mozilla.com/D237967
1 parent 9474117 commit a197076

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

toolkit/components/satchel/megalist/content/components/password-card/password-card.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class PasswordCard extends MozLitElement {
128128
}
129129

130130
#recordInteractionType(type) {
131-
Glean.contextualManager.interactionType.record({
131+
Glean.contextualManager.recordsInteraction.record({
132132
interaction_type: type,
133133
});
134134
}

toolkit/components/satchel/megalist/content/tests/browser/browser_passwords_list_alerts.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ add_task(async function test_no_username_alert() {
6363
ok(true, "Cannot test OSAuth.");
6464
return;
6565
}
66+
67+
Services.fog.testResetFOG();
68+
await Services.fog.testFlushAllChildren();
69+
6670
info("Adding a login with no username.");
6771
await Services.logins.addLoginAsync({ ...TEST_LOGIN_1, username: "" });
6872
const megalist = await openPasswordsSidebar();
@@ -77,6 +81,10 @@ add_task(async function test_no_username_alert() {
7781

7882
info("Click on view alerts.");
7983
viewAlertsButton.click();
84+
let events = Glean.contextualManager.recordsInteraction.testGetValue();
85+
assertCPMGleanEvent(events[0], {
86+
interaction_type: "view_alert",
87+
});
8088
const notifMsgBar = await waitForNotification(
8189
megalist,
8290
"no-username-warning"

toolkit/components/satchel/megalist/content/tests/browser/browser_passwords_sidebar.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async function waitForPasswordConceal(passwordLine) {
5656
{
5757
attributeFilter: ["inputtype"],
5858
},
59-
() => passwordLine.loginLine.getAttribute("inputtype") === "password"
59+
() => passwordLine.getAttribute("inputtype") === "password"
6060
);
6161
return concealedPromise;
6262
}
@@ -124,6 +124,9 @@ add_task(async function test_passwords_sidebar() {
124124
});
125125

126126
add_task(async function test_login_line_commands() {
127+
Services.fog.testResetFOG();
128+
await Services.fog.testFlushAllChildren();
129+
127130
await addLocalOriginLogin();
128131
const passwordsSidebar = await openPasswordsSidebar();
129132
await checkAllLoginsRendered(passwordsSidebar);
@@ -146,6 +149,10 @@ add_task(async function test_login_line_commands() {
146149
);
147150
info(`click on ${selector}`);
148151
loginLineInput.click();
152+
let events = Glean.contextualManager.recordsInteraction.testGetValue();
153+
assertCPMGleanEvent(events[0], {
154+
interaction_type: "url_navigate",
155+
});
149156
await browserLoadedPromise;
150157
ok(true, "origin url loaded");
151158
} else if (selector === "usernameLine") {
@@ -154,6 +161,11 @@ add_task(async function test_login_line_commands() {
154161
() => {
155162
info(`click on ${selector}`);
156163
loginLineInput.click();
164+
let events =
165+
Glean.contextualManager.recordsInteraction.testGetValue();
166+
assertCPMGleanEvent(events[1], {
167+
interaction_type: "copy_username",
168+
});
157169
}
158170
);
159171
} else if (
@@ -168,6 +180,11 @@ add_task(async function test_login_line_commands() {
168180
() => {
169181
info(`click on ${selector}`);
170182
loginLineInput.click();
183+
let events =
184+
Glean.contextualManager.recordsInteraction.testGetValue();
185+
assertCPMGleanEvent(events[2], {
186+
interaction_type: "copy_password",
187+
});
171188
}
172189
);
173190
});
@@ -182,12 +199,28 @@ add_task(async function test_login_line_commands() {
182199
);
183200
info("click on reveal button");
184201
revealBtn.click();
202+
203+
let events = Glean.contextualManager.recordsInteraction.testGetValue();
204+
assertCPMGleanEvent(events[3], {
205+
interaction_type: "view_password",
206+
});
207+
185208
await revealBtnPromise;
186209
is(
187210
loginLineInput.value,
188211
expectedPasswordCard[selector].value,
189212
"password revealed"
190213
);
214+
215+
info("click on button again to conceal the password");
216+
revealBtn.click();
217+
await waitForPasswordConceal(loginLine);
218+
ok(true, "Password is hidden.");
219+
220+
events = Glean.contextualManager.recordsInteraction.testGetValue();
221+
assertCPMGleanEvent(events[4], {
222+
interaction_type: "hide_password",
223+
});
191224
}
192225
}
193226

@@ -313,7 +346,7 @@ add_task(async function test_passwords_visibility_when_view_shown() {
313346
megalist = await openPasswordsSidebar();
314347
await checkAllLoginsRendered(megalist);
315348
passwordCard = megalist.querySelector("password-card");
316-
await waitForPasswordConceal(passwordCard.passwordLine);
349+
await waitForPasswordConceal(passwordCard.passwordLine.loginLine);
317350
ok(true, "Password is hidden.");
318351

319352
info(
@@ -323,7 +356,7 @@ add_task(async function test_passwords_visibility_when_view_shown() {
323356
megalist = await openPasswordsSidebar();
324357
await checkAllLoginsRendered(megalist);
325358
passwordCard = megalist.querySelector("password-card");
326-
await waitForPasswordConceal(passwordCard.passwordLine);
359+
await waitForPasswordConceal(passwordCard.passwordLine.loginLine);
327360
ok(true, "Password is hidden.");
328361

329362
SidebarController.hide();

toolkit/components/satchel/megalist/content/tests/browser/browser_passwords_update_login.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ add_task(async function test_update_login_success() {
1919
return;
2020
}
2121

22+
Services.fog.testResetFOG();
23+
await Services.fog.testFlushAllChildren();
24+
2225
const login = TEST_LOGIN_1;
2326
await LoginTestUtils.addLogin(login);
2427

@@ -27,6 +30,10 @@ add_task(async function test_update_login_success() {
2730

2831
const passwordCard = megalist.querySelector("password-card");
2932
await waitForReauth(() => passwordCard.editBtn.click());
33+
let events = Glean.contextualManager.recordsInteraction.testGetValue();
34+
assertCPMGleanEvent(events[0], {
35+
interaction_type: "edit",
36+
});
3037
await BrowserTestUtils.waitForCondition(
3138
() => megalist.querySelector("login-form"),
3239
"Login form failed to render"

0 commit comments

Comments
 (0)