Skip to content

Commit f004f11

Browse files
committed
Fix unit test errors in Consent Banner
1 parent c5afcb5 commit f004f11

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

src/components/Consent/Banner/client/__tests__/index.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ describe('ConsentBannerElement', () => {
117117

118118
expect(window.document.activeElement).toBe(wrapper)
119119

120-
await new Promise<void>(resolve => {
121-
setTimeout(resolve, 0)
122-
})
123-
const allowBtn = window.document.querySelector(
124-
'.consent-modal__btn-allow'
120+
// Tab from the modal wrapper moves focus to the first focusable element.
121+
wrapper!.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Tab', bubbles: true }))
122+
123+
const closeBtn = window.document.querySelector(
124+
'.consent-modal__close-btn'
125125
) as HTMLButtonElement | null
126-
expect(allowBtn).not.toBeNull()
127-
expect(window.document.activeElement).toBe(allowBtn)
126+
expect(closeBtn).not.toBeNull()
127+
expect(window.document.activeElement).toBe(closeBtn)
128128
})
129129
})
130130

@@ -181,7 +181,7 @@ describe('ConsentBannerElement', () => {
181181
const navigateSpy = vi.spyOn(bannerCtor, 'navigateToUrl').mockImplementation(() => {})
182182

183183
try {
184-
customizeLink!.dispatchEvent(new window.MouseEvent('click', { bubbles: true }))
184+
customizeLink!.dispatchEvent(new window.MouseEvent('click', { bubbles: true, cancelable: true }))
185185

186186
expect(navigateSpy).toHaveBeenCalledTimes(1)
187187
expect(navigateSpy).toHaveBeenCalledWith(expect.stringContaining('/consent'))

src/components/Navigation/Menu.astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const activeMenuItem = (url: string) => {
2424
'w-full font-heading text-[0.85rem] uppercase tracking-[0.22em] text-primary',
2525
'lg:relative lg:text-[0.8rem] lg:tracking-[0.12em]',
2626
]}
27-
aria-label="main navigation"
2827
tabindex="-1"
2928
>
3029
{

0 commit comments

Comments
 (0)