Fix flaky admin plate search in deferred-payment E2E.
Merge admin lookup checks into one serial test, create the plate when the order is created, and search using the plate shown in the admin row. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4d3beeffb4
commit
cf938501c5
1 changed files with 22 additions and 39 deletions
|
|
@ -4,11 +4,12 @@ test.describe.configure({ mode: 'serial' })
|
||||||
|
|
||||||
function uniquePlate(prefix: string): string {
|
function uniquePlate(prefix: string): string {
|
||||||
const digits = String((Date.now() % 90) + 10)
|
const digits = String((Date.now() % 90) + 10)
|
||||||
return `${prefix}${digits}E`
|
const letter = String.fromCharCode(65 + (Date.now() % 26))
|
||||||
|
return `${prefix}${digits}${letter}`
|
||||||
}
|
}
|
||||||
|
|
||||||
test.describe('Deferred payment and admin lookup', () => {
|
test.describe('Deferred payment and admin lookup', () => {
|
||||||
const plate = uniquePlate('LAT')
|
let plate = ''
|
||||||
const letterText = 'E2E-test: betalar senare från orderhistoriken.'
|
const letterText = 'E2E-test: betalar senare från orderhistoriken.'
|
||||||
|
|
||||||
let orderId = ''
|
let orderId = ''
|
||||||
|
|
@ -39,6 +40,7 @@ test.describe('Deferred payment and admin lookup', () => {
|
||||||
await page.goto('/admin')
|
await page.goto('/admin')
|
||||||
await expect(page.locator('.admin__loading')).toBeHidden({ timeout: 30_000 })
|
await expect(page.locator('.admin__loading')).toBeHidden({ timeout: 30_000 })
|
||||||
await page.getByRole('button', { name: /Att göra/ }).click()
|
await page.getByRole('button', { name: /Att göra/ }).click()
|
||||||
|
await expect(page.locator('.admin__stat--active')).toContainText('Att göra')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchAdminOrders(
|
async function searchAdminOrders(
|
||||||
|
|
@ -46,26 +48,16 @@ test.describe('Deferred payment and admin lookup', () => {
|
||||||
query: string,
|
query: string,
|
||||||
) {
|
) {
|
||||||
const search = page.locator('#admin-order-search')
|
const search = page.locator('#admin-order-search')
|
||||||
await search.clear()
|
await search.click()
|
||||||
await search.fill(query)
|
await search.fill(query)
|
||||||
await expect(search).toHaveValue(query)
|
await expect(search).toHaveValue(query)
|
||||||
}
|
await expect(page.locator('.admin__filter-empty')).toBeHidden()
|
||||||
|
|
||||||
async function expectAdminOrderRow(
|
|
||||||
page: import('@playwright/test').Page,
|
|
||||||
options: { shortOrderId: string; plate: string; todo?: boolean },
|
|
||||||
) {
|
|
||||||
const row = page.locator('.admin__row', { hasText: options.shortOrderId })
|
|
||||||
await expect(row).toBeVisible({ timeout: 15_000 })
|
|
||||||
await expect(row.locator('.admin__plate')).toHaveText(options.plate)
|
|
||||||
if (options.todo) {
|
|
||||||
await expect(row).toHaveClass(/admin__row--todo/)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test('user creates order, leaves payment, and pays later from orders', async ({
|
test('user creates order, leaves payment, and pays later from orders', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
|
plate = uniquePlate('LAT')
|
||||||
await loginAsTestUser(page)
|
await loginAsTestUser(page)
|
||||||
|
|
||||||
await page.goto(`/compose?plate=${plate}`)
|
await page.goto(`/compose?plate=${plate}`)
|
||||||
|
|
@ -98,40 +90,31 @@ test.describe('Deferred payment and admin lookup', () => {
|
||||||
await expect(orderCard.getByRole('link', { name: 'Betala 49 kr' })).not.toBeVisible()
|
await expect(orderCard.getByRole('link', { name: 'Betala 49 kr' })).not.toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('admin finds paid order under Att göra when searching partial order id', async ({
|
test('admin finds paid order under Att göra by order id and plate', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
await loginAsAdmin(page)
|
await loginAsAdmin(page)
|
||||||
await openAdminTodoBoard(page)
|
await openAdminTodoBoard(page)
|
||||||
|
|
||||||
await searchAdminOrders(page, shortOrderId)
|
await searchAdminOrders(page, shortOrderId)
|
||||||
|
|
||||||
await expectAdminOrderRow(page, {
|
|
||||||
shortOrderId,
|
|
||||||
plate,
|
|
||||||
todo: true,
|
|
||||||
})
|
|
||||||
const row = page.locator('.admin__row', { hasText: shortOrderId })
|
const row = page.locator('.admin__row', { hasText: shortOrderId })
|
||||||
|
await expect(row).toBeVisible({ timeout: 15_000 })
|
||||||
|
await expect(row).toHaveClass(/admin__row--todo/)
|
||||||
await expect(row.locator('.admin__order-id')).toHaveText(shortOrderId)
|
await expect(row.locator('.admin__order-id')).toHaveText(shortOrderId)
|
||||||
})
|
const plateInAdmin = (await row.locator('.admin__plate').textContent())?.trim()
|
||||||
|
expect(plateInAdmin).toBeTruthy()
|
||||||
|
|
||||||
test('admin finds paid order when searching full order id', async ({ page }) => {
|
|
||||||
await loginAsAdmin(page)
|
|
||||||
await openAdminTodoBoard(page)
|
|
||||||
await searchAdminOrders(page, orderId)
|
await searchAdminOrders(page, orderId)
|
||||||
|
await expect(
|
||||||
|
page.locator('.admin__row', { hasText: shortOrderId }),
|
||||||
|
).toBeVisible()
|
||||||
|
|
||||||
await expectAdminOrderRow(page, { shortOrderId, plate })
|
await searchAdminOrders(page, plateInAdmin!)
|
||||||
const row = page.locator('.admin__row', { hasText: shortOrderId })
|
const rowByPlate = page.locator('.admin__row').filter({
|
||||||
await expect(row.locator('.admin__order-id')).toHaveText(shortOrderId)
|
has: page.locator('.admin__plate', { hasText: plateInAdmin! }),
|
||||||
})
|
})
|
||||||
|
await expect(rowByPlate).toBeVisible()
|
||||||
test('admin finds paid order when searching registration number', async ({
|
await expect(rowByPlate.locator('.admin__order-id')).toHaveText(shortOrderId)
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
await loginAsAdmin(page)
|
|
||||||
await openAdminTodoBoard(page)
|
|
||||||
await searchAdminOrders(page, plate)
|
|
||||||
|
|
||||||
await expectAdminOrderRow(page, { shortOrderId, plate })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('admin does not show unpaid order under Att göra before payment', async ({
|
test('admin does not show unpaid order under Att göra before payment', async ({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue