import { test, expect } from '@playwright/test';
import { fillContactForm, mockShopApi } from './helpers';

test.beforeEach(async ({ page }) => {
  await mockShopApi(page);
});

test('home hero and contact form submit', async ({ page }) => {
  await page.goto('/');

  await expect(page.getByRole('heading', { name: /Tervetuloa/i })).toBeVisible();

  await page.getByRole('link', { name: /Ota yhteyttä/i }).click();
  await expect(page).toHaveURL(/\/yhteystiedot/);

  await fillContactForm(page);
  await page.getByRole('button', { name: /Lähetä viesti/i }).click();

  await expect(page.getByText('Viesti lähetetty!')).toBeVisible();
});
