import { expect, test } from '@playwright/test'; import { SITE_CONTENT_DATA } from '../src/app/core/content/site-content'; import { SITE_CONFIG } from '../src/app/core/content/site-config'; import { pagePath } from './helpers'; test.describe('contact briefing', () => { test('builds a mailto href and issues no network request', async ({ page }) => { const extras: string[] = []; await page.route('**/*', (route) => { const url = route.request().url(); const resource = route.request().resourceType(); if (resource !== 'document' && !url.startsWith('data:') && !url.startsWith('blob:')) { extras.push(`${resource} ${url}`); } void route.continue(); }); await page.goto(pagePath('contact', 'de'), { waitUntil: 'networkidle' }); extras.length = 0; const emptySubmit = page.locator('.submit'); await expect(emptySubmit).toHaveAttribute('aria-disabled', 'true'); expect(await emptySubmit.getAttribute('href')).toBeNull(); await page.locator('#contact-name').fill('Ada'); await page.locator('#contact-email').fill('ada@example.com'); await page.locator('#contact-projectType').selectOption('software'); await page.locator('#contact-situation').fill('Need a migration.'); const href = await page.locator('a.submit').getAttribute('href'); expect(href).toMatch(/^mailto:/); expect(href).toContain(encodeURIComponent(SITE_CONTENT_DATA.de.contact.mailSubject)); expect(href).toContain(encodeURIComponent('Ada')); expect(href).toContain(SITE_CONFIG.contactEmail); expect(extras, extras.join('\n')).toEqual([]); }); });