Commit Graph

14 Commits

Author SHA1 Message Date
weli a2b7825188 Fix course-package:610 flaky — use expect.poll for post-save API check
Replace fixed waitForTimeout(2000) with expect.poll({ timeout: 15_000 })
so the API verification retries until the created package and its item
association are queryable. CI is slower than local, causing false failures.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 22:09:38 +08:00
weli 2f73bea4b6 test: replace flaky login assertions with localStorage JWT check
loginAndGetJwt / loginAsStudent no longer wait 120s for text patterns
that may not appear. Instead they wait for Authorization in localStorage,
which is faster and more reliable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 16:15:54 +08:00
weli 4d594c97ab test(course-package): add picker persistence and edit scenario tests
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 21:10:23 +08:00
weli bc8122f4d4 fix(test): align with create_course_group returning String ID and update merge behavior
- create_course_group returns HtyResponse<String>, d is the UUID directly
- list_course_package_items returns CoursePackageItem with course_group_id field

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 14:58:32 +08:00
weli de058d1e5e test(course-package): add org_visible and course_package_item sync E2E tests
- API test: course_group org_visible toggle (create → visible → list → invisible)
- API test: course_package_item sync with SUPERVISOR permission check
- UI test: "包含课节" picker link on course-package add page
- UI test: "开放给机构" switch on course-group add page

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 14:31:25 +08:00
weli 524c27c278 test(course-package): add music-room frontend UI tests for course-package
Verify: nav link from summary page, list page with tabs/search/add button,
and form fields on add page.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 13:58:44 +08:00
weli 3cf0d2901b test(course-package): simplify teacher UI test with unionid login
Use new ?unionid=X&status=2 login support on teacher.moicen.com
instead of the complex cookie-injection workaround (login on music-room
→ extract JWT → inject into teacher domain via document.cookie).

Also seed course packages to both orgs (慧正书法 + 慧添翼) so the
test works regardless of which org the role chooser selects first.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 12:12:20 +08:00
weli 327fdc60c6 fix(course-package): use document.cookie instead of addCookies for teacher UI test
addCookies uses CDP Storage.setCookies which rejects some JWT cookies with
"Invalid cookie fields" on certain Chromium versions. Switching to
document.cookie bypasses CDP validation entirely.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 11:27:41 +08:00
weli 2688904a5d fix(course-package): fix teacher UI test cookie injection
Read CurrentUserRole from cookies not localStorage. Add cookies with
.moicen.com domain. Navigate directly to /course-packages after
injection so router guard picks up the auth cookie.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 11:00:54 +08:00
weli 527c084942 fix(course-package): inject JWT cookie for teacher app UI test
teacher.moicen.com Nginx has no AuthCore middleware, so ?unionid= login
doesn't work there. Login on music-room first, extract JWT, then inject
HtyTeacherToken/CurrentUserRole cookies + localStorage on teacher domain
before navigating to /course-packages.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 10:50:44 +08:00
weli 27ba562f39 test(course-package): add teacher UI test verifying nav link and page render
Navigate to teacher.moicen.com, verify "课包" nav link is visible for
teacher/supervisor, click through to /course-packages, assert seeded
data renders. Catches frontend build/deploy regressions.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 10:36:20 +08:00
weli 75291986cf test(course-package): verify against seeded data from moicen DB
Add pre-seeded course packages for 阿难 on moicen DB: 钢琴一对一课程,
声乐基础训练, 乐理知识速成 (INACTIVE). Update pagination tests to assert
specific names, ACTIVE filtering, sort order, and INACTIVE exclusion.
Extract shared loginAndGetJwt helper to reduce duplication.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 08:58:15 +08:00
weli 894ca05566 fix(course-package): extract role_key from JWT sub roles objects
JWT sub.roles is an array of objects with role_key field, not plain
strings. Fix extractRoleKeys to map role_key from each role object.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 08:41:54 +08:00
weli 1ddeb21ca7 test(course-package): add API CRUD, pagination, and role permission tests
Verify course_package endpoints are only accessible to TEACHER/SUPERVISOR
roles. Test full CRUD cycle and paginated listing APIs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 08:31:04 +08:00