Files
e-tib.com/tests/navigation.e2e.test.ts
Marc Mintel b13f628b55 feat: complete MDX migration, stabilize environment & verify via E2E tests
Former-commit-id: ec3e64156a2e182535cbdcf0d975cd54603a517d
2026-05-03 18:46:41 +02:00

90 lines
3.9 KiB
TypeScript

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import puppeteer, { Browser, Page } from 'puppeteer';
describe('E2E Navigation & Content (MDX Architecture)', () => {
let browser: Browser;
let page: Page;
const BASE_URL = 'http://localhost:3010';
beforeAll(async () => {
browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });
});
afterAll(async () => {
if (browser) {
await browser.close();
}
});
it('should load the homepage in German', async () => {
const response = await page.goto(`${BASE_URL}/de`, { waitUntil: 'networkidle2' });
expect(response?.status()).toBe(200);
const bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('DIE EXPERTEN FÜR KABELTIEFBAU');
});
it('should load the "Über uns" page and show MDX content', async () => {
await page.goto(`${BASE_URL}/de/ueber-uns`, { waitUntil: 'networkidle2' });
const bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Die E-TIB Gruppe steht für höchste Qualität');
expect(bodyText).toContain('E-TIB Bohrtechnik GmbH');
});
it('should load the competencies page in English', async () => {
await page.goto(`${BASE_URL}/en/competencies`, { waitUntil: 'networkidle2' });
const bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Drilling Technology (HDD)');
expect(bodyText).toContain('horizontal directional drilling');
});
it('should load the careers page and show job listings', async () => {
await page.goto(`${BASE_URL}/de/karriere`, { waitUntil: 'networkidle2' });
const bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Karriere bei E-TIB');
expect(bodyText).toContain('Tiefbaufacharbeiter');
});
it('should verify the imprint, privacy and terms pages (MDX)', async () => {
// Imprint
await page.goto(`${BASE_URL}/de/impressum`, { waitUntil: 'networkidle2' });
let bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Angaben gemäß § 5 TMG');
expect(bodyText).toContain('Danny Joseph');
// Privacy
await page.goto(`${BASE_URL}/en/privacy-policy`, { waitUntil: 'networkidle2' });
bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Privacy at a Glance');
expect(bodyText).toContain('Umami Analytics');
// Terms (AGB)
await page.goto(`${BASE_URL}/de/agb`, { waitUntil: 'networkidle2' });
bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Allgemeine Geschäftsbedingungen');
expect(bodyText).toContain('Geltungsbereich');
});
it('should verify blog listing and post loading', async () => {
await page.goto(`${BASE_URL}/de/blog`, { waitUntil: 'networkidle2', timeout: 60000 });
let bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Moderne Verfahren im Kabeltiefbau');
// Click on the first article (if found) or navigate directly
await page.goto(`${BASE_URL}/de/blog/moderne-verfahren-kabeltiefbau`, { waitUntil: 'networkidle2', timeout: 60000 });
bodyText = await page.evaluate(() => document.body.innerText);
expect(bodyText).toContain('Horizontalspülbohrung (HDD)');
});
it('should handle non-existent routes with a 404', async () => {
const response = await page.goto(`${BASE_URL}/de/irgendwas-falsches`, { waitUntil: 'networkidle2' });
expect(response?.status()).toBe(404);
});
});