Skip to content

Commit f33082f

Browse files
committed
test: failing test for #405
1 parent 13b9312 commit f33082f

File tree

3 files changed

+50
-10
lines changed

3 files changed

+50
-10
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
type: lesson
3+
title: Layout change all off
4+
previews: false
5+
terminal: false
6+
editor: false
7+
---
8+
9+
# Navigation test - Layout change all off
10+
11+
This page should not show previw, editor or terminal.

e2e/src/content/tutorial/tests/navigation/meta.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ lessons:
55
- page-one
66
- page-two
77
- page-three
8+
- layout-change-all-off
89
- layout-change-from
910
- layout-change-to
1011
mainCommand: ''

e2e/test/navigation.test.ts

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
import { test, expect } from '@playwright/test';
1+
import { test as base, expect } from '@playwright/test';
2+
3+
const test = base.extend<{ menu: { navigate: (name: { from: string; to: string }) => Promise<void> } }>({
4+
menu: async ({ page }, use) => {
5+
async function navigate({ from, to }: { from: string; to: string }) {
6+
// navigation select can take a while to hydrate on page load, click until responsive
7+
await expect(async () => {
8+
const button = page.getByRole('button', { name: `Tests / Navigation / ${from}` });
9+
await button.click();
10+
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 });
11+
}).toPass();
12+
13+
await page.getByRole('region', { name: 'Navigation' }).getByRole('link', { name: to }).click();
14+
}
15+
16+
await use({ navigate });
17+
},
18+
});
219

320
const BASE_URL = '/tests/navigation';
421

@@ -20,17 +37,10 @@ test('user can navigate between lessons using nav bar links', async ({ page }) =
2037
}
2138
});
2239

23-
test('user can navigate between lessons using breadcrumbs', async ({ page }) => {
40+
test('user can navigate between lessons using breadcrumbs', async ({ page, menu }) => {
2441
await page.goto(`${BASE_URL}/page-one`);
2542

26-
// navigation select can take a while to hydrate on page load, click until responsive
27-
await expect(async () => {
28-
const button = page.getByRole('button', { name: 'Tests / Navigation / Page one' });
29-
await button.click();
30-
await expect(page.locator('[data-state="open"]', { has: button })).toBeVisible({ timeout: 50 });
31-
}).toPass();
32-
33-
await page.getByRole('region', { name: 'Navigation' }).getByRole('link', { name: 'Page three' }).click();
43+
await menu.navigate({ from: 'Page one', to: 'Page three' });
3444

3545
await expect(page.getByRole('heading', { level: 1, name: 'Navigation test - Page three' })).toBeVisible();
3646
});
@@ -56,3 +66,21 @@ test("user should see metadata's layout changes after navigation (#318)", async
5666
useInnerText: true,
5767
});
5868
});
69+
70+
test('user should not see preview on lessons that disable it (#405)', async ({ page, menu }) => {
71+
await page.goto(`${BASE_URL}/layout-change-from`);
72+
73+
// first page should have preview visible
74+
await expect(page.getByRole('heading', { level: 1, name: 'Navigation test - Layout change from' })).toBeVisible();
75+
76+
const preview = page.frameLocator('[title="Custom preview"]');
77+
await expect(preview.getByText('Index page')).toBeVisible();
78+
79+
await menu.navigate({ from: 'Layout change from', to: 'Layout change all off' });
80+
81+
// page should open
82+
await expect(page.getByRole('heading', { level: 1, name: 'Navigation test - Layout change all off' })).toBeVisible();
83+
84+
// preview should not be visible
85+
await expect(page.locator('iframe[title="Custom preview"]')).not.toBeVisible();
86+
});

0 commit comments

Comments
 (0)