1
+ import { test , expect } from '@playwright/test' ;
2
+
3
+ test . describe ( 'Docs Section' , ( ) => {
4
+ test ( 'should navigate through docs section with nested routes' , async ( { page } ) => {
5
+ // Navigate to docs index
6
+ await page . goto ( '/docs' ) ;
7
+
8
+ // Verify the docs index page is shown
9
+ await expect ( page ) . toHaveURL ( '/docs' ) ;
10
+
11
+ // Navigate to getting-started page
12
+ await page . goto ( '/docs/getting-started' ) ;
13
+ await expect ( page ) . toHaveURL ( '/docs/getting-started' ) ;
14
+
15
+ // Navigate to advanced page
16
+ await page . goto ( '/docs/advanced' ) ;
17
+ await expect ( page ) . toHaveURL ( '/docs/advanced' ) ;
18
+
19
+ // Verify layouts are preserved during navigation
20
+ await page . goto ( '/docs' ) ;
21
+
22
+ // Check for the main navigation menu
23
+ const mainNav = page . locator ( 'header nav' ) ;
24
+ await expect ( mainNav ) . toBeVisible ( ) ;
25
+ await expect ( mainNav . locator ( 'a[href="/docs"]' ) ) . toBeVisible ( ) ;
26
+ } ) ;
27
+
28
+ test ( 'should preserve layout when navigating between nested routes' , async ( { page } ) => {
29
+ // Start at docs index
30
+ await page . goto ( '/docs' ) ;
31
+
32
+ // Click on the Documentation link in the main nav
33
+ const mainNav = page . locator ( 'header nav' ) ;
34
+ const docsLink = mainNav . locator ( 'a[href="/docs"]' ) ;
35
+ await expect ( docsLink ) . toBeVisible ( ) ;
36
+ await expect ( docsLink ) . toHaveAttribute ( 'aria-current' , 'page' ) ;
37
+
38
+ // Navigate to getting-started
39
+ await page . goto ( '/docs/getting-started' ) ;
40
+ await expect ( page ) . toHaveURL ( '/docs/getting-started' ) ;
41
+
42
+ // The main navigation should still be visible
43
+ await expect ( mainNav ) . toBeVisible ( ) ;
44
+ await expect ( docsLink ) . toBeVisible ( ) ;
45
+
46
+ // Navigate to advanced
47
+ await page . goto ( '/docs/advanced' ) ;
48
+ await expect ( page ) . toHaveURL ( '/docs/advanced' ) ;
49
+
50
+ // Navigation should still be preserved
51
+ await expect ( mainNav ) . toBeVisible ( ) ;
52
+ await expect ( docsLink ) . toBeVisible ( ) ;
53
+ } ) ;
54
+ } ) ;
0 commit comments