# 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:**
  1. -
    - expect: Navigate to `/parent/rewards` and verify the default reward list loads (some reward name visible)
  2. Click the 'Create Reward' FAB
    - expect: The create form appears with 'Reward Name' and 'Cost' fields
    - expect: Create button is disabled initially
  3. Enter a unique name (e.g. `Toy car ${suffix}`) and `20` in Cost via DOM events
    - expect: Create button becomes enabled
  4. Click the Create button
    - expect: No `.error` elements 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:**
  1. -
    - expect: Navigate to `/parent/rewards` and click 'Create Reward'
    - expect: Create form is displayed with name label visible
  2. 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:**
  1. -
    - expect: Navigate to `/parent/rewards`; create `Toy car ${suffix}` if absent
    - expect: The reward appears in the list
  2. Click the reward row to open edit form
    - expect: Edit form appears with 'Reward Name' label visible
  3. Change the name to `Toy boat ${suffix}` and cost to '25' via DOM events
    - expect: Save button becomes enabled
  4. 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:**
  1. -
    - expect: Navigate to `/parent/rewards`; ensure `Toy car` exists; click its row
    - expect: Edit form is displayed
  2. Change the name to 'Should not save' via DOM events then click 'Cancel'
    - expect: Rewards list visible again
    - expect: `Toy car` is still present
    - expect: `Should not save` does 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:**
  1. -
    - expect: Navigate to `/parent/rewards` and locate a default reward such as 'Choose meal'
    - expect: Item is visible with no delete button
  2. Click the row to open edit form
    - expect: Edit form opens with `input#name` value matching the default
  3. Change the name to 'Choose meal (custom)' and cost to '35'
    - expect: Save button becomes enabled
  4. 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:**
  1. -
    - expect: Navigate to `/parent/rewards`; create a unique reward if necessary
    - expect: The reward appears in the list with a delete control
  2. 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:**
  1. -
    - 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
  2. 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
  3. Click Save
    - expect: Exactly one 'Choose meal' row exists
    - expect: Delete icon now visible on that row
    - expect: Cost display reads '50 pts'
  4. 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
