Skip to content

Commit e945dc7

Browse files
Update and Remove tests
wip: still need link attribution addition and removal tests
1 parent 322b8c0 commit e945dc7

4 files changed

Lines changed: 956 additions & 2 deletions

File tree

springfield/privacy/templates/privacy/cookie-settings-flare26.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ <h4 class="cookie-summary-title">
9090
</div>
9191
</details>
9292
</li>
93-
<li class="cookie-category">
93+
<li class="cookie-category" data-testid="cookie-consent-analytics">
9494
<h3 class="fl-heading-sm cookie-category-title">
9595
{{ ftl('cookie-settings-category-analytics-heading') }}
9696
</h3>

tests/playwright/specs/download-attribution/create.spec.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ function forceEssentialCampaign() {
163163
}
164164
}
165165

166+
const existingMarketingParams =
167+
'utm_source=newsletter&utm_medium=email&utm_campaign=existing';
168+
166169
test.describe('marketing download attribution', () => {
167170
test('has expected cookie values', async ({ page, browserName }) => {
168171
await page.addInitScript(mockGetGtagClientID);
@@ -271,7 +274,7 @@ test.describe('marketing download attribution', () => {
271274
() => {
272275
const url = '/en-US/?geo=us';
273276

274-
test('on cookie created', async ({ page, browserName }) => {
277+
test('cookie created', async ({ page, browserName }) => {
275278
await page.addInitScript(mockGetGtagClientID);
276279

277280
const capture = { params: null };
@@ -462,6 +465,63 @@ test.describe('marketing download attribution', () => {
462465
}
463466
);
464467
});
468+
469+
test.describe(
470+
'user action grants consent',
471+
{
472+
tag: '@firefox'
473+
},
474+
() => {
475+
test('cookie created', async ({ page, browserName }) => {
476+
await page.addInitScript(interceptInitMarketing);
477+
await page.addInitScript(mockGetGtagClientID);
478+
await openPage(
479+
`/fr/?geo=fr&mozcb=y&${existingMarketingParams}`,
480+
page,
481+
browserName
482+
);
483+
484+
// confirm there's no existing cookie
485+
await page.waitForLoadState('networkidle');
486+
487+
const initMarketingCalled = await page.evaluate(
488+
() => window.__initMarketingCalled
489+
);
490+
expect(initMarketingCalled).toBe(false);
491+
492+
const existingMarketingCookies = await page.context().cookies();
493+
const existingMarketingCookie = existingMarketingCookies.find(
494+
(c) => c.name === 'moz-download-attribution-marketing-raw'
495+
);
496+
expect(existingMarketingCookie).toBeUndefined();
497+
498+
// change consent status
499+
const acceptButton = page.getByTestId(
500+
'consent-banner-accept-button'
501+
);
502+
acceptButton.click();
503+
504+
// check marketing cookie was added
505+
await page.waitForFunction(() => {
506+
return document.cookie
507+
.split(';')
508+
.some((c) =>
509+
c
510+
.trim()
511+
.startsWith(
512+
'moz-download-attribution-marketing-raw='
513+
)
514+
);
515+
});
516+
517+
const cookies = await page.context().cookies();
518+
const marketingCookie = cookies.find(
519+
(c) => c.name === 'moz-download-attribution-marketing-raw'
520+
);
521+
expect(marketingCookie).toBeDefined();
522+
});
523+
}
524+
);
465525
});
466526

467527
test.describe('essential download attribution', () => {

0 commit comments

Comments
 (0)