- Update HomePage specs: new headline, CTA class from btn--success to btn--primary - Update ComposePage specs: new button text, brand name in GDPR footer - Update PaymentRedirect specs: button text, class, and test payment note - Update TemplatePicker specs: remove emoji icon assertion - Update AdminDashboard specs: expand button selectors instead of row clicks - Update AppHeader specs: BilHälsning to Bilhej brand text - Update AboutPage specs: BilHälsning to Bilhej heading - Update App specs: new homepage headline text - Update OrdersPage specs: badge class renames - Update LoginPage specs: form name/action attribute tests - Update E2E compose specs: button text, GDPR footer brand name - Update E2E payment specs: button text and note selectors - Update E2E admin-dashboard specs: expand button and tracking label selectors - Update E2E header-auth specs: new test additions for admin visibility
121 lines
4.6 KiB
TypeScript
121 lines
4.6 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
|
|
test.describe('Compose flow', () => {
|
|
test('redirects unauthenticated user to login', async ({ page }) => {
|
|
await page.goto('/compose?plate=ABC123')
|
|
await expect(page).toHaveURL(/\/logga-in\?redirect=\/compose/)
|
|
await expect(page.getByRole('heading', { name: 'Logga in' })).toBeVisible()
|
|
})
|
|
|
|
test('shows error when no plate is provided', 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.goto('/compose')
|
|
|
|
await expect(page.getByText('Inget registreringsnummer valt')).toBeVisible()
|
|
})
|
|
|
|
test('displays plate and textarea', 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.goto('/compose?plate=ABC123')
|
|
|
|
await expect(
|
|
page.getByRole('heading', { name: 'Skriv ditt brev' }),
|
|
).toBeVisible()
|
|
await expect(page.getByText('ABC123').first()).toBeVisible()
|
|
await expect(page.getByLabel('Ditt meddelande')).toBeVisible()
|
|
})
|
|
|
|
test('submit button disabled when textarea is empty', 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.goto('/compose?plate=ABC123')
|
|
|
|
const button = page.getByRole('button', { name: 'Fortsätt till betalning' })
|
|
await expect(button).toBeDisabled()
|
|
})
|
|
|
|
test('can create order and navigate to payment page', 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.goto('/compose?plate=ABC123')
|
|
|
|
await page.getByLabel('Ditt meddelande').fill('Hej fin bil!')
|
|
const button = page.getByRole('button', { name: 'Fortsätt till betalning' })
|
|
await expect(button).toBeEnabled()
|
|
await button.click()
|
|
|
|
await expect(page).toHaveURL(/\/betalning\//)
|
|
await expect(page.getByRole('heading', { name: 'Betalning' })).toBeVisible()
|
|
await expect(page.getByText('49 kr')).toBeVisible()
|
|
})
|
|
|
|
test('preview shows letter content and GDPR footer', 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.goto('/compose?plate=ABC123')
|
|
|
|
await page.getByLabel('Ditt meddelande').fill('Testmeddelande')
|
|
|
|
await expect(
|
|
page.getByText('Detta brev skickades via Bilhej'),
|
|
).toBeVisible()
|
|
await expect(page.getByText('Transportstyrelsens fordonsregister')).toBeVisible()
|
|
})
|
|
|
|
test('Visa mallar button opens template picker', 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.goto('/compose?plate=ABC123')
|
|
|
|
await page.getByRole('button', { name: 'Visa mallar' }).click()
|
|
|
|
await expect(page.getByRole('heading', { name: 'Välj en mall' })).toBeVisible()
|
|
await expect(page.getByText('Komplimang')).toBeVisible()
|
|
await expect(page.getByText('Köpförfrågan')).toBeVisible()
|
|
})
|
|
|
|
test('selecting template fills textarea and closes picker', 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.goto('/compose?plate=ABC123')
|
|
|
|
await page.getByRole('button', { name: 'Visa mallar' }).click()
|
|
await page.getByText('Komplimang').click()
|
|
|
|
const textarea = page.getByLabel('Ditt meddelande')
|
|
await expect(textarea).toHaveValue(/jättefin/)
|
|
await expect(page.getByRole('heading', { name: 'Välj en mall' })).not.toBeVisible()
|
|
})
|
|
})
|