import { describe, it, expect, afterEach } from 'vitest';
import { cleanup, render } from 'vitest-browser-svelte';
import { page } from 'vitest/browser';
import EnrichDonePage from './+page.svelte';

afterEach(cleanup);

describe('enrich/done page', () => {
	it('renders the success heading', async () => {
		render(EnrichDonePage, { props: {} });

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

	it('renders the body message', async () => {
		render(EnrichDonePage, { props: {} });

		await expect.element(page.getByText('Alle Dokumente wurden bearbeitet.')).toBeVisible();
	});

	it('links the primary CTA to the home page', async () => {
		render(EnrichDonePage, { props: {} });

		await expect
			.element(page.getByRole('link', { name: /zurück zur übersicht/i }))
			.toHaveAttribute('href', '/');
	});

	it('links the secondary CTA back to /enrich', async () => {
		render(EnrichDonePage, { props: {} });

		await expect
			.element(page.getByRole('link', { name: /zurück zur liste/i }))
			.toHaveAttribute('href', '/enrich');
	});
});
