Skip to content

Commit d159788

Browse files
authored
Add end-to-end tests for table of contents navigation (#3741)
1 parent 3355960 commit d159788

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,58 @@ const testCases: TestsCase[] = [
228228
);
229229
},
230230
},
231+
{
232+
name: 'Expandable TOC navigation',
233+
url: '',
234+
run: async (page) => {
235+
await waitForCookiesDialog(page);
236+
237+
// Verify "Navigation" link is not visible initially
238+
const navigationLink = page.getByRole('link', { name: 'Navigation' });
239+
await expect(navigationLink).not.toBeVisible();
240+
241+
// Find and click the chevron element that is next to "Editor" in the TOC
242+
// It is a span inside the link
243+
const editorChevron = page
244+
.getByRole('link', { name: 'Editor' })
245+
.locator('span');
246+
await editorChevron.click();
247+
248+
// Verify "Navigation" link becomes visible after expansion
249+
await expect(navigationLink).toBeVisible();
250+
},
251+
},
252+
{
253+
name: 'Expandable nested TOC navigation',
254+
url: '',
255+
screenshot: false,
256+
run: async (page) => {
257+
await waitForCookiesDialog(page);
258+
259+
// Verify "Spaces" link is not visible initially
260+
const navigationLink = page.getByRole('link', { name: 'Spaces' });
261+
await expect(navigationLink).not.toBeVisible();
262+
263+
// Find and click the chevron element that is next to "Editor" in the TOC
264+
// It is a span inside the link
265+
const editorChevron = page
266+
.getByRole('link', { name: 'Editor' })
267+
.locator('span');
268+
await editorChevron.click();
269+
270+
// At this stage the link should still not be visible
271+
await expect(navigationLink).not.toBeVisible();
272+
273+
// Then we click 'Content Structure' chevron to expand further
274+
const contentStructureChevron = page
275+
.getByRole('link', { name: 'Content Structure' })
276+
.locator('span');
277+
await contentStructureChevron.click();
278+
279+
// Verify "Spaces" link becomes visible after expansion
280+
await expect(navigationLink).toBeVisible();
281+
},
282+
},
231283
...searchTestCases,
232284
{
233285
name: 'Not found',

0 commit comments

Comments
 (0)