Skip to content

Commit eea9a77

Browse files
authored
Merge pull request #413 from webstackdev/feature/sitemap
Refactors to e2e test cases
2 parents 3a22709 + c1bccfe commit eea9a77

30 files changed

Lines changed: 1245 additions & 493 deletions

.github/instructions/general.instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ applyTo: "**"
3535
- JavaScript loading warnings from happy-dom are silenced in vitest.setup.ts for clean test output.
3636
- A working example test using the Container API is available at /home/kevin/Repos/Webstack Builders/Corporate Website/astro.webstackbuilders.com/src/components/Test/container.spec.ts
3737
- **NEVER hard-code content slugs in e2e tests** (e.g., `/articles/typescript-best-practices`, `/services/web-development`). Content can be deleted or renamed. Always dynamically fetch the first available item from listing pages (articles, services, case-studies, etc.) and navigate to it. This prevents test breakage when content changes.
38+
- **Playwright E2E Tests**: Set `DEBUG=1` environment variable to prevent the dev server from being launched by the Playwright test runner. This is useful when you want to run tests against an already running dev server.
3839

3940
# Personality
4041
- Do not apologize

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dango",
2323
"dbtable",
2424
"Dynatrace",
25+
"ecommerce",
2526
"Favicons",
2627
"Fedi",
2728
"Fedibird",

TODO.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ https://github.com/modernweb-dev/rocket/tree/main/packages/check-html-links
3636

3737
"Scaling/zooming animations are problematic for accessibility, as they are a common trigger for certain types of migraine. If you need to include such animations on your website, you should provide a control to allow users to turn off animations, preferably site-wide. Also, consider making use of the prefers-reduced-motion media feature — use it to write a media query that will turn off animations if the user has reduced animation specified in their system preferences. "
3838

39+
## Fix offline page
40+
41+
- It should look like any other page, but have interactivity like navigation and other links disabled.
42+
- The test cases should check for if they're on the offline page, and return passed for an inverse. Like the smoke test that makes sure navigation is available, it would return true if navigation is present but disabled in the same test case.
43+
3944
## @TODO: Handle `@media (prefers-reduced-motion: reduce)`
4045

4146
Stop the Hero Greensocks animation when `@media (prefers-reduced-motion: reduce)`, using `window.mediaQuery()`. Handle user preference for reduced motion on animations, doing this also with a listener like for browser theme preference
@@ -573,3 +578,27 @@ Repo is in root of Corporate Websites
573578
* [**typographic-permille**][typographic-permille]
574579

575580
Micro module to replace `%o` with `` and optionally replace the preceding space.
581+
582+
## Tests
583+
584+
```typescript
585+
test('Critical Paths @smoke', async ({ context, page, allPaths }) => {
586+
for (const path of allPaths) {
587+
await test.step('@ready all main pages are accessible', async () => {
588+
await page.goto(path)
589+
await expect(page.locator('main')).toBeVisible()
590+
})
591+
592+
await test.step('@ready cookie consent banner appears', async () => {
593+
// Clear consent cookies to force banner to appear
594+
await clearConsentCookies(context)
595+
596+
await page.goto(path)
597+
await page.waitForLoadState('networkidle')
598+
599+
// Cookie modal should be visible
600+
await expect(page.locator('#cookie-modal-id')).toBeVisible()
601+
})
602+
}
603+
})
604+
```

astro.config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import mdx from '@astrojs/mdx'
2-
import preact from "@astrojs/preact"
2+
import preact from '@astrojs/preact'
3+
import sitemap from '@astrojs/sitemap'
34
import vercelStatic from '@astrojs/vercel'
45
import sentry from "@sentry/astro"
56
import tailwindcss from '@tailwindcss/vite'
@@ -14,6 +15,7 @@ import {
1415
vercelConfig,
1516
} from './src/lib/config'
1617
import { callToActionValidator } from './src/integrations/CtaValidator/call-to-action-validator'
18+
import { serializeSitemapItem, writePagesJson } from './src/lib/config/sitemap-serialize'
1719

1820
// Type guard for required environment variables (only in CI)
1921
const IS_CI = process.env['CI'] === 'true'
@@ -42,6 +44,19 @@ export default defineConfig({
4244
org: "webstack-builders",
4345
authToken: SENTRY_AUTH_TOKEN,
4446
})] : []),
47+
sitemap({
48+
lastmod: new Date(),
49+
serialize: serializeSitemapItem,
50+
}),
51+
// Custom integration to write pages.json after build
52+
{
53+
name: 'pages-json-writer',
54+
hooks: {
55+
'astro:build:done': () => {
56+
writePagesJson()
57+
},
58+
},
59+
},
4560
],
4661
output: 'static',
4762
prefetch: true,

0 commit comments

Comments
 (0)