Files
chore/frontend/vue-app/e2e/mode_parent/rewards/reward-cancel.spec.ts
Ryan Kegel a9131242a7
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 3m33s
Add end-to-end tests for task modification and assignment features
- Implemented tests for editing penalty points and reward costs in `penalty-edit-points.spec.ts` and `reward-edit-cost.spec.ts`.
- Created detailed plans for task activation and assignment scenarios in `task-activated.plan.md` and `task-assignment.plan.md`.
- Added comprehensive test cases for modifying tasks, including editing points for chores, kindness acts, penalties, and rewards in `task-modified.plan.md`.
- Ensured all tests are isolated and run in serial mode to maintain state integrity.
2026-03-17 22:46:27 -04:00

79 lines
2.9 KiB
TypeScript

// spec: frontend/vue-app/e2e/plans/parent-rewards-management.plan.md
// seed: e2e/seed.spec.ts
import { test, expect } from '@playwright/test'
test.describe('Reward cancellation', () => {
test.beforeEach(async ({ page }, testInfo) => {
test.skip(testInfo.project.name === 'chromium-no-pin', 'Requires parent-authenticated mode')
})
test.describe.configure({ mode: 'serial' })
test('Cancel reward creation', async ({ page }) => {
const name = `CancelMe-${Date.now()}`
// 1. Navigate and open create form
await page.goto('/parent/rewards')
await page.getByRole('button', { name: 'Create Reward' }).click()
await expect(page.locator('text=Reward Name')).toBeVisible()
// 2. Fill then cancel
await page.evaluate((n) => {
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('#name', n)
setVal('#cost', '5')
}, name)
await page.getByRole('button', { name: 'Cancel' }).click()
// verify return to list and the cancelled item was not saved
await expect(page.getByText(name, { exact: true })).toHaveCount(0)
})
test('Cancel reward edit', async ({ page }) => {
// 1. Ensure Toy car exists and open edit
const suffix = Date.now()
const original = `Toy car ${suffix}`
await page.goto('/parent/rewards')
if (!(await page.locator(`text=${original}`).count())) {
await page.getByRole('button', { name: 'Create Reward' }).click()
await page.evaluate((name) => {
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('#name', name)
setVal('#cost', '20')
}, original)
await page.getByRole('button', { name: 'Create' }).click()
}
await expect(page.locator(`text=${original}`)).toBeVisible()
await page.click(`text=${original}`)
await expect(page.locator('text=Reward Name')).toBeVisible()
// 2. make a change then cancel
await page.evaluate(() => {
const el = document.querySelector('#name') as HTMLInputElement | null
if (el) {
el.value = 'Should not save'
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
}
})
await page.getByRole('button', { name: 'Cancel' }).click()
await expect(page.locator('text=Should not save')).toHaveCount(0)
await expect(page.locator(`text=${original}`)).toBeVisible()
})
})