Skip to content

Commit 4f548e2

Browse files
committed
DC-207 Add: Pa11y runs on CI
1 parent 80436d2 commit 4f548e2

4 files changed

Lines changed: 53 additions & 9 deletions

File tree

.github/workflows/playwright-e2e.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@ jobs:
7878
- name: Install Playwright browsers
7979
run: cd src/SEBT.Portal.Web && pnpm exec playwright install --with-deps chromium
8080

81-
- name: Run Playwright tests
81+
- name: Run Pa11y and Playwright E2E tests
8282
env:
8383
CI: true
84+
SKIP_WEB_SERVER: "1"
8485
STATE: dc
8586
NEXT_PUBLIC_STATE: dc
8687
ASPNETCORE_ENVIRONMENT: Development
@@ -89,7 +90,18 @@ jobs:
8990
IdentifierHasher__SecretKey: "ci-e2e-identifier-hasher-key-32chars"
9091
Oidc__CompleteLoginSigningKey: "ci-e2e-oidc-signing-key-at-least-32-chars"
9192
UseMockHouseholdData: "true"
92-
run: pnpm ci:test:e2e:ci
93+
run: |
94+
pnpm dev &
95+
echo "Waiting for server at http://localhost:3000..."
96+
for i in $(seq 1 90); do
97+
curl -sf http://localhost:3000 > /dev/null && echo "Server ready" && break
98+
sleep 2
99+
done
100+
curl -sf http://localhost:3000 > /dev/null || (echo "Server failed to start" && exit 1)
101+
echo "Running Pa11y accessibility tests..."
102+
cd src/SEBT.Portal.Web && pnpm test:a11y
103+
echo "Running Playwright E2E tests..."
104+
cd ../.. && pnpm ci:test:e2e:ci
93105
94106
- name: Upload Playwright report
95107
uses: actions/upload-artifact@v4

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"ci:test": "./scripts/ci/test-backend.sh && ./scripts/ci/test-frontend.sh",
1717
"ci:test:e2e": "cd src/SEBT.Portal.Web && pnpm test:e2e",
1818
"ci:test:e2e:ci": "cd src/SEBT.Portal.Web && pnpm exec playwright test --project=chromium",
19+
"ci:test:a11y": "cd src/SEBT.Portal.Web && pnpm test:a11y",
1920
"ci:test:frontend": "./scripts/ci/test-frontend.sh",
2021
"ci:test:backend": "./scripts/ci/test-backend.sh",
2122
"ci:list": "./act-test.sh list",

src/SEBT.Portal.Web/e2e/example.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ test.describe('Homepage', () => {
99
test('should load and display the homepage', async ({ page }) => {
1010
await page.goto('/')
1111

12-
// Check that the page loaded
12+
// The homepage currently redirects to /login
13+
await expect(page).toHaveURL(/\/login\/?$/)
14+
15+
// Check that metadata loaded (state-based title)
1316
await expect(page).toHaveTitle(/SUN Bucks/i)
1417

18+
const continueButton = page.getByRole('button', { name: /continue/i })
19+
await expect(continueButton).toBeVisible()
20+
1521
// Check for USWDS JavaScript initialization
1622
const html = page.locator('html')
1723
await expect(html).not.toHaveClass(/usa-js-loading/, { timeout: 10000 })
@@ -33,4 +39,23 @@ test.describe('Homepage', () => {
3339
const main = page.locator('main, [role="main"]')
3440
await expect(main).toBeVisible()
3541
})
42+
43+
test('switches language to Spanish and shows translated UI', async ({ page }) => {
44+
await page.goto('/login')
45+
46+
// Initially loads in English
47+
await expect(page.getByRole('button', { name: 'Continue' })).toBeVisible()
48+
49+
// Switch to Spanish (handles both desktop + mobile language selector variants)
50+
const desktopSelector = page.locator('.usa-language__desktop')
51+
if (await desktopSelector.isVisible()) {
52+
await page.locator('.usa-language__desktop button[lang="es"]').click()
53+
} else {
54+
await page.locator('button[aria-controls="language-options"]').click()
55+
await page.locator('button[role="menuitem"][lang="es"]').click()
56+
}
57+
58+
// Assert at least one string is translated
59+
await expect(page.getByRole('button', { name: 'Continuar' })).toBeVisible()
60+
})
3661
})

src/SEBT.Portal.Web/playwright.config.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
77
/**
88
* Playwright E2E Testing Configuration
99
* Cross-browser testing with mobile viewport support
10+
* Set SKIP_WEB_SERVER=1 in CI when the server is already running (for Pa11y)
1011
*/
1112
export default defineConfig({
1213
testDir: './e2e',
@@ -45,10 +46,15 @@ export default defineConfig({
4546
}
4647
],
4748

48-
webServer: {
49-
command: 'pnpm dev',
50-
url: process.env.BASE_URL || 'http://localhost:3000',
51-
cwd: path.resolve(__dirname, '../..'),
52-
reuseExistingServer: !process.env.CI
53-
}
49+
// Omit webServer when SKIP_WEB_SERVER is set
50+
...(process.env.SKIP_WEB_SERVER
51+
? {}
52+
: {
53+
webServer: {
54+
command: 'pnpm dev',
55+
url: process.env.BASE_URL || 'http://localhost:3000',
56+
cwd: path.resolve(__dirname, '../..'),
57+
reuseExistingServer: !process.env.CI
58+
}
59+
})
5460
})

0 commit comments

Comments
 (0)