Refactor Playwright tests and update configurations
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Has been cancelled

- Consolidated kindness and penalty tests into single files to ensure serial execution and prevent conflicts.
- Updated Playwright configuration to define separate test buckets for child options and create child tests, ensuring proper execution order.
- Added new tests for child kebab menu options including editing, deleting points, and confirming child deletion.
- Removed obsolete tests for kindness and penalty default management.
- Updated authentication tokens in user.json for improved security.
- Enhanced test reliability by implementing retry logic for UI interactions in the create-child happy path test.
This commit is contained in:
2026-03-13 23:26:27 -04:00
parent 8da04676ca
commit c2b022eb0b
14 changed files with 568 additions and 261 deletions

View File

@@ -0,0 +1,40 @@
import { test, expect } from '@playwright/test'
async function createTestChild(request: any, name: string, age = 8): Promise<string> {
await request.put('/api/child/add', { data: { name, age } })
const listRes = await request.get('/api/child/list')
const data = await listRes.json()
const child = (data.children ?? []).find((c: any) => c.name === name)
return child?.id ?? ''
}
test.describe('Child kebab menu Delete Points', () => {
const CHILD_NAME = 'KebabPoints'
let childId = ''
test.beforeEach(async ({ request }) => {
childId = await createTestChild(request, CHILD_NAME)
await request.put(`/api/child/${childId}/edit`, { data: { points: 50 } })
})
test.afterEach(async ({ request }) => {
if (childId) await request.delete(`/api/child/${childId}`)
childId = ''
})
test('Delete Points resets child points to 0', async ({ page }) => {
await page.goto('/parent')
const card = page.locator('.card').filter({ hasText: CHILD_NAME })
await card.getByRole('button', { name: 'Options' }).click()
await expect(card.getByRole('button', { name: 'Options' })).toHaveAttribute(
'aria-expanded',
'true',
)
await card.getByRole('button', { name: 'Delete Points' }).click()
await expect(card.getByText('Points: 0')).toBeVisible()
})
})