# Parent Activate Modifies Task (changing points and resetting completed tasks)

## Application Overview

In parent mode, with a populated list of chores, kindness acts, penalties, and rewards, tests must be run to make sure a chore has a kebab menu that lets a parent make modifications to the chore. For kindness acts, penalties, and rewards, parents should be able to click on the edit button and change the amount of points or cost of the item.

This is a continuation of tests from task-assignment.plan.md

**Chores:**

- When the parent clicks on a chore's kebab menu, there should be an item that allows the parent to "Edit Points"
- When the parent clicks on a chore's kebab menu with the chore already in the COMPLETED state, there should be a "Reset" option.
- When a chore's "Edit Points" are clicked, a new dialog should appear with the chore's title, icon, and point value. These points should be editable. The value should not be negitive. If cancelled, nothing happens. If Save is clicked, the chore's point value should match what was entered. There should also be a star emoji that appears on the chore's card on the top right. The maximum value for the points should be 10000. Anything higher, the save button should disable.
- Clicking outside the points dialog should not close it. It should be modal.
- When the parent clicks "Reset" from a completed chore. That chore should become active again. The completed banner should be gone and the chore can be activated again.
- Everytime a resetted chore is activated it should go back to the completed state until reset again.

**Kindness Acts, Penalties, Rewards**

- When the parent clicks on these item's edit button, a new dialog should appear with the item's title, icon, and point/cost value. These points/costs should be editable. The value should not be negitive. If cancelled, nothing happens. If Save is clicked, the item's point value should match what was entered. There should also be a star emoji that appears on the chore's card on the top right. The maximum value for the points should be 10000. Anything higher, the save button should disable.

**Other Tests:**
When a point/cost value is changed, make sure the new value take affect when the parent activates the task. This testing is done in task-assignment.plan.md, but we want to verify the new point values work. There may be some test overlap.

---

## Implementation

Tests are in `e2e/mode_parent/task-modification/`. Each spec creates its own isolated child via the API so all 6 files run in parallel under the `chromium-task-modification` project.

## Playwright Project

**Project name:** `chromium-task-modification`
**Config:** `playwright.config.ts`
**testMatch:** `/mode_parent/task-modification/.+\.spec\.ts/`
**Dependencies:** `setup`
**Excluded from:** `chromium-tasks-rewards` (via `testIgnore`)

---

## Test Scenarios

### 1. Chore Edit Points ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/chore-edit-points.spec.ts`

**Seed:** Creates an isolated child and a chore task via API in `beforeAll`. Deletes all in `afterAll`.

#### 1.1. Kebab button visibility ✅

- Kebab button is hidden initially; becomes visible after the chore card is clicked; hides again when a different card is clicked

#### 1.2. Kebab menu contents ✅

- Menu contains "Edit Points" and "Schedule" options

#### 1.3. Override modal opens pre-populated ✅

- "Edit Points" opens the override modal with the current point value already filled in

#### 1.4. Modal is blocking ✅

- Clicking outside the modal does not close it

#### 1.5. Cancel does not save ✅

- Card still shows original points after Cancel; no ⭐ badge appears

#### 1.6. Save updates displayed points ✅

- Saving a valid new value updates the point display on the card

#### 1.7. ⭐ override badge appears after save ✅

- ⭐ badge appears on the card after saving a custom value

#### 1.8. ⭐ badge persists on revert ✅

- ⭐ badge remains even when the value is changed back to the original default

#### 1.9. Validation — negative and over-limit ✅

- Negative value disables the Save button; value above 10000 disables Save; exactly 10000 enables it

#### 1.10. Zero is valid ✅

- Card shows "0 Points" with ⭐ badge when zero is saved

---

### 2. Chore Reset ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/chore-reset.spec.ts`

**Seed:** Creates an isolated child and a chore task via API in `beforeAll`. Activates and confirms the chore as needed per test. Deletes all in `afterAll`.

#### 2.1. "Reset" absent before completion ✅

- "Reset" is not present in the kebab menu when the chore is not yet completed

#### 2.2. COMPLETED stamp after activation ✅

- Chore shows COMPLETED stamp after activation and parent confirmation

#### 2.3. "Reset" appears after completion ✅

- "Reset" appears in the kebab menu once the chore is in COMPLETED state

#### 2.4. Reset removes COMPLETED stamp ✅

- Clicking "Reset" removes the COMPLETED stamp and returns the chore to active

#### 2.5. Chore is re-activatable after reset ✅

- After reset, the chore can be activated again and returns to COMPLETED on confirmation

#### 2.6. Reset → activate cycle is repeatable ✅

- The reset and re-activate cycle can be repeated multiple times without error

---

### 3. Kindness Act Edit Points ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/kindness-edit-points.spec.ts`

**Seed:** Creates an isolated child and two kindness act tasks via API in `beforeAll`. Deletes all in `afterAll`.

#### 3.1. Edit button visibility ✅

- Edit button appears on first click of a kindness card; disappears when a different card is clicked

#### 3.2. Override modal opens pre-populated ✅

- Edit button opens modal with the kindness name, "Assign new points" subtitle, and current point value filled in

#### 3.3. Cancel does not save ✅

- Points remain unchanged and no ⭐ badge appears after Cancel

#### 3.4. Save updates displayed points and badge ✅

- Saving a new value updates the displayed points and shows ⭐ badge

#### 3.5. Validation — negative and over-limit ✅

- Negative value disables the Save button; value above 10000 disables Save; exactly 10000 enables it

---

### 4. Penalty Edit Points ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/penalty-edit-points.spec.ts`

**Seed:** Creates an isolated child and two penalty tasks via API in `beforeAll`. Deletes all in `afterAll`.

#### 4.1. Edit button visibility ✅

- Edit button appears on first click of a penalty card; disappears when a different card is clicked

#### 4.2. Override modal opens pre-populated ✅

- Edit button opens modal with the penalty name, "Assign new points" subtitle, and the raw (positive) point value filled in — not the negated display value

#### 4.3. Cancel does not save ✅

- Display remains unchanged after Cancel

#### 4.4. Save updates card and badge ✅

- Saving a new value updates the card to show the negated override value and ⭐ badge

#### 4.5. Validation — negative and over-limit ✅

- Negative value disables the Save button; value above 10000 disables Save; exactly 10000 enables it

---

### 5. Reward Edit Cost ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/reward-edit-cost.spec.ts`

**Seed:** Creates an isolated child and a reward (with a pending redemption for warning-dialog tests) via API in `beforeAll`. Deletes all in `afterAll`.

#### 5.1. Edit button visibility ✅

- Edit button appears on first click of a reward card

#### 5.2. Override modal opens pre-populated ✅

- Edit button opens modal with the reward name, "Assign new cost" subtitle, and the current cost filled in

#### 5.3. Cancel does not save ✅

- Points needed display remains unchanged after Cancel

#### 5.4. Save updates cost and badge ✅

- Saving a new cost updates the points needed display and shows ⭐ badge

#### 5.5. Zero cost makes reward immediately redeemable ✅

- Setting cost to 0 marks the reward as immediately redeemable

#### 5.6. Validation — negative and over-limit ✅

- Negative value disables the Save button; value above 10000 disables Save; exactly 10000 enables it

#### 5.7. Warning dialog for pending redemption ✅

- Editing a reward with an active pending redemption shows a warning dialog; Cancel aborts the edit

#### 5.8. Confirming warning opens override modal ✅

- Confirming the warning dialog proceeds to open the override modal normally

---

### 6. Modified Points Take Effect on Activation ✅ IMPLEMENTED

**File:** `e2e/mode_parent/task-modification/modified-points-activation.spec.ts`

**Seed:** Creates an isolated child, a chore, a kindness act, a penalty, and a reward via API in `beforeAll`. Sets overrides for each. Deletes all in `afterAll`.

#### 6.1. Modified chore points awarded on activation ✅

- Child receives the overridden point value (not the default) when the chore is activated and confirmed

#### 6.2. Modified kindness points awarded on activation ✅

- Child receives the overridden point value when the kindness act is activated and confirmed

#### 6.3. Modified penalty points deducted on activation ✅

- Child loses the overridden point value when the penalty is applied

#### 6.4. Modified reward cost reflected in display ✅

- Points needed shown on the reward card reflects the overridden cost value
