test: add E2E tests for homepage vehicle lookup flow
- enters plate and sees vehicle info with CTA button: types HDO732, verifies Peugeot 107 1.0, 2011, Gul, Bensin appear, verifies Fortsatt till brevet link has correct href - shows not found for unknown plate (ZZZ999) - CTA navigates to compose when authenticated: logs in as test@bilhalsning.se, performs lookup, clicks CTA, verifies redirect to /compose?plate=HDO732
This commit is contained in:
parent
1b87e15a21
commit
be7775f680
1 changed files with 51 additions and 0 deletions
51
frontend/e2e/vehicle-lookup.spec.ts
Normal file
51
frontend/e2e/vehicle-lookup.spec.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import { test, expect } from '@playwright/test'
|
||||
|
||||
test.describe('Vehicle lookup', () => {
|
||||
test('enters plate and sees vehicle info with CTA button', async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto('/')
|
||||
|
||||
await page.getByPlaceholder('ABC 123').fill('HDO732')
|
||||
await page.getByPlaceholder('ABC 123').press('Enter')
|
||||
|
||||
await expect(page.getByText(/Peugeot 107 1\.0/)).toBeVisible({
|
||||
timeout: 15_000,
|
||||
})
|
||||
await expect(page.getByText('2011').first()).toBeVisible()
|
||||
await expect(page.getByText(/Gul/)).toBeVisible()
|
||||
await expect(page.getByText(/Bensin/)).toBeVisible()
|
||||
|
||||
const cta = page.getByRole('link', { name: 'Fortsätt till brevet' })
|
||||
await expect(cta).toBeVisible()
|
||||
await expect(cta).toHaveAttribute('href', '/compose?plate=HDO732')
|
||||
})
|
||||
|
||||
test('shows not found for unknown plate', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
|
||||
await page.getByPlaceholder('ABC 123').fill('ZZZ999')
|
||||
await page.getByPlaceholder('ABC 123').press('Enter')
|
||||
|
||||
await expect(
|
||||
page.getByText('Inget fordon hittades'),
|
||||
).toBeVisible({ timeout: 15_000 })
|
||||
})
|
||||
|
||||
test('CTA navigates to compose when authenticated', async ({ page }) => {
|
||||
await page.goto('/logga-in')
|
||||
await page.getByLabel('E-postadress').fill('test@bilhalsning.se')
|
||||
await page.getByLabel('Lösenord').fill('test1234')
|
||||
await page.getByRole('button', { name: 'Logga in' }).click()
|
||||
await page.waitForURL('/')
|
||||
|
||||
await page.getByPlaceholder('ABC 123').fill('HDO732')
|
||||
await page.getByPlaceholder('ABC 123').press('Enter')
|
||||
|
||||
const cta = page.getByRole('link', { name: 'Fortsätt till brevet' })
|
||||
await expect(cta).toBeVisible({ timeout: 15_000 })
|
||||
await cta.click()
|
||||
|
||||
await expect(page).toHaveURL('/compose?plate=HDO732')
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue