- 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
51 lines
No EOL
1.7 KiB
TypeScript
51 lines
No EOL
1.7 KiB
TypeScript
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')
|
|
})
|
|
}) |