- 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
119 lines
4 KiB
TypeScript
119 lines
4 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
|
|
test.describe('Admin dashboard', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/logga-in')
|
|
await page.getByLabel('E-postadress').fill('admin@bilhalsning.se')
|
|
await page.getByLabel('Lösenord').fill('test1234')
|
|
await page.getByRole('button', { name: 'Logga in' }).click()
|
|
await page.waitForURL('/')
|
|
})
|
|
|
|
test('admin can navigate to admin page', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
await expect(
|
|
page.getByRole('heading', { name: 'Administration' }),
|
|
).toBeVisible()
|
|
})
|
|
|
|
test('non-admin user is redirected away from admin', async ({ page }) => {
|
|
await page.evaluate(() => localStorage.clear())
|
|
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('/admin')
|
|
|
|
await expect(page).toHaveURL('/')
|
|
})
|
|
|
|
test('shows orders table with columns', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
await expect(page.getByText('Datum')).toBeVisible()
|
|
await expect(page.getByText('E-post')).toBeVisible()
|
|
await expect(page.getByText('Regnr')).toBeVisible()
|
|
await expect(page.getByText('Status')).toBeVisible()
|
|
})
|
|
|
|
test('shows seeded order data', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
await expect(page.locator('.admin__plate').first()).toBeVisible()
|
|
await expect(page.getByText('DEF456').first()).toBeVisible()
|
|
await expect(page.getByText('GHI789').first()).toBeVisible()
|
|
})
|
|
|
|
test('click expand button shows letter content', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const expandBtns = page.locator('.admin__expand-btn')
|
|
await expandBtns.first().click()
|
|
|
|
await expect(page.getByText('Brevtext')).toBeVisible()
|
|
})
|
|
|
|
test('click expand button again collapses it', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const expandBtns = page.locator('.admin__expand-btn')
|
|
await expandBtns.first().click()
|
|
await expect(page.getByText('Brevtext')).toBeVisible()
|
|
|
|
await expandBtns.first().click()
|
|
await expect(page.getByText('Brevtext')).not.toBeVisible()
|
|
})
|
|
|
|
test('status dropdown changes update order status', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const selects = page.locator('.admin__status-select')
|
|
await selects.first().selectOption('delivered')
|
|
|
|
const updatedSelect = selects.first()
|
|
await expect(updatedSelect).toHaveValue('delivered')
|
|
})
|
|
|
|
test('admin cannot access admin page without auth', async ({ page }) => {
|
|
await page.evaluate(() => localStorage.clear())
|
|
await page.goto('/admin')
|
|
|
|
await expect(page).toHaveURL(/\/logga-in\?redirect=\/admin/)
|
|
})
|
|
|
|
test('expanded row shows tracking input and save button', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const expandBtns = page.locator('.admin__expand-btn')
|
|
await expandBtns.first().click()
|
|
|
|
await expect(page.getByText('Spårnings-ID').first()).toBeVisible()
|
|
await expect(page.locator('.admin__tracking-input')).toBeVisible()
|
|
await expect(page.getByRole('button', { name: 'Spara' })).toBeVisible()
|
|
})
|
|
|
|
test('shows PostNord link when trackingId exists', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const expandBtns = page.locator('.admin__expand-btn')
|
|
await expandBtns.last().click()
|
|
|
|
const trackingLink = page.locator('.admin__tracking-link')
|
|
await expect(trackingLink).toBeVisible()
|
|
await expect(trackingLink).toHaveAttribute('href', /postnord/)
|
|
})
|
|
|
|
test('hides PostNord link when trackingId is null', async ({ page }) => {
|
|
await page.goto('/admin')
|
|
|
|
const defRow = page.locator('.admin__row', { hasText: 'DEF456' }).first()
|
|
const expandBtn = defRow.locator('.admin__expand-btn')
|
|
await expandBtn.click()
|
|
|
|
const trackingLink = page.locator('.admin__tracking-link')
|
|
await expect(trackingLink).not.toBeVisible()
|
|
})
|
|
})
|