Templates serve as a brand shield (showing the platform facilitates all kinds of messaging), not as a compose-flow form control. Remove them from the data model and compose page. Templates will live as branding elements on the landing page in a future commit. Backend: - Remove template field from Order entity (getter/setter removed) - Remove template from CreateOrderRequest DTO - Remove template from OrderResponse DTO - Remove template param from OrderService.createOrder() - Remove template passthrough in OrderController - Remove /api/templates permitAll from SecurityConfig - Edit V5 migration: remove template column from orders table - Edit V6 migration: remove template from seed data - Update OrderControllerTest (remove template from assertions/requests) - Update OrderServiceTest (remove template from createOrder calls) Frontend: - Remove template from Order interface in api/orders.ts - Remove template param from createOrder() function - Remove template display from OrdersPage.vue cards - Rewrite ComposePage.vue: remove template selector, keep textarea + preview + submit - Update ComposePage.spec.ts (remove template tests, add preview/GDPR tests) - Update OrdersPage.spec.ts (remove template from mock data and display test) - Update compose.spec.ts E2E (remove template selector interactions) - Update order-history.spec.ts E2E (remove template names test) - Fix unused import in Router.spec.ts - Also includes minor Prettier formatting in AppHeader.spec.ts, AdminPage.vue, authStore.ts
87 lines
3.2 KiB
TypeScript
87 lines
3.2 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')).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: 'Skicka brev (49 kr)' })
|
|
await expect(button).toBeDisabled()
|
|
})
|
|
|
|
test('can create order and navigate to orders 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: 'Skicka brev (49 kr)' })
|
|
await expect(button).toBeEnabled()
|
|
await button.click()
|
|
|
|
await expect(page).toHaveURL('/orders')
|
|
await expect(
|
|
page.getByRole('heading', { name: 'Mina beställningar' }),
|
|
).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.se'),
|
|
).toBeVisible()
|
|
await expect(page.getByText('Transportstyrelsens fordonsregister')).toBeVisible()
|
|
})
|
|
})
|