CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
- Products collection (interim mirror of the PLATFM-14 catalogue contract): lifecycle status, product type, required whole-forint net price, yearly billing, service definition, per-product English gate - HostingPlans global: page copy, comparison labels, VAT rate (27%) - Gate: production shows only active plans, staging all but retired; with no showable plan the page is 404 and left out of the menu and the sitemap - /hu/tarhely-csomagok <-> /en/hosting-plans via PAGE_SLUGS (hreflang, language switcher, CTA page picker) - Seed migration 20260929_hosting_plans: mIT Start (14 900 Ft/yr, 5 mailboxes) and mIT Mid (23 900 Ft/yr) as drafts, English AI draft; idempotent - Production SEO suite expects at least 12 sitemap URLs; new SMOKE-10 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
75 lines
3.5 KiB
TypeScript
75 lines
3.5 KiB
TypeScript
import { expect, test, type APIRequestContext } from '@playwright/test'
|
|
|
|
/**
|
|
* MITHOME-127 — production launch SEO checks (run at go-live and after every
|
|
* production release): `BASE_URL=https://mozdit.hu npm run test:seo:production`.
|
|
*
|
|
* The site must be indexable, every sitemap URL must be final (200, no
|
|
* redirect), canonical/hreflang must point at those final URLs, and content +
|
|
* internal links must be in the server-rendered HTML (no JS needed).
|
|
* Host-level redirects (http→https, www→apex) are nginx's job (MITHOME-15):
|
|
* set SEO_CHECK_HOST_REDIRECTS=1 once the production domain is live.
|
|
*/
|
|
|
|
const text = async (request: APIRequestContext, path: string) => {
|
|
const response = await request.get(path, { maxRedirects: 0 })
|
|
expect(response.status(), `${path} status`).toBe(200)
|
|
return response.text()
|
|
}
|
|
|
|
const locs = (xml: string) => [...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map((m) => m[1])
|
|
const attr = (html: string, pattern: RegExp) => html.match(pattern)?.[1]
|
|
|
|
test('robots.txt allows crawling and points to the sitemap', async ({ request, baseURL }) => {
|
|
const robots = await text(request, '/robots.txt')
|
|
expect(robots).not.toMatch(/^Disallow:\s*\/\s*$/im)
|
|
expect(robots).toContain(`Sitemap: ${baseURL}/sitemap.xml`)
|
|
})
|
|
|
|
test('every sitemap URL is final, indexable and correctly annotated', async ({ request, baseURL }) => {
|
|
const urls = locs(await text(request, '/sitemap.xml'))
|
|
// MITHOME-130: 12 core URLs, +2 once a hosting plan is active.
|
|
expect(urls.length).toBeGreaterThanOrEqual(12)
|
|
|
|
for (const url of urls) {
|
|
expect(url.startsWith(`${baseURL}/`), `${url} is on ${baseURL}`).toBe(true)
|
|
const html = await text(request, url)
|
|
expect(html, `${url} has no noindex`).not.toMatch(/<meta[^>]*name="robots"[^>]*noindex/i)
|
|
expect(attr(html, /<link rel="canonical" href="([^"]+)"/), `${url} canonical`).toBe(url)
|
|
for (const lang of ['hu', 'en', 'x-default']) {
|
|
const alternate = attr(html, new RegExp(`<link rel="alternate" hrefLang="${lang}" href="([^"]+)"`))
|
|
expect(urls, `${url} hreflang ${lang} → ${alternate}`).toContain(alternate)
|
|
}
|
|
}
|
|
})
|
|
|
|
test('content and internal links are in the server-rendered HTML', async ({ request }) => {
|
|
const html = await text(request, '/hu')
|
|
expect(html).toMatch(/<h1[^>]*>[^<]+/)
|
|
for (const path of ['/hu/rolunk', '/hu/szolgaltatasok', '/hu/kapcsolat', '/en']) {
|
|
expect(html, `link to ${path}`).toContain(`href="${path}"`)
|
|
}
|
|
})
|
|
|
|
test('the site root redirects to /hu in one step', async ({ request }) => {
|
|
const response = await request.get('/', { maxRedirects: 0 })
|
|
expect([301, 302, 307, 308]).toContain(response.status())
|
|
expect(new URL(response.headers()['location'], 'http://x').pathname).toBe('/hu')
|
|
})
|
|
|
|
test('unknown pages return a real 404', async ({ request }) => {
|
|
const response = await request.get('/hu/nincs-ilyen-oldal', { maxRedirects: 0 })
|
|
expect(response.status()).toBe(404)
|
|
})
|
|
|
|
test('host variants redirect to the canonical origin in one step', async ({ request, baseURL }) => {
|
|
test.skip(!process.env.SEO_CHECK_HOST_REDIRECTS, 'nginx host redirects are checked once the production domain is live (MITHOME-15)')
|
|
const canonical = new URL(baseURL!)
|
|
const variants = [`http://${canonical.host}/hu`, `https://www.${canonical.host}/hu`]
|
|
for (const variant of variants) {
|
|
const response = await request.get(variant, { maxRedirects: 0 })
|
|
expect([301, 308], `${variant} status`).toContain(response.status())
|
|
expect(response.headers()['location'], `${variant} target`).toBe(`${canonical.origin}/hu`)
|
|
}
|
|
})
|