Skip to content

Commit 8821338

Browse files
OvgoddAntoLC
authored andcommitted
✅(frontend) add e2e test for onboarding modal
Ensure onboarding entrypoint and modal navigation work end-to-end.
1 parent f2ee56a commit 8821338

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { expect, test } from '@playwright/test';
2+
3+
import { overrideConfig } from './utils-common';
4+
5+
test.describe('Help feature', () => {
6+
test.beforeEach(async ({ page }) => {
7+
await page.goto('/');
8+
});
9+
10+
test.describe('Onboarding modal', () => {
11+
test('Help menu not displayed if onboarding is disabled', async ({
12+
page,
13+
}) => {
14+
await overrideConfig(page, {
15+
theme_customization: {
16+
onboarding: {
17+
enabled: false,
18+
},
19+
},
20+
});
21+
22+
await expect(page.getByRole('button', { name: 'New doc' })).toBeVisible();
23+
24+
await expect(
25+
page.getByRole('button', { name: 'Open onboarding menu' }),
26+
).toBeHidden();
27+
});
28+
29+
test('opens onboarding modal from help menu and can navigate/close', async ({
30+
page,
31+
}) => {
32+
await overrideConfig(page, {
33+
theme_customization: {
34+
onboarding: {
35+
enabled: true,
36+
learn_more_url: 'https://example.com/learn-more',
37+
},
38+
},
39+
});
40+
41+
await page.getByRole('button', { name: 'Open onboarding menu' }).click();
42+
43+
await page.getByRole('menuitem', { name: 'Onboarding' }).click();
44+
45+
const modal = page.getByTestId('onboarding-modal');
46+
await expect(modal).toBeVisible();
47+
48+
await expect(page.getByTestId('onboarding-step-0')).toHaveAttribute(
49+
'tabindex',
50+
'0',
51+
);
52+
53+
await page.getByTestId('onboarding-next').click();
54+
await expect(page.getByTestId('onboarding-step-1')).toHaveAttribute(
55+
'tabindex',
56+
'0',
57+
);
58+
59+
await page.getByTestId('onboarding-step-2').click();
60+
await expect(page.getByTestId('onboarding-step-2')).toHaveAttribute(
61+
'tabindex',
62+
'0',
63+
);
64+
65+
await page.getByTestId('onboarding-step-3').click();
66+
await expect(page.getByTestId('onboarding-step-3')).toHaveAttribute(
67+
'tabindex',
68+
'0',
69+
);
70+
71+
const learnMoreLink = page.getByRole('link', {
72+
name: 'Learn more docs features',
73+
});
74+
await expect(learnMoreLink).toHaveAttribute(
75+
'href',
76+
'https://example.com/learn-more',
77+
);
78+
await learnMoreLink.click();
79+
80+
await page.getByRole('button', { name: /understood|compris/i }).click();
81+
await expect(modal).toBeHidden();
82+
});
83+
84+
test('closes modal with Skip button', async ({ page }) => {
85+
await page.getByRole('button', { name: 'Open onboarding menu' }).click();
86+
await page.getByRole('menuitem', { name: 'Onboarding' }).click();
87+
88+
const modal = page.getByTestId('onboarding-modal');
89+
await expect(modal).toBeVisible();
90+
91+
await expect(
92+
page.getByRole('link', {
93+
name: 'Learn more docs features',
94+
}),
95+
).toBeHidden();
96+
97+
await page.getByRole('button', { name: /skip/i }).click();
98+
await expect(modal).toBeHidden();
99+
});
100+
});
101+
});

0 commit comments

Comments
 (0)