Feature/implement e2e tests with mock third party services - #490
webstackdev merged 32 commits into
Conversation
…rver test harnesses
… server test harnesses
…server test harnesses
… checkbox E2E test with container mocks
… container mocks for third party services
…ainer mocks for third party services
…ect changes made while implementing E2E tests
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR implements comprehensive E2E testing infrastructure with mocked third-party services (Resend, Supabase) to enable full-stack integration testing. The implementation includes WireMock-based service mocks, fetch interception utilities, and extensive test coverage for newsletter workflows, contact forms, consent management, and cron jobs.
Key Changes:
- Added WireMock client and fetch override utilities for mocking external services during E2E tests
- Implemented full E2E test suites for newsletter double opt-in, contact forms, consent preferences, cron endpoints, and Supabase RLS policies
- Enhanced API endpoints with mock service support via
x-e2e-mocksheader and Supabase fallback mode
Reviewed changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/specs/15-cron/cron.spec.ts | New E2E tests for cron cleanup and ping endpoints with Supabase integration |
| test/e2e/specs/08-api/*.spec.ts | Comprehensive API integration tests for Supabase RLS, newsletter, and contact endpoints |
| test/e2e/specs/03-forms/*.spec.ts | Form E2E tests with fetch interception and mock service validation |
| test/e2e/specs/04-components/consentPreferences.spec.ts | Full-stack consent flow tests with Supabase verification |
| test/e2e/helpers/mockServices.ts | WireMock client for managing mock service requests and assertions |
| test/e2e/helpers/fetchOverride.ts | Fetch interception utilities for spying, mocking, and header injection |
| test/containers/supabase/*.sh | Supabase container management and logging scripts |
| src/pages/api/newsletter/*.ts | E2E mocks support and Resend mock integration |
| src/pages/api/contact/index.ts | Mock Resend support for contact form testing |
| src/pages/api/gdpr/consent.ts | Supabase fallback mode for E2E tests |
| src/pages/api/_environment/environmentApi.ts | Helper functions for mock service URLs and fallback detection |
| package.json | Added test:e2e:full script with E2E_MOCKS environment variable |
| import { | ||
| getCronSecret, | ||
| getSuprabaseApiUrl, | ||
| getSuprabaseApiServiceRoleKey, |
There was a problem hiding this comment.
Typo in function name: "getSuprabaseApiServiceRoleKey" should be "getSupabaseApiServiceRoleKey" to match the correct spelling of "Supabase".
| } from '@pages/api/_environment/environmentApi' | ||
|
|
||
| const CRON_SECRET = getCronSecret() | ||
| const SUPABASE_URL = getSuprabaseApiUrl() |
There was a problem hiding this comment.
The variable name uses incorrect spelling: "SUPABASE_URL" is assigned from "getSuprabaseApiUrl()" which contains a typo. Once the function name is corrected to "getSupabaseApiUrl", this will be resolved.
|
|
||
| const CRON_SECRET = getCronSecret() | ||
| const SUPABASE_URL = getSuprabaseApiUrl() | ||
| const SUPABASE_SERVICE_ROLE_KEY = getSuprabaseApiServiceRoleKey() |
There was a problem hiding this comment.
The variable name uses incorrect spelling: "SUPABASE_SERVICE_ROLE_KEY" is assigned from "getSuprabaseApiServiceRoleKey()" which contains a typo. Once the function name is corrected to "getSupabaseApiServiceRoleKey", this will be resolved.
| */ | ||
| import { | ||
| getCronSecret, | ||
| getSuprabaseApiUrl, |
There was a problem hiding this comment.
Typo in function name: "getSuprabaseApiUrl" should be "getSupabaseApiUrl" to match the correct spelling of "Supabase".
… so dynamic navigations hit the real pages instead of the offline fallback.
…Page.ts so this page object flips
…low, fix lint errors in e2e test files
…) call in newsletter-api.spec.ts
…d logs between tests, so concurrent suites keep their evidence intact
…rt animation-frame bursts with the new helper, footer.spec.ts switches to waitForPageLoad() + waitForURL('**/privacy'), so the assertion runs after Astro’s client-side navigation settles, internal privacy/consent links now honor trailingSlash: 'never', updated anchors in index.astro, GDPR checkbox defaults in index.astro, the confirmation copy in [token].astro, and the canonical path metadata in index.astro and index.astro, specs that relied on /privacy/ were aligned with the canonical slug (package-release.spec.ts, privacy-policy-version.spec.ts) so they no longer trigger the trailing-slash 404 banner.
… the listener now installs only once, records status/method/url for each 4xx response, and exposes reset404Errors() so each navigation starts from a clean slate, reworked the @ready main pages have no 404 errors coverage in critical-paths.spec.ts to enable the listener once, reset errors before every goto, and then assert. The loop no longer keeps stale entries from prior navigations or spins up redundant listeners, so the smoke check now exercises exactly one listener per Playwright page.
…ttenly on webkit spinner wait, added state-based selector instead of time-based in waitForSpinnerLoadingState() of NewsletterPage POM
…s by validating/regenerating DataSubjectId inside consent
…icker rehydration
Description
Add a container workflow to E2E tests that mocks third-party services, and implement tests that need the infrastructure
Type of Change