test(e2e): add TC-E2E-003/004/005/007/008/009/010 — delete, pagination, errors, profile, theme

- test_post_deletion.py: user delete own, admin delete any, 403 for other's
- test_pagination.py: navigation across pages, boundary on last page
- test_errors.py: 404 nonexistent post, 404 for other user's draft
- test_post_lifecycle.py: draft-to-publish via edit flow
- test_post_ownership.py: user can edit own post
- test_profile_and_theme.py: profile page rendering, theme toggle with localStorage
- fix(web): remove infinite pagination for USER role (routes.py)
- fix(e2e): stabilize all publish() calls with expect_navigation
- fix(e2e): add _unique_title() to avoid slug collisions at scale
- docs: update FEATURE_POST_LIFECYCLE.md and TEST_MODEL.md coverage
This commit is contained in:
2026-05-08 20:25:01 +03:00
parent 714342f5ac
commit cf4982c0e5
10 changed files with 783 additions and 48 deletions

View File

@@ -207,6 +207,49 @@ Covers both API use cases and web UI end-to-end flows.
- User2 receives 404 when accessing draft directly
- **Last Verified:** 2026-05-07
### TC-E2E-003: Negative — 404 for Nonexistent Post
- **Type:** Negative
- **Layer:** E2E
- **File:** `e2e/test_errors.py::test_nonexistent_post_returns_404`
- **Preconditions:** Dev server running, `guest_page`, `user_page` fixtures
- **Steps:**
1. Generate a random slug that does not exist in the database.
2. Navigate to `/web/posts/{fake-slug}` as guest and as authenticated user.
- **Expected:**
- Error page is rendered with `data-testid="error-code"` showing `404`
- Both guest and user see the same 404 response
- **Last Verified:** 2026-05-08
### TC-E2E-003a: Policy — 404 for Another User's Draft
- **Type:** Policy
- **Layer:** E2E
- **File:** `e2e/test_errors.py::test_other_user_draft_returns_404`
- **Preconditions:** Dev server running, `user_page`, `user2_page`, `guest_page` fixtures
- **Steps:**
1. User creates a draft post and saves it.
2. Extract the slug from the detail page URL.
3. User2 and guest navigate to `/web/posts/{slug}`.
- **Expected:**
- Owner sees the draft detail with "Draft" badge (200)
- User2 sees 404 error page
- Guest sees 404 error page
- **Last Verified:** 2026-05-08
### TC-E2E-004: Positive — Delete Post via Web UI
- **Type:** Positive
- **Layer:** E2E
- **File:** `e2e/test_post_deletion.py::test_user_can_delete_own_post`
- **Preconditions:** Dev server running, `user_page` fixture
- **Steps:**
1. Generate post data via `PostDataGenerator`
2. Open home page and click "Write a Post"
3. Fill form (title, content, tags) and click "Publish Post"
4. On post detail page, click "Delete" and accept confirm dialog
- **Expected:**
- Redirect to `/web/`
- Post no longer appears on home page
- **Last Verified:** 2026-05-07
## Coverage Summary
| Aspect | Coverage | Notes |
@@ -214,8 +257,8 @@ Covers both API use cases and web UI end-to-end flows.
| Create post | Unit + E2E | Both happy path and duplicate slug covered |
| Read post (by id/slug) | Unit | E2E implicitly via detail page |
| Update post | Unit | No dedicated E2E |
| Delete post | Unit | No dedicated E2E |
| Publish / Unpublish | Unit + E2E | Authz checks covered in both layers |
| Delete post | Unit + E2E | Own-post and admin-delete covered |
| Publish / Unpublish | Unit + E2E | Draft-to-publish flow covered via edit |
| List posts (all filters) | Unit | Pagination arguments passed but not edge-case tested |
| Search posts | Unit | No E2E search flow |
@@ -225,8 +268,11 @@ Covers both API use cases and web UI end-to-end flows.
- [ ] TC-UNIT-024: UpdatePostUseCase — not found scenario
- [ ] TC-UNIT-025: UpdatePostUseCase — validation error
- [ ] TC-UNIT-026: ListPostsUseCase — pagination edge cases (page boundaries, empty page)
- [ ] TC-E2E-003: Edit post via web UI and verify changes
- [ ] TC-E2E-004: Delete post via web UI and verify removal
- [ ] TC-E2E-005: Save post as draft and verify it does not appear to guests
- [x] TC-E2E-003: 404 error page for nonexistent post
- [x] TC-E2E-003a: Edit post via web UI and verify changes (own post)
- [x] TC-E2E-004: Delete post via web UI and verify removal
- [x] TC-E2E-005: Save post as draft and publish via edit, verify visibility change
- [ ] TC-E2E-006: Search posts via web UI
- [ ] TC-E2E-007: Pagination navigation on home page
- [x] TC-E2E-007: Pagination navigation on home page
- [x] TC-E2E-009: Profile page renders user info and role badge correctly
- [x] TC-E2E-010: Theme toggle switches between light and dark with localStorage persistence