Skip to content

Commit 8d6f627

Browse files
committed
Skip Duck Player step when ad blocking is enabled
1 parent ce153da commit 8d6f627

File tree

5 files changed

+62
-30
lines changed

5 files changed

+62
-30
lines changed

special-pages/pages/onboarding/app/components/v3/data.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ export const stepsConfig = {
8383
content: <SettingsStep data={settingsRowItems} />,
8484
};
8585
},
86-
duckPlayerSingle: ({ t, globalState, advance, beforeAfter }) => {
87-
const isYouTubeAdBlockingEnabled = globalState.values['youtube-ad-blocking']?.enabled ?? false;
88-
const title = isYouTubeAdBlockingEnabled ? t('duckPlayer_alt_title') : t('duckPlayer_title');
89-
const subtitle = isYouTubeAdBlockingEnabled ? t('duckPlayer_alt_subtitle') : t('duckPlayer_subtitle');
86+
duckPlayerSingle: ({ t, advance, beforeAfter }) => {
9087
const beforeAfterState = beforeAfter.get();
9188
const longestText = [t('beforeAfter_duckPlayer_show'), t('beforeAfter_duckPlayer_hide')].reduce((acc, cur) => {
9289
return cur.length > acc.length ? cur : acc;
@@ -95,8 +92,8 @@ export const stepsConfig = {
9592
return {
9693
variant: 'box',
9794
heading: {
98-
title,
99-
subtitle,
95+
title: t('duckPlayer_title'),
96+
subtitle: t('duckPlayer_subtitle'),
10097
speechBubble: true,
10198
},
10299
dismissButton: {

special-pages/pages/onboarding/app/global.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export function reducer(state, action) {
7676
/** @type {import('./types').SystemValueId} */
7777
const systemValueId = action.id;
7878

79+
// skip Duck Player onboarding step when ad blocking is enabled
80+
// note: there's no UI for disabling this setting, so we never need to re-insert duckPlayerSingle into order
81+
const isAdBlockingSetting = systemValueId === 'ad-blocking' || systemValueId === 'youtube-ad-blocking';
82+
const nextOrder =
83+
isAdBlockingSetting && action.payload.enabled
84+
? state.order.filter((step) => step !== 'duckPlayerSingle')
85+
: state.order;
86+
7987
/** @type {import('./types').UIValue} */
8088
const nextUIState = isCurrent && action.payload.enabled ? 'accepted' : 'skipped';
8189

@@ -86,6 +94,7 @@ export function reducer(state, action) {
8694
// bump the step (show the next row)
8795
...state.step,
8896
},
97+
order: nextOrder,
8998
activeRow: isCurrent ? state.activeRow + 1 : state.activeRow,
9099
values: {
91100
...state.values,

special-pages/pages/onboarding/integration-tests/onboarding.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,10 @@ export class OnboardingPage {
699699
await this.startBrowsing();
700700
}
701701

702-
async completesOrderV3WithAdBlocking() {
702+
/**
703+
* @param {'ad-blocking'|'youtube-ad-blocking'} adBlockingId
704+
*/
705+
async completesOrderV3WithAdBlockingEnabled(adBlockingId) {
703706
const { page } = this;
704707

705708
/* Welcome */
@@ -715,22 +718,23 @@ export class OnboardingPage {
715718
await page.getByText('Excellent!').nth(1).waitFor({ timeout: 1000 });
716719
await page.getByRole('button', { name: 'Next' }).click();
717720

718-
/* System settings (with ad-blocking) */
721+
/* System settings */
719722
await page.getByText('Let’s get you set up!').nth(1).waitFor({ timeout: 1000 });
720723
const dockButton = this.build.switch({
721724
windows: () => page.getByRole('button', { name: 'Pin to Taskbar' }),
722725
apple: () => page.getByRole('button', { name: 'Keep in Dock' }),
723726
});
724727
await dockButton.click();
725-
await page.getByRole('button', { name: 'Turn on Enhanced Ad Blocking', exact: true }).click();
728+
await page
729+
.getByRole('button', {
730+
name: adBlockingId === 'youtube-ad-blocking' ? 'Block Ads' : 'Turn on Enhanced Ad Blocking',
731+
exact: true,
732+
})
733+
.click();
726734
await page.getByRole('button', { name: 'Import Now', exact: true }).click();
727735
await page.getByRole('button', { name: 'Next' }).click();
728736

729-
/* Duckplayer */
730-
await page.getByText('Drowning in ads').nth(1).waitFor({ timeout: 1000 });
731-
await page.getByLabel('See Without Duck Player').click();
732-
await page.getByLabel('See With Duck Player').click();
733-
await page.getByRole('button', { name: 'Next' }).click();
737+
/* No Duck Player step as ad blocking was enabled */
734738

735739
/* Customize */
736740
await page.getByText('Let’s customize a few things').nth(1).waitFor({ timeout: 1000 });
@@ -740,8 +744,9 @@ export class OnboardingPage {
740744
await this.startBrowsing();
741745
}
742746

743-
async completesOrderV3WithYouTubeAdBlocking() {
747+
async completesOrderV3WithAdBlockingDisabled() {
744748
const { page } = this;
749+
745750
/* Welcome */
746751
await page.getByText('Welcome to DuckDuckGo').nth(1).waitFor({ timeout: 1000 });
747752

@@ -755,20 +760,19 @@ export class OnboardingPage {
755760
await page.getByText('Excellent!').nth(1).waitFor({ timeout: 1000 });
756761
await page.getByRole('button', { name: 'Next' }).click();
757762

758-
/* System settings (with youtube ad-blocking) */
763+
/* System settings */
759764
await page.getByText('Let’s get you set up!').nth(1).waitFor({ timeout: 1000 });
760765
const dockButton = this.build.switch({
761766
windows: () => page.getByRole('button', { name: 'Pin to Taskbar' }),
762767
apple: () => page.getByRole('button', { name: 'Keep in Dock' }),
763768
});
764769
await dockButton.click();
765-
await page.getByRole('button', { name: 'Block Ads', exact: true }).click();
770+
await page.getByRole('button', { name: 'Skip', exact: true }).click();
766771
await page.getByRole('button', { name: 'Import Now', exact: true }).click();
767772
await page.getByRole('button', { name: 'Next' }).click();
768773

769-
/* Duckplayer - alternate title/subtitle */
770-
await page.getByText('Watch YouTube privately with Duck Player').nth(1).waitFor({ timeout: 1000 });
771-
await expect(page.locator('h2')).toContainText("Watching videos in Duck Player won't influence your YouTube recommendations.");
774+
/* Duck Player */
775+
await page.getByText('Drowning in ads').nth(1).waitFor({ timeout: 1000 });
772776
await page.getByLabel('See Without Duck Player').click();
773777
await page.getByLabel('See With Duck Player').click();
774778
await page.getByRole('button', { name: 'Next' }).click();

special-pages/pages/onboarding/integration-tests/onboarding.spec.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,22 @@ test.describe('onboarding', () => {
246246
await onboarding.reducedMotion();
247247
await onboarding.darkMode();
248248
await onboarding.openPage();
249-
await onboarding.completesOrderV3WithAdBlocking();
249+
await onboarding.completesOrderV3WithAdBlockingEnabled('ad-blocking');
250+
});
251+
test('shows v3 flow with ad blocking disabled', async ({ page }, workerInfo) => {
252+
const onboarding = OnboardingPage.create(page, workerInfo);
253+
onboarding.withInitData({
254+
stepDefinitions: {
255+
systemSettings: {
256+
rows: ['dock', 'ad-blocking', 'import'],
257+
},
258+
},
259+
order: 'v3',
260+
});
261+
await onboarding.reducedMotion();
262+
await onboarding.darkMode();
263+
await onboarding.openPage();
264+
await onboarding.completesOrderV3WithAdBlockingDisabled();
250265
});
251266
test('shows v3 flow with YouTube ad blocking', async ({ page }, workerInfo) => {
252267
const onboarding = OnboardingPage.create(page, workerInfo);
@@ -261,7 +276,22 @@ test.describe('onboarding', () => {
261276
await onboarding.reducedMotion();
262277
await onboarding.darkMode();
263278
await onboarding.openPage();
264-
await onboarding.completesOrderV3WithYouTubeAdBlocking();
279+
await onboarding.completesOrderV3WithAdBlockingEnabled('youtube-ad-blocking');
280+
});
281+
test('shows v3 flow with YouTube ad blocking disabled', async ({ page }, workerInfo) => {
282+
const onboarding = OnboardingPage.create(page, workerInfo);
283+
onboarding.withInitData({
284+
stepDefinitions: {
285+
systemSettings: {
286+
rows: ['dock', 'youtube-ad-blocking', 'import'],
287+
},
288+
},
289+
order: 'v3',
290+
});
291+
await onboarding.reducedMotion();
292+
await onboarding.darkMode();
293+
await onboarding.openPage();
294+
await onboarding.completesOrderV3WithAdBlockingDisabled();
265295
});
266296
test.describe('Given I am on the settings step', () => {
267297
test('When I have choosen to add to dock/taskbar', async ({ page }, workerInfo) => {

special-pages/pages/onboarding/public/locales/en/onboarding.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,6 @@
285285
"title": "No targeted ads. No targeted recommendations. Just your video.",
286286
"note": "Subtitle for a page that shows the benefits of using the Duck Player feature to watch YouTube videos more privately."
287287
},
288-
"duckPlayer_alt_title": {
289-
"title": "Watch YouTube privately with Duck Player",
290-
"note": "Alternative title for Duck Player step when YouTube ad blocking is also offered."
291-
},
292-
"duckPlayer_alt_subtitle": {
293-
"title": "Watching videos in Duck Player won't influence your YouTube recommendations.",
294-
"note": "Alternative subtitle for Duck Player step when YouTube ad blocking is also offered."
295-
},
296288
"customize_title_v3": {
297289
"title": "Let’s customize a few things…",
298290
"note": "Title for a page that allows the user to customize specific settings in the DuckDuckGo browser."

0 commit comments

Comments
 (0)