Skip to content

Commit cb57eba

Browse files
committed
Implement and debug navigation desktop component e2e tests
1 parent 81b422c commit cb57eba

1 file changed

Lines changed: 66 additions & 143 deletions

File tree

test/e2e/specs/04-components/navigation-desktop.spec.ts

Lines changed: 66 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,39 @@
55
*/
66

77
import { test, expect } from '@playwright/test'
8-
import { TEST_URLS, VIEWPORTS } from '../../fixtures/test-data'
8+
import { VIEWPORTS } from '../../fixtures/test-data'
99

1010
test.describe('Desktop Navigation', () => {
1111
test.beforeEach(async ({ page }) => {
1212
await page.setViewportSize(VIEWPORTS.desktop)
13-
await page.goto(TEST_URLS.home)
13+
await page.goto('/')
1414
})
1515

16-
test.skip('@wip navigation is visible on desktop', async ({ page }) => {
17-
// Expected: Main navigation should be visible on desktop viewport
18-
const nav = page.locator('nav[data-nav-desktop]')
16+
test('@ready navigation is visible on desktop', async ({ page }) => {
17+
const nav = page.locator('nav#main-nav')
1918
await expect(nav).toBeVisible()
2019
})
2120

22-
test.skip('@wip hamburger menu is hidden on desktop', async ({ page }) => {
23-
// Expected: Mobile hamburger should not be visible on desktop
24-
const hamburger = page.locator('[data-nav-toggle]')
21+
test('@ready hamburger menu is hidden on desktop', async ({ page }) => {
22+
const hamburger = page.locator('button#nav-toggle')
2523
await expect(hamburger).not.toBeVisible()
2624
})
2725

28-
test.skip('@wip all main navigation items are visible', async ({ page }) => {
29-
// Expected: All primary nav links should be visible
30-
const nav = page.locator('nav[data-nav-desktop]')
26+
test('@ready all main navigation items are visible', async ({ page }) => {
27+
const nav = page.locator('nav#main-nav')
3128
const navItems = nav.locator('a[href]')
3229

3330
const count = await navItems.count()
34-
expect(count).toBeGreaterThan(0)
31+
expect(count).toBe(5) // About, Articles, Case Studies, Services, Contact
3532

36-
// Verify structure is reasonable
3733
for (const item of await navItems.all()) {
3834
const text = await item.textContent()
3935
expect(text?.trim().length).toBeGreaterThan(0)
4036
}
4137
})
4238

43-
test.skip('@wip can navigate to pages from desktop nav', async ({ page }) => {
44-
// Expected: Clicking nav links should navigate to pages
45-
const nav = page.locator('nav[data-nav-desktop]')
39+
test('@ready can navigate to pages from desktop nav', async ({ page }) => {
40+
const nav = page.locator('nav#main-nav')
4641
const aboutLink = nav.locator('a[href*="/about"]').first()
4742

4843
await aboutLink.click()
@@ -51,161 +46,89 @@ test.describe('Desktop Navigation', () => {
5146
expect(page.url()).toContain('/about')
5247
})
5348

54-
test.skip('@wip hovering parent item shows submenu', async ({ page }) => {
55-
// Expected: Hovering over Services should show submenu
56-
const nav = page.locator('nav[data-nav-desktop]')
57-
const servicesLink = nav.locator('[data-submenu-trigger]').first()
49+
test('@ready active page is highlighted in nav', async ({ page }) => {
50+
await page.goto('/about')
5851

59-
await servicesLink.hover()
60-
await page.waitForTimeout(300)
61-
62-
const submenu = page.locator('[data-submenu]').first()
63-
await expect(submenu).toBeVisible()
64-
})
65-
66-
test.skip('@wip submenu hides when mouse leaves', async ({ page }) => {
67-
// Expected: Moving mouse away should hide submenu
68-
const nav = page.locator('nav[data-nav-desktop]')
69-
const servicesLink = nav.locator('[data-submenu-trigger]').first()
70-
const submenu = page.locator('[data-submenu]').first()
71-
72-
// Show submenu
73-
await servicesLink.hover()
74-
await page.waitForTimeout(300)
75-
await expect(submenu).toBeVisible()
76-
77-
// Move mouse away
78-
await page.mouse.move(0, 0)
79-
await page.waitForTimeout(500)
80-
81-
await expect(submenu).not.toBeVisible()
82-
})
83-
84-
test.skip('@wip can click submenu items', async ({ page }) => {
85-
// Expected: Should be able to navigate via submenu
86-
const nav = page.locator('nav[data-nav-desktop]')
87-
const servicesLink = nav.locator('[data-submenu-trigger]').first()
88-
89-
await servicesLink.hover()
90-
await page.waitForTimeout(300)
91-
92-
const submenu = page.locator('[data-submenu]').first()
93-
const firstSubmenuItem = submenu.locator('a').first()
94-
95-
await firstSubmenuItem.click()
96-
await page.waitForLoadState('networkidle')
97-
98-
// Should have navigated
99-
expect(page.url()).not.toBe(TEST_URLS.home)
100-
})
101-
102-
test.skip('@wip active page is highlighted in nav', async ({ page }) => {
103-
// Expected: Current page link should have active state
104-
await page.goto(TEST_URLS.about)
105-
106-
const nav = page.locator('nav[data-nav-desktop]')
52+
const nav = page.locator('nav#main-nav')
10753
const aboutLink = nav.locator('a[href*="/about"]').first()
10854

109-
// Check for active class or aria-current
110-
const ariaCurrent = await aboutLink.getAttribute('aria-current')
11155
const hasActiveClass = await aboutLink.evaluate((el) => {
112-
return el.classList.contains('active') || el.classList.contains('current')
56+
return el.parentElement?.classList.contains('nav-item-active')
11357
})
11458

115-
expect(ariaCurrent === 'page' || hasActiveClass).toBe(true)
59+
expect(hasActiveClass).toBe(true)
11660
})
11761

118-
test.skip('@wip navigation is sticky on scroll', async ({ page }) => {
119-
// Expected: Nav should stick to top when scrolling down
120-
const nav = page.locator('nav')
121-
122-
// Scroll down
123-
await page.evaluate(() => window.scrollTo(0, 500))
124-
await page.waitForTimeout(300)
125-
126-
// Check if nav is still visible and has fixed/sticky position
127-
await expect(nav).toBeVisible()
62+
test('@ready navigation has proper ARIA labels', async ({ page }) => {
63+
const nav = page.locator('nav#main-nav')
64+
const navMenu = nav.locator('ul')
12865

129-
const position = await nav.evaluate((el) => {
130-
return window.getComputedStyle(el).position
131-
})
66+
const navRole = await nav.getAttribute('role')
67+
const navAriaLabel = await nav.getAttribute('aria-label')
68+
const menuAriaLabel = await navMenu.getAttribute('aria-label')
13269

133-
expect(['fixed', 'sticky']).toContain(position)
70+
expect(navRole).toBe('navigation')
71+
expect(navAriaLabel).toBe('Main')
72+
expect(menuAriaLabel).toBe('main navigation')
13473
})
13574

136-
test.skip('@wip nav has proper z-index for overlays', async ({ page }) => {
137-
// Expected: Nav should appear above page content
138-
const nav = page.locator('nav')
139-
140-
const zIndex = await nav.evaluate((el) => {
141-
return parseInt(window.getComputedStyle(el).zIndex || '0')
142-
})
143-
144-
expect(zIndex).toBeGreaterThan(0)
75+
test.skip('@wip hovering parent item shows submenu', async ({ page: _page }) => {
76+
// Navigation doesn't have submenus - this test is not applicable
77+
test.skip()
14578
})
14679

147-
test.skip('@wip submenu keyboard navigation works', async ({ page }) => {
148-
// Expected: Can navigate submenu with keyboard
149-
150-
// Tab to services link
151-
await page.keyboard.press('Tab')
152-
await page.keyboard.press('Tab') // May need multiple tabs
80+
test.skip('@wip submenu hides when mouse leaves', async ({ page: _page }) => {
81+
// Navigation doesn't have submenus - this test is not applicable
82+
test.skip()
83+
})
15384

154-
// Press Enter to open submenu
155-
await page.keyboard.press('Enter')
156-
await page.waitForTimeout(300)
85+
test.skip('@wip can click submenu items', async ({ page: _page }) => {
86+
// Navigation doesn't have submenus - this test is not applicable
87+
test.skip()
88+
})
15789

158-
const submenu = page.locator('[data-submenu]').first()
159-
await expect(submenu).toBeVisible()
90+
test('@ready navigation links have hover states', async ({ page }) => {
91+
const nav = page.locator('nav#main-nav')
92+
const firstLink = nav.locator('a').first()
16093

161-
// Arrow down to submenu item
162-
await page.keyboard.press('ArrowDown')
94+
// Hover and check that hover styles apply
95+
await firstLink.hover()
16396

164-
const focusedElement = await page.evaluate(() => {
165-
return document.activeElement?.tagName
97+
const hasHoverTransition = await firstLink.evaluate((el) => {
98+
const parent = el.parentElement
99+
return parent?.classList.contains('main-nav-item')
166100
})
167101

168-
expect(focusedElement).toBe('A')
102+
expect(hasHoverTransition).toBe(true)
169103
})
170104

171-
test.skip('@wip nav works on tablet breakpoint', async ({ page }) => {
172-
// Expected: Nav should adapt appropriately for tablet
173-
await page.setViewportSize(VIEWPORTS.tablet)
174-
await page.goto(TEST_URLS.home)
175-
176-
const nav = page.locator('nav')
177-
await expect(nav).toBeVisible()
178-
179-
// Check if desktop or mobile nav is shown
180-
const isDesktopNav = await page.locator('nav[data-nav-desktop]').isVisible()
181-
const isMobileNav = await page.locator('[data-nav-toggle]').isVisible()
182-
183-
// One should be visible
184-
expect(isDesktopNav || isMobileNav).toBe(true)
105+
test.skip('@wip navigation is sticky on scroll', async ({ page: _page }) => {
106+
// Header/navigation stickiness would be tested in header tests
107+
test.skip()
185108
})
186109

187-
test.skip('@wip nav logo links to homepage', async ({ page }) => {
188-
// Expected: Clicking logo should return to home
189-
await page.goto(TEST_URLS.about)
190-
191-
const logo = page.locator('nav a[href="/"]').first()
192-
await logo.click()
193-
await page.waitForLoadState('networkidle')
194-
195-
expect(page.url()).toBe(TEST_URLS.home)
110+
test.skip('@wip nav has proper z-index for overlays', async ({ page: _page }) => {
111+
// Z-index testing not critical for functional tests
112+
test.skip()
196113
})
197114

198-
test.skip('@wip nav has skip to content link', async ({ page }) => {
199-
// Expected: Should have accessible skip link
200-
await page.goto(TEST_URLS.home)
115+
test.skip('@wip submenu keyboard navigation works', async ({ page: _page }) => {
116+
// No submenus in this navigation
117+
test.skip()
118+
})
201119

202-
// Tab to first element (should be skip link)
203-
await page.keyboard.press('Tab')
120+
test.skip('@wip nav works on tablet breakpoint', async ({ page: _page }) => {
121+
// Responsive behavior tested in mobile tests
122+
test.skip()
123+
})
204124

205-
const skipLink = page.locator('a[href="#main-content"]')
206-
const isVisible = await skipLink.isVisible()
125+
test.skip('@wip nav logo links to homepage', async ({ page: _page }) => {
126+
// Logo is in Header component, not Navigation
127+
test.skip()
128+
})
207129

208-
// Skip link may be visually hidden until focused
209-
expect(isVisible).toBe(true)
130+
test.skip('@wip nav has skip to content link', async ({ page: _page }) => {
131+
// Skip link is in Header component
132+
test.skip()
210133
})
211134
})

0 commit comments

Comments
 (0)