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

@@ -1,34 +0,0 @@
// spec: frontend/vue-app/e2e/plans/parent-item-management.plan.md
// seed: e2e/seed.spec.ts
import { test, expect } from '@playwright/test'
test('Convert a default kindness act to a user item by editing', async ({ page }) => {
await page.goto('/parent/tasks/chores')
await page.click('text=Kindness Acts')
// find a default act
await expect(page.locator('text=Be good for the day')).toBeVisible()
await expect(
page.locator('text=Be good for the day >> .. >> button[aria-label="Delete item"]'),
).toHaveCount(0)
// edit it — rename to avoid name collision with kindness-delete-default running in parallel
await page.click('text=Be good for the day')
await page.locator('#name').fill('Be good today (edited)')
await page.locator('#points').fill('7')
await page.getByRole('button', { name: 'Save' }).click()
// renamed item should now be deletable
await expect(
page
.getByText('Be good today (edited)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// clean up: delete the created user item so other tests see a clean default state
await page
.getByText('Be good today (edited)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
})

View File

@@ -0,0 +1,130 @@
// spec: frontend/vue-app/e2e/plans/parent-item-management.plan.md
// Merged from kindness-convert-default.spec.ts and kindness-delete-default.spec.ts.
// Both tests touch "Be good for the day" so they MUST run serially.
import { test, expect } from '@playwright/test'
test.describe('Default kindness act management', () => {
test.describe.configure({ mode: 'serial' })
test('Convert a default kindness act to a user item by editing', async ({ page }) => {
await page.goto('/parent/tasks/chores')
await page.click('text=Kindness Acts')
// find a default act
await expect(page.locator('text=Be good for the day')).toBeVisible()
await expect(
page.locator('text=Be good for the day >> .. >> button[aria-label="Delete item"]'),
).toHaveCount(0)
// edit it — rename so there is no name collision with the delete-default test
await page.click('text=Be good for the day')
await page.locator('#name').fill('Be good today (edited)')
await page.locator('#points').fill('7')
await page.getByRole('button', { name: 'Save' }).click()
// renamed item should now be deletable
await expect(
page
.getByText('Be good today (edited)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// clean up: delete the user item so the next test sees "Be good for the day" as a system default
await page
.getByText('Be good today (edited)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
})
test('Edit default kindness act "Be good for the day" and verify system act restoration on delete', async ({
page,
}) => {
await page.goto('/parent/tasks/chores')
await page.getByText('Kindness Acts').click()
// Cleanup: if a previous run left a modified 'Be good for the day' (with delete icon), remove it first
while (
(await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.count()) > 0
) {
await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.first()
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
}
// 1. Verify 'Be good for the day' is the system default (visible, no delete icon)
await expect(page.getByText('Be good for the day', { exact: true })).toBeVisible()
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// 2. Click 'Be good for the day' to open the edit form and change points
await page.getByText('Be good for the day', { exact: true }).click()
await expect(page.locator('input#name').inputValue()).resolves.toBe('Be good for the day')
await page.evaluate(() => {
const setVal = (sel: string, val: string) => {
const el = document.querySelector(sel) as HTMLInputElement | null
if (el) {
el.value = val
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
}
}
setVal('#points', '3')
})
// expect: Save button becomes enabled because the form is dirty
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// 3. Verify exactly one 'Be good for the day' is in the list and it now has a delete icon
await expect(page.getByText('Be good for the day', { exact: true })).toHaveCount(1)
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// expect: points display reflects the updated value
await expect(
page.getByText('Be good for the day', { exact: true }).locator('..').locator('.value'),
).toHaveText('3 pts')
// 4. Delete the modified 'Be good for the day' and verify the system default is restored
await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await expect(page.locator('text=Are you sure')).toBeVisible()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
// expect: 'Be good for the day' is still on the list (system default restored)
await expect(page.getByText('Be good for the day', { exact: true })).toBeVisible()
// expect: no delete icon (it's a system default again)
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// expect: original points (15 pts) are restored
await expect(
page.getByText('Be good for the day', { exact: true }).locator('..').locator('.value'),
).toHaveText('15 pts')
})
})

View File

@@ -1,93 +0,0 @@
// spec: frontend/vue-app/e2e/plans/parent-item-management.plan.md
// seed: e2e/seed.spec.ts
import { test, expect } from '@playwright/test'
test('Edit default kindness act "Be good for the day" and verify system act restoration on delete', async ({
page,
}) => {
await page.goto('/parent/tasks/chores')
await page.getByText('Kindness Acts').click()
// Cleanup: if a previous run left a modified 'Be good for the day' (with delete icon), remove it first
while (
(await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.count()) > 0
) {
await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.first()
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
}
// 1. Verify 'Be good for the day' is the system default (visible, no delete icon)
await expect(page.getByText('Be good for the day', { exact: true })).toBeVisible()
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// 2. Click 'Be good for the day' to open the edit form and change points
await page.getByText('Be good for the day', { exact: true }).click()
await expect(page.locator('input#name').inputValue()).resolves.toBe('Be good for the day')
await page.evaluate(() => {
const setVal = (sel: string, val: string) => {
const el = document.querySelector(sel) as HTMLInputElement | null
if (el) {
el.value = val
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
}
}
setVal('#points', '3')
})
// expect: Save button becomes enabled because the form is dirty
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// 3. Verify exactly one 'Be good for the day' is in the list and it now has a delete icon
await expect(page.getByText('Be good for the day', { exact: true })).toHaveCount(1)
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// expect: points display reflects the updated value
await expect(
page.getByText('Be good for the day', { exact: true }).locator('..').locator('.value'),
).toHaveText('3 pts')
// 4. Delete the modified 'Be good for the day' and verify the system default is restored
await page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await expect(page.locator('text=Are you sure')).toBeVisible()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
// expect: 'Be good for the day' is still on the list (system default restored)
await expect(page.getByText('Be good for the day', { exact: true })).toBeVisible()
// expect: no delete icon (it's a system default again)
await expect(
page
.getByText('Be good for the day', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// expect: original points (15 pts) are restored
await expect(
page.getByText('Be good for the day', { exact: true }).locator('..').locator('.value'),
).toHaveText('15 pts')
})

View File

@@ -17,8 +17,11 @@ test('Convert a default penalty to a user item by editing', async ({ page }) =>
await page.locator('#points').fill('15')
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// now should have delete option
// now should have delete option (match the updated name exactly)
await expect(
page.locator('text=Fighting >> .. >> button[aria-label="Delete item"]'),
page
.getByText('Fighting (custom)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
})

View File

@@ -0,0 +1,131 @@
// spec: frontend/vue-app/e2e/plans/parent-item-management.plan.md
// Merged from penalty-convert-default.spec.ts and penalty-delete-default.spec.ts.
// Both tests touch "Fighting" so they MUST run serially.
import { test, expect } from '@playwright/test'
test.describe('Default penalty management', () => {
test.describe.configure({ mode: 'serial' })
test('Convert a default penalty to a user item by editing', async ({ page }) => {
await page.goto('/parent/tasks/chores')
await page.click('text=Penalties')
// locate default penalty
await expect(page.locator('text=Fighting')).toBeVisible()
await expect(
page.locator('text=Fighting >> .. >> button[aria-label="Delete item"]'),
).toHaveCount(0)
// edit it (click the item itself)
await page.getByText('Fighting', { exact: true }).click()
await page.locator('#name').fill('Fighting (custom)')
await page.locator('#points').fill('15')
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// now should have delete option
await expect(
page
.getByText('Fighting (custom)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// clean up: delete so the next test sees 'Fighting' as a system default again
await page
.getByText('Fighting (custom)', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
})
test('Edit default penalty "Fighting" and verify system penalty restoration on delete', async ({
page,
}) => {
await page.goto('/parent/tasks/chores')
await page.getByText('Penalties').click()
// Cleanup: if a previous run left a modified 'Fighting' (with delete icon), remove it first
while (
(await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.count()) > 0
) {
await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.first()
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
}
// 1. Verify 'Fighting' is the system default (visible, no delete icon)
await expect(page.getByText('Fighting', { exact: true })).toBeVisible()
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// 2. Click 'Fighting' to open the edit form and change points
await page.getByText('Fighting', { exact: true }).click()
await expect(page.locator('input#name').inputValue()).resolves.toBe('Fighting')
await page.evaluate(() => {
const setVal = (sel: string, val: string) => {
const el = document.querySelector(sel) as HTMLInputElement | null
if (el) {
el.value = val
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
}
}
setVal('#points', '3')
})
// expect: Save button becomes enabled because the form is dirty
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// 3. Verify exactly one 'Fighting' is in the list and it now has a delete icon
await expect(page.getByText('Fighting', { exact: true })).toHaveCount(1)
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// expect: points display reflects the updated value
await expect(
page.getByText('Fighting', { exact: true }).locator('..').locator('.value'),
).toHaveText('3 pts')
// 4. Delete the modified 'Fighting' and verify the system default is restored
await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await expect(page.locator('text=Are you sure')).toBeVisible()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
// expect: 'Fighting' is still on the list (system default restored)
await expect(page.getByText('Fighting', { exact: true })).toBeVisible()
// expect: no delete icon (it's a system default again)
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// expect: original points (10 pts) are restored
await expect(
page.getByText('Fighting', { exact: true }).locator('..').locator('.value'),
).toHaveText('10 pts')
})
})

View File

@@ -1,93 +0,0 @@
// spec: frontend/vue-app/e2e/plans/parent-item-management.plan.md
// seed: e2e/seed.spec.ts
import { test, expect } from '@playwright/test'
test('Edit default penalty "Fighting" and verify system penalty restoration on delete', async ({
page,
}) => {
await page.goto('/parent/tasks/chores')
await page.getByText('Penalties').click()
// Cleanup: if a previous run left a modified 'Fighting' (with delete icon), remove it first
while (
(await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.count()) > 0
) {
await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.first()
.click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
}
// 1. Verify 'Fighting' is the system default (visible, no delete icon)
await expect(page.getByText('Fighting', { exact: true })).toBeVisible()
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// 2. Click 'Fighting' to open the edit form and change points
await page.getByText('Fighting', { exact: true }).click()
await expect(page.locator('input#name').inputValue()).resolves.toBe('Fighting')
await page.evaluate(() => {
const setVal = (sel: string, val: string) => {
const el = document.querySelector(sel) as HTMLInputElement | null
if (el) {
el.value = val
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
}
}
setVal('#points', '3')
})
// expect: Save button becomes enabled because the form is dirty
await expect(page.getByRole('button', { name: 'Save' })).toBeEnabled()
await page.getByRole('button', { name: 'Save' }).click()
// 3. Verify exactly one 'Fighting' is in the list and it now has a delete icon
await expect(page.getByText('Fighting', { exact: true })).toHaveCount(1)
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toBeVisible()
// expect: points display reflects the updated value
await expect(
page.getByText('Fighting', { exact: true }).locator('..').locator('.value'),
).toHaveText('3 pts')
// 4. Delete the modified 'Fighting' and verify the system default is restored
await page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]')
.click()
await expect(page.locator('text=Are you sure')).toBeVisible()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
// expect: 'Fighting' is still on the list (system default restored)
await expect(page.getByText('Fighting', { exact: true })).toBeVisible()
// expect: no delete icon (it's a system default again)
await expect(
page
.getByText('Fighting', { exact: true })
.locator('..')
.locator('button[aria-label="Delete item"]'),
).toHaveCount(0)
// expect: original points (10 pts) are restored
await expect(
page.getByText('Fighting', { exact: true }).locator('..').locator('.value'),
).toHaveText('10 pts')
})