test(cms): Payload config + Local API tests, fix stale Docker tests (MITHOME-96)
Adds the two test categories the ticket asked for, replacing the old content-JSON-schema-only testing story now that Payload is the real source of truth: 1. src/payload-config.test.ts — fast, DB-free unit tests over the Collection/Global config objects themselves. WHY not importing payload.config.ts directly: it pulls in the real `payload` and `@payloadcms/db-mongodb` packages as values (not just types), which are ESM-only and Jest's default transformIgnorePatterns skips node_modules entirely — confirmed by trying it (`SyntaxError: Cannot use import statement outside a module` from payload's own dist). Individual collection/global files only ever `import type` from 'payload' (erased at compile time), so they're safely importable in isolation. Two of the assertions are deliberate regression guards for real bugs found earlier this session (MITHOME-121): Media.access.read must stay public, and Partners.logo must stay optional. 2. scripts/test-payload-local-api.ts (npm run test:payload) — exercises every src/lib/payload-content.ts getter plus a full create/findByID/delete cycle against a real, already-migrated MongoDB. WHY a plain node script instead of a Jest integration config: same ESM problem as above, and Payload's dependency graph is too broad to safely add to transformIgnorePatterns — this follows the same working `node --import tsx` pattern already used by migrate-content-to-payload.ts. Not wired into pre-deploy-tests.sh (needs a live, pre-migrated MongoDB, same reasoning as the removed CMS integration tests); run manually or before a release. 3. Fixed the pre-existing (Docker-stack-gated, so silently never caught) staleness in integration.test.ts and e2e-docker.test.ts: unprefixed routes (/rolunk) → locale-prefixed (/hu/rolunk), and Mongo assertions against the old site_config/contact_submissions collections → the real globals/legal-pages/partners/ contact-submissions collections Payload actually uses. Also fixed an unrelated stale error-message assertion for spam detection that never matched the route's real string. Verified: full gate green (tsc, lint, 63 unit tests — 13 new — build), and separately ran test:payload live against the dev MongoDB (8/8 passed, including the write/read/delete cycle actually hitting Mongo). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
a7e0530068
commit
e2b0c62628
@@ -1,6 +1,10 @@
|
||||
/**
|
||||
* End-to-End tests for the Docker environment
|
||||
* These tests verify the full application flow in the Docker stack
|
||||
*
|
||||
* MITHOME-96: routes are locale-prefixed (/hu/..., /en/...) since the
|
||||
* Payload CMS migration (MITHOME-91/114) — updated from the old unprefixed
|
||||
* paths.
|
||||
*/
|
||||
|
||||
describe('Docker E2E Tests', () => {
|
||||
@@ -27,24 +31,24 @@ describe('Docker E2E Tests', () => {
|
||||
expect(html).toContain('mozdIT Bt.')
|
||||
|
||||
// Test navigation links exist in homepage
|
||||
expect(html).toContain('href="/rolunk"')
|
||||
expect(html).toContain('href="/szolgaltatasok"')
|
||||
expect(html).toContain('href="/kapcsolat"')
|
||||
expect(html).toContain('href="/hu/rolunk"')
|
||||
expect(html).toContain('href="/hu/szolgaltatasok"')
|
||||
expect(html).toContain('href="/hu/kapcsolat"')
|
||||
|
||||
// Test about page
|
||||
response = await fetch(`${APP_URL}/rolunk`)
|
||||
response = await fetch(`${APP_URL}/hu/rolunk`)
|
||||
expect(response.status).toBe(200)
|
||||
html = await response.text()
|
||||
expect(html).toContain('Rólunk')
|
||||
|
||||
// Test services page
|
||||
response = await fetch(`${APP_URL}/szolgaltatasok`)
|
||||
response = await fetch(`${APP_URL}/hu/szolgaltatasok`)
|
||||
expect(response.status).toBe(200)
|
||||
html = await response.text()
|
||||
expect(html).toContain('Szolgáltatásaink')
|
||||
|
||||
// Test contact page
|
||||
response = await fetch(`${APP_URL}/kapcsolat`)
|
||||
response = await fetch(`${APP_URL}/hu/kapcsolat`)
|
||||
expect(response.status).toBe(200)
|
||||
html = await response.text()
|
||||
expect(html).toContain('Kapcsolat')
|
||||
@@ -210,9 +214,9 @@ describe('Docker E2E Tests', () => {
|
||||
|
||||
const pages = [
|
||||
{ url: '', title: 'mozdIT Bt.' },
|
||||
{ url: '/rolunk', title: 'Rólunk' },
|
||||
{ url: '/szolgaltatasok', title: 'Szolgáltatásaink' },
|
||||
{ url: '/kapcsolat', title: 'Kapcsolatfelvétel' }
|
||||
{ url: '/hu/rolunk', title: 'Rólunk' },
|
||||
{ url: '/hu/szolgaltatasok', title: 'Szolgáltatásaink' },
|
||||
{ url: '/hu/kapcsolat', title: 'Kapcsolat' }
|
||||
]
|
||||
|
||||
for (const page of pages) {
|
||||
|
||||
Reference in New Issue
Block a user