feat: add Daily Digest and Push Notifications toggles to User Profile with corresponding functionality
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m4s
Some checks failed
Chore App Build, Test, and Push Docker Images / build-and-push (push) Failing after 2m4s
This commit is contained in:
@@ -537,19 +537,102 @@ This allows a spec to simulate notification action clicks without OS interaction
|
||||
|
||||
---
|
||||
|
||||
### 10. User Profile Notification Settings
|
||||
|
||||
**File:** `e2e/mode_parent/notifications/user-profile-notification-settings.spec.ts`
|
||||
|
||||
**Seed:** No child/task setup required. Tests navigate directly to the User Profile page. No `afterAll` cleanup beyond any push subscription state left by the tests (handled internally by `beforeEach`/`afterEach` where needed).
|
||||
|
||||
#### 10.1. Email Digest toggle is visible on User Profile page
|
||||
|
||||
- Navigate to `/parent/profile` (or the route that renders `UserProfile.vue`)
|
||||
- expect: An element with the label text "Daily Digest" is visible
|
||||
|
||||
#### 10.2. Email Digest toggle initialises from the server value
|
||||
|
||||
- Via authenticated `request`, call `PUT /api/user/profile` with `{ email_digest_enabled: true }` to set a known state
|
||||
- Navigate to `/parent/profile`
|
||||
- expect: The Daily Digest toggle is checked/on
|
||||
- Via authenticated `request`, call `PUT /api/user/profile` with `{ email_digest_enabled: false }`
|
||||
- Reload the page
|
||||
- expect: The Daily Digest toggle is unchecked/off
|
||||
|
||||
#### 10.3. Toggling Email Digest off calls the correct API
|
||||
|
||||
- Via `request`, ensure `email_digest_enabled` is `true` before the test
|
||||
- Navigate to `/parent/profile`
|
||||
- Intercept `PUT /api/user/profile` with `page.route()`
|
||||
- Click the Daily Digest toggle to switch it off
|
||||
- expect: Intercepted PUT body contains `email_digest_enabled: false`
|
||||
- expect: Toggle visually reflects the off state
|
||||
|
||||
#### 10.4. Toggling Email Digest on calls the correct API
|
||||
|
||||
- Via `request`, ensure `email_digest_enabled` is `false` before the test
|
||||
- Navigate to `/parent/profile`
|
||||
- Intercept `PUT /api/user/profile` with `page.route()`
|
||||
- Click the Daily Digest toggle to switch it on
|
||||
- expect: Intercepted PUT body contains `email_digest_enabled: true`
|
||||
- expect: Toggle visually reflects the on state
|
||||
|
||||
#### 10.5. Push Notifications toggle is visible on User Profile page
|
||||
|
||||
- Navigate to `/parent/profile`
|
||||
- expect: An element with the label text "Push Notifications" is visible
|
||||
|
||||
#### 10.6. Push Notifications toggle initialises to off when no subscription exists
|
||||
|
||||
- Do NOT call `page.context().grantPermissions(['notifications'])` (leave default denied/prompt)
|
||||
- Navigate to `/parent/profile`
|
||||
- expect: The Push Notifications toggle is unchecked/off
|
||||
|
||||
#### 10.7. Push Notifications toggle initialises to on when a subscription already exists
|
||||
|
||||
- Call `page.context().grantPermissions(['notifications'])` before navigation
|
||||
- Intercept `POST /api/push-subscription` and respond `200 OK` (to avoid real push registration)
|
||||
- Navigate to `/parent/tasks/chores` first (triggers `ParentLayout` subscription POST)
|
||||
- Then navigate to `/parent/profile`
|
||||
- expect: The Push Notifications toggle is checked/on
|
||||
|
||||
#### 10.8. Push Notifications toggle is disabled when browser permission is denied
|
||||
|
||||
- Call `page.context().clearPermissions()` then navigate to `/parent/profile` with notifications permission absent (or set to `'denied'` if Playwright supports it)
|
||||
- expect: The Push Notifications toggle input is disabled (`aria-disabled` or `disabled` attribute set)
|
||||
|
||||
#### 10.9. Enabling Push Notifications toggle subscribes and posts to backend
|
||||
|
||||
- Call `page.context().grantPermissions(['notifications'])`
|
||||
- Intercept `POST /api/push-subscription` to capture the request and respond `200 OK`
|
||||
- Navigate to `/parent/profile`; ensure toggle starts off (no prior subscription)
|
||||
- Click the Push Notifications toggle to turn it on
|
||||
- expect: `POST /api/push-subscription` is called with a non-empty `endpoint` and `keys`
|
||||
- expect: Toggle visually reflects the on state
|
||||
|
||||
#### 10.10. Disabling Push Notifications toggle unsubscribes and sends DELETE to backend
|
||||
|
||||
- Set up a push subscription (grant permissions, intercept POST on `/parent/tasks/chores` to get a subscription in place)
|
||||
- Navigate to `/parent/profile`; toggle should be on
|
||||
- Intercept `DELETE /api/push-subscription` with `page.route()`
|
||||
- Click the Push Notifications toggle to turn it off
|
||||
- expect: `DELETE /api/push-subscription` is called
|
||||
- expect: Toggle visually reflects the off state
|
||||
|
||||
---
|
||||
|
||||
## Test Summary
|
||||
|
||||
| # | Group | Spec File(s) | Test Cases |
|
||||
| --- | --------------------------------- | -------------------------------------- | ---------- |
|
||||
| 1 | Push subscription registration | `push-subscription.spec.ts` | 5 |
|
||||
| 2 | Chore notification — approve flow | `chore-notification-approve.spec.ts` | 8 |
|
||||
| 3 | Chore notification — reject flow | `chore-notification-deny.spec.ts` | 5 |
|
||||
| 4 | Reward notification — grant flow | `reward-notification-approve.spec.ts` | 7 |
|
||||
| 5 | Reward notification — deny flow | `reward-notification-deny.spec.ts` | 6 |
|
||||
| 6 | ParentView deep-link navigation | `deep-link-navigation.spec.ts` | 7 |
|
||||
| 7 | Digest token — happy paths | 4 spec files (one per `entity×action`) | 8 |
|
||||
| 8 | Digest token — error paths | `digest-action-errors.spec.ts` | 5 |
|
||||
| 9 | SW push — manual/mock | (no spec file) | checklist |
|
||||
| # | Group | Spec File(s) | Test Cases |
|
||||
| --- | --------------------------------- | -------------------------------------------- | ---------- |
|
||||
| 1 | Push subscription registration | `push-subscription.spec.ts` | 5 |
|
||||
| 2 | Chore notification — approve flow | `chore-notification-approve.spec.ts` | 8 |
|
||||
| 3 | Chore notification — reject flow | `chore-notification-deny.spec.ts` | 5 |
|
||||
| 4 | Reward notification — grant flow | `reward-notification-approve.spec.ts` | 7 |
|
||||
| 5 | Reward notification — deny flow | `reward-notification-deny.spec.ts` | 6 |
|
||||
| 6 | ParentView deep-link navigation | `deep-link-navigation.spec.ts` | 7 |
|
||||
| 7 | Digest token — happy paths | 4 spec files (one per `entity×action`) | 8 |
|
||||
| 8 | Digest token — error paths | `digest-action-errors.spec.ts` | 5 |
|
||||
| 9 | SW push — manual/mock | (no spec file) | checklist |
|
||||
| 10 | User Profile notification toggles | `user-profile-notification-settings.spec.ts` | 10 |
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user