- Implement tests for creating, editing, canceling, and deleting rewards in parent mode. - Include scenarios for converting default rewards to user items and verifying restoration of default rewards after deletion. - Create a comprehensive test plan outlining the steps and expectations for each scenario.
4.3 KiB
Parent Rewards Management
Application Overview
Focus on parent-mode flows interacting with the Rewards section. A parent must be authenticated via PIN and can create, cancel, edit, delete, and manage default rewards. The scenarios mirror the chore/kindness/penalty plans but target /parent/rewards and the reward-specific fields (name, cost, description). All tests run under parent mode in the mode_parent/rewards directory. Unique names use a ${Date.now()} suffix to avoid collisions.
Test Scenarios
1. Create and manage rewards
Seed: e2e/seed.spec.ts
1.1. Create a new reward
File: e2e/mode_parent/rewards/reward-create-edit.spec.ts
Steps:
- expect: Navigate to `/parent/rewards` and verify the default reward list loads (some reward name visible)
- Click the 'Create Reward' FAB - expect: The create form appears with 'Reward Name' and 'Cost' fields - expect: Create button is disabled initially
- Enter a unique name (e.g.
Toy car ${suffix}) and20in Cost via DOM events - expect: Create button becomes enabled - Click the Create button
- expect: No
.errorelements are shown - expect: The new reward appears in the list
1.2. Cancel reward creation
File: e2e/mode_parent/rewards/reward-cancel.spec.ts
Steps:
- expect: Navigate to `/parent/rewards` and click 'Create Reward'
- expect: Create form is displayed with name label visible
- Fill 'Test' for name and '5' for cost then click 'Cancel' - expect: User is returned to the rewards list - expect: No element with text 'Test' exists
1.3. Edit an existing reward
File: e2e/mode_parent/rewards/reward-create-edit.spec.ts
Steps:
- expect: Navigate to `/parent/rewards`; create `Toy car ${suffix}` if absent
- expect: The reward appears in the list
- Click the reward row to open edit form - expect: Edit form appears with 'Reward Name' label visible
- Change the name to
Toy boat ${suffix}and cost to '25' via DOM events - expect: Save button becomes enabled - Click Save - expect: No errors are displayed - expect: Updated reward name appears in the list
1.4. Cancel reward edit
File: e2e/mode_parent/rewards/reward-cancel.spec.ts
Steps:
- expect: Navigate to `/parent/rewards`; ensure `Toy car` exists; click its row
- expect: Edit form is displayed
- Change the name to 'Should not save' via DOM events then click 'Cancel'
- expect: Rewards list visible again
- expect:
Toy caris still present - expect:Should not savedoes not appear
1.5. Convert a default reward to a user item by editing
File: e2e/mode_parent/rewards/reward-convert-default.spec.ts
Steps:
- expect: Navigate to `/parent/rewards` and locate a default reward such as 'Choose meal'
- expect: Item is visible with no delete button
- Click the row to open edit form
- expect: Edit form opens with
input#namevalue matching the default - Change the name to 'Choose meal (custom)' and cost to '35' - expect: Save button becomes enabled
- Click Save - expect: Row now shows a visible delete button
1.6. Delete a reward
File: e2e/mode_parent/rewards/reward-create-edit.spec.ts
Steps:
- expect: Navigate to `/parent/rewards`; create a unique reward if necessary
- expect: The reward appears in the list with a delete control
- Click the delete icon and confirm the dialog - expect: Item is removed from the list
1.7. Edit default reward cost and verify system restoration on delete
File: e2e/mode_parent/rewards/reward-delete-default.spec.ts
Steps:
- expect: Navigate to `/parent/rewards`; clean up any user-copy of 'Choose meal' from prior runs
- expect: Verify default 'Choose meal' is present with no delete icon
- Click 'Choose meal' to open edit form; confirm input#name reads 'Choose meal'; change cost to '50' via DOM events - expect: Save button becomes enabled
- Click Save - expect: Exactly one 'Choose meal' row exists - expect: Delete icon now visible on that row - expect: Cost display reads '50 pts'
- Click delete icon and confirm - expect: 'Choose meal' remains in list (default restored) - expect: No delete icon present - expect: Cost display returns to original value