import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import puppeteer, { Browser, Page } from 'puppeteer'; describe('E2E Navigation & Content', () => { let browser: Browser; let page: Page; const BASE_URL = 'http://etib.localhost'; beforeAll(async () => { browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); page = await browser.newPage(); // Set viewport for a desktop view await page.setViewport({ width: 1280, height: 800 }); }); afterAll(async () => { if (browser) { await browser.close(); } }); it('should load the homepage and display core content in German (default)', async () => { const response = await page.goto(`${BASE_URL}/de`, { waitUntil: 'networkidle0' }); expect(response?.status()).toBe(200); // Check if a standard element like h1 is present const h1Text = await page.evaluate(() => document.querySelector('h1')?.textContent); expect(h1Text).toBeTruthy(); // Check for specific German text that should be on the homepage // e.g., "Kompetenzen" or a known Hero text const bodyText = await page.evaluate(() => document.body.innerText); expect(bodyText).toContain('Kontakt'); }); it('should switch language to English and display translated content', async () => { await page.goto(`${BASE_URL}/en`, { waitUntil: 'networkidle0' }); // Wait for language to change const htmlLang = await page.evaluate(() => document.documentElement.lang); expect(htmlLang).toBe('en'); // Check for specific English text const bodyText = await page.evaluate(() => document.body.innerText); // Assuming "Unternehmen" translates to "COMPANY" expect(bodyText).toContain('COMPANY'); }); it('should load the contact page and verify the map/form presence', async () => { const response = await page.goto(`${BASE_URL}/de/contact`, { waitUntil: 'networkidle0' }); expect(response?.status()).toBe(200); // Verify that the page contains contact-specific elements const bodyText = await page.evaluate(() => document.body.innerText); // E-TIB specific contact info expect(bodyText).toContain('E-TIB'); // Check if form is present const formExists = await page.evaluate(() => document.querySelector('form') !== null); expect(formExists).toBe(true); }); });