Files
chore/frontend/vue-app/e2e/mode_parent/child-options/delete-child.spec.ts
Ryan Kegel c2b022eb0b
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Has been cancelled
Refactor Playwright tests and update configurations
- 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.
2026-03-13 23:26:27 -04:00

55 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 Child', () => {
test.describe.configure({ mode: 'serial' })
const CHILD_NAME = 'KebabDelete'
let childId = ''
test.afterEach(async ({ request }) => {
// Best-effort cleanup in case the test did not delete the child
if (childId) await request.delete(`/api/child/${childId}`)
childId = ''
})
test('Confirm deletes the child from the list', async ({ page, request }) => {
childId = await createTestChild(request, CHILD_NAME)
await page.goto('/parent')
await expect(page.getByRole('heading', { name: CHILD_NAME })).toBeVisible()
const card = page.locator('.card').filter({ hasText: CHILD_NAME })
await card.getByRole('button', { name: 'Options' }).click()
await card.getByRole('button', { name: 'Delete Child' }).click()
await expect(page.getByText('Are you sure you want to delete this child?')).toBeVisible()
await page.getByRole('button', { name: 'Delete' }).click()
await expect(page.getByRole('heading', { name: CHILD_NAME })).not.toBeVisible()
childId = '' // already deleted, skip afterEach cleanup
})
test('Cancel does not delete the child', async ({ page, request }) => {
childId = await createTestChild(request, CHILD_NAME)
await page.goto('/parent')
await expect(page.getByRole('heading', { name: CHILD_NAME })).toBeVisible()
const card = page.locator('.card').filter({ hasText: CHILD_NAME })
await card.getByRole('button', { name: 'Options' }).click()
await card.getByRole('button', { name: 'Delete Child' }).click()
await expect(page.getByText('Are you sure you want to delete this child?')).toBeVisible()
await page.getByRole('button', { name: 'Cancel' }).click()
await expect(page.getByText('Are you sure you want to delete this child?')).not.toBeVisible()
await expect(page.getByRole('heading', { name: CHILD_NAME })).toBeVisible()
})
})