feat: add functions to validate today's timestamps and update pending status logic
All checks were successful
Chore App Build, Test, and Push Docker Images / build-and-push (push) Successful in 2m20s

This commit is contained in:
2026-05-03 12:26:21 -04:00
parent ce3d1b3d54
commit 2e1a0ab2fa
4 changed files with 46 additions and 22 deletions

View File

@@ -45,6 +45,28 @@ async function openEditModal(page: Page, card: Locator): Promise<void> {
await expect(page.getByRole('button', { name: 'Save' })).toBeVisible()
}
async function seedPendingReward(
request: APIRequestContext,
childId: string,
rewardId: string,
rewardCost: number,
): Promise<void> {
await request.put(`/api/child/${childId}/edit`, { data: { points: rewardCost } })
const requestResp = await request.post(`/api/child/${childId}/request-reward`, {
data: { reward_id: rewardId },
})
if (requestResp.status() === 409) {
await request.post(`/api/child/${childId}/cancel-request-reward`, {
data: { reward_id: rewardId },
})
await request.post(`/api/child/${childId}/request-reward`, {
data: { reward_id: rewardId },
})
}
}
test.describe('Reward edit cost', () => {
test.describe.configure({ mode: 'serial' })
@@ -172,9 +194,8 @@ test.describe('Reward edit cost', () => {
page,
request,
}) => {
// Give child enough points to satisfy the original reward cost, then create a pending request
await request.put(`/api/child/${childId}/edit`, { data: { points: REWARD_COST } })
await request.post(`/api/child/${childId}/request-reward`, { data: { reward_id: rewardId } })
// Ensure a fresh pending request exists for this test.
await seedPendingReward(request, childId, rewardId, REWARD_COST)
await page.goto(`/parent/${childId}`)
const card = rewardSection(page).locator('.item-card').filter({ hasText: REWARD_NAME })
@@ -197,8 +218,11 @@ test.describe('Reward edit cost', () => {
test('Editing a pending reward — confirming the warning opens the override modal', async ({
page,
request,
}) => {
// Pending state was established in the previous test; navigate fresh
// Seed pending state in this test to avoid cross-test coupling.
await seedPendingReward(request, childId, rewardId, REWARD_COST)
await page.goto(`/parent/${childId}`)
const card = rewardSection(page).locator('.item-card').filter({ hasText: REWARD_NAME })
await card.waitFor({ state: 'visible' })