Skip to content

Commit

Permalink
Add a couple of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikao1998 committed Jan 4, 2024
1 parent 1118854 commit 621e8fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/client/components/Choices/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Text = ({ control, question, defaultValue }: InputProps) => {
render={({ field: { onChange } }) => (
<Box justifyContent="center">
<TextField
data-testid={`question-${question.id}`}
onChange={onChange}
fullWidth
InputProps={props ? props.attributes : {}}
Expand Down
28 changes: 26 additions & 2 deletions tests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import { test, expect } from '@playwright/test'

test('has title', async ({ page }) => {
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()
})

0 comments on commit 621e8fd

Please sign in to comment.