Files
klz-cables.com/tests/pages.test.ts
Marc Mintel 6e2a959972
Some checks failed
CI - Lint, Typecheck & Test / quality-assurance (pull_request) Failing after 6s
Build & Deploy / 🔍 Prepare (push) Successful in 14s
Build & Deploy / 🧪 QA (push) Failing after 1m31s
Build & Deploy / 🏗️ Build (push) Has been skipped
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 4s
fix: resolve contact form and page slug translation mismatch causing E2E test failures
2026-06-10 11:47:42 +02:00

75 lines
2.7 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { getPageBySlug } from '../lib/pages';
import { getPostBySlug, getPostSlugs } from '../lib/blog';
describe('getPageBySlug translation routing', () => {
it('should resolve standard page in German', async () => {
const page = await getPageBySlug('impressum', 'de');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Impressum');
});
it('should resolve translated slug "legal-notice" for English', async () => {
const page = await getPageBySlug('legal-notice', 'en');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Impressum');
});
it('should resolve translated slug "privacy-policy" for English', async () => {
const page = await getPageBySlug('privacy-policy', 'en');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Datenschutzerklärung');
});
it('should resolve translated slug "kontakt" for German', async () => {
const page = await getPageBySlug('kontakt', 'de');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Kontakt');
});
it('should resolve translated slug "contact" for English', async () => {
const page = await getPageBySlug('contact', 'en');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Kontakt');
});
it('should resolve translated slug "produkte" for German', async () => {
const page = await getPageBySlug('produkte', 'de');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Produkte');
});
it('should resolve translated slug "products" for English', async () => {
const page = await getPageBySlug('products', 'en');
expect(page).not.toBeNull();
expect(page?.frontmatter.title).toBe('Produkte');
});
it('should return null for non-existent slugs', async () => {
const page = await getPageBySlug('does-not-exist', 'de');
expect(page).toBeNull();
});
});
describe('getPostBySlug and getPostSlugs translation routing', () => {
it('should resolve post by English slug', async () => {
const post = await getPostBySlug(
'focus-on-wind-farm-construction-three-typical-cable-challenges',
'en',
);
expect(post).not.toBeNull();
expect(post?.frontmatter.title).toBe(
'Windparkbau im Fokus: drei typische Kabelherausforderungen',
);
});
it('should return correct localized post slugs', async () => {
const slugs = await getPostSlugs(
'focus-on-wind-farm-construction-three-typical-cable-challenges',
'en',
);
expect(slugs.de).toBe('windparkbau-im-fokus-drei-typische-kabelherausforderungen');
expect(slugs.en).toBe('focus-on-wind-farm-construction-three-typical-cable-challenges');
});
});