1+ import { test , expect } from '@playwright/test' ;
2+
3+ test . describe ( 'Portals Dialog Accessibility' , ( ) => {
4+ test . beforeEach ( async ( { page } ) => {
5+ // Navigate to portals page with test site
6+ await page . goto ( '/portals?site=https://webboard.app' ) ;
7+ } ) ;
8+
9+ test ( 'back button should be keyboard accessible' , async ( { page } ) => {
10+ // Wait for the publish pane to be available
11+ await page . waitForSelector ( 'publish-pane' ) ;
12+
13+ // Open the dialog by clicking Generate Package button
14+ const generateButton = page . locator ( 'button:has-text("Generate Package")' ) . first ( ) ;
15+ await generateButton . click ( ) ;
16+
17+ // Wait for dialog to open and form to show
18+ await page . waitForSelector ( '#pp-form-header' , { state : 'visible' } ) ;
19+
20+ // Find the back button in the form header
21+ const backButton = page . locator ( '#pp-form-header > button' ) . first ( ) ;
22+
23+ // Verify button is visible and accessible
24+ await expect ( backButton ) . toBeVisible ( ) ;
25+
26+ // Test keyboard navigation - tab to the button
27+ await backButton . focus ( ) ;
28+
29+ // Verify button has focus
30+ await expect ( backButton ) . toBeFocused ( ) ;
31+
32+ // Test that pressing Enter activates the button
33+ await backButton . press ( 'Enter' ) ;
34+
35+ // Verify that we're back to the cards view (form header should not be visible)
36+ await expect ( page . locator ( '#pp-form-header' ) ) . not . toBeVisible ( ) ;
37+ await expect ( page . locator ( '#store-cards' ) ) . toBeVisible ( ) ;
38+ } ) ;
39+
40+ test ( 'back button should have proper focus styling' , async ( { page } ) => {
41+ // Navigate to portals page
42+ await page . goto ( '/portals?site=https://webboard.app' ) ;
43+
44+ // Wait for the publish pane
45+ await page . waitForSelector ( 'publish-pane' ) ;
46+
47+ // Open dialog
48+ const generateButton = page . locator ( 'button:has-text("Generate Package")' ) . first ( ) ;
49+ await generateButton . click ( ) ;
50+
51+ // Wait for form to show
52+ await page . waitForSelector ( '#pp-form-header' , { state : 'visible' } ) ;
53+
54+ // Focus the back button
55+ const backButton = page . locator ( '#pp-form-header > button' ) . first ( ) ;
56+ await backButton . focus ( ) ;
57+
58+ // Check that focus styles are applied
59+ const outlineStyle = await backButton . evaluate ( ( el ) => {
60+ return window . getComputedStyle ( el ) . outline ;
61+ } ) ;
62+
63+ // Verify that the button has an outline when focused
64+ expect ( outlineStyle ) . toContain ( 'solid' ) ;
65+ } ) ;
66+ } ) ;
0 commit comments