diff --git a/src/client/components/Choices/TextField.tsx b/src/client/components/Choices/TextField.tsx index f748d4c..edc38e0 100644 --- a/src/client/components/Choices/TextField.tsx +++ b/src/client/components/Choices/TextField.tsx @@ -17,6 +17,7 @@ const Text = ({ control, question, defaultValue }: InputProps) => { render={({ field: { onChange } }) => ( { +test.beforeEach(async ({ page }) => { await page.goto('/') +}) - // Expect a title "to contain" a substring. +test('has title', async ({ page }) => { await expect(page).toHaveTitle(/Riksutin/) }) + +test('has the first question', async ({ page }) => { + await expect(page.getByText('Ilmoittajan nimi')).toBeVisible() + + const nameInput = page.getByTestId('question-1').getByRole('textbox') + + await nameInput.click() + await nameInput.fill('') + + await expect(nameInput).toHaveValue('') +}) + +test('shows answers after submitting', async ({ page }) => { + const nameInput = page.getByTestId('question-1').getByRole('textbox') + + await nameInput.click() + await nameInput.fill('Testi Testinen') + + await page.getByRole('button', { name: 'Valinnat tehty' }).click() + + await expect(page.getByText('Yhteenveto valinnoistasi')).toBeVisible() + await expect(page.getByText('Ilmoittajan nimi: Testi Testinen')).toBeVisible() +})