feat(profile): production-ready profile block (avatar S3, i18n, +87 tests, UTC fix)#289
Open
abdout wants to merge 2 commits into
Open
feat(profile): production-ready profile block (avatar S3, i18n, +87 tests, UTC fix)#289abdout wants to merge 2 commits into
abdout wants to merge 2 commits into
Conversation
…ontribution map, +87 tests Block-level fixes - Avatar upload: was a no-op stub returning fake success; now persists via the shared S3 pipeline (file/upload/actions::uploadFile) with MIME and 5MB caps. - updateProfileSettings: same lie (validated then no-op write); now returns NOT_IMPLEMENTED until the User schema gains settings columns. - Contribution graph timezone bug: getYearDateRange used local-time new Date(year, 0, 1) while formatDateKey was UTC, shifting Jan 1 to Dec 31 in any positive UTC offset (Riyadh +3 etc.). Switched the helper to Date.UTC + setUTCDate so the calendar is timezone-stable. - Added viewerPermission (OWNER/ADMIN/STAFF/RELATED/PUBLIC) to getProfileBasicData so the UI can mask emailAddress/employeeId for non-admins. - Replaced hardcoded English error strings in edit-role-actions.ts and detail/actions.ts with action error codes (i18n compliance). - Removed dead Octicon icon-reference grid that was leaking debug UI into the profile overview tab. - Documented detail/actions.ts as foundation code for a future admin user-detail page (currently dead, kept intentionally). Tests (5 → 92) - __tests__/actions.test.ts: rewrote weak prisma-mock smoke tests into 35 real tests covering auth/tenant gates, schoolId scoping, role mapping, pinned items, activity logging, viewerPermission flagging. - __tests__/validation.test.ts (new, 22): every Zod schema + edge cases. - __tests__/contribution.test.ts (new, 12): year validation, leap-year day count, activity aggregation, streak math, missing-role-record path. - detail/__tests__/permissions.test.ts (new, 23): full RBAC matrix. - tests/e2e/profile/profile-flows.spec.ts (new, 6 specs): own profile, edit form, view-other, auth gate, teacher self-service. Infra - Added NOT_IMPLEMENTED to ACTION_ERRORS for honest stub responses. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…code Self-QA caught one missed translation leak in updatePinnedItems: "Maximum 6 pinned items allowed" → VALIDATION_ERROR + MAX_PINNED_EXCEEDED detail. Strengthens the corresponding test to assert both error code and detail. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| return `http://${host}/en/profile` | ||
| } | ||
|
|
||
| function profileForId(userId: string, host = DEMO_HOST) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Production-ready profile block work, isolated from
feat/cdn-cname-migration(PR #272) which is blocked on CNAME verification.file/upload/actions::uploadFile) with MIME validation and 5 MB cap.updateProfileSettings: same lie (validated then no-op write) — now returnsNOT_IMPLEMENTEDuntil the User schema gains settings columns.getYearDateRangeused local-timenew Date(year, 0, 1)whileformatDateKeywas UTC, shifting Jan 1 to Dec 31 in any positive UTC offset (Riyadh +3 etc.). Switched the helper toDate.UTC+setUTCDateso the calendar is timezone-stable.viewerPermission(OWNER/ADMIN/STAFF/RELATED/PUBLIC) added togetProfileBasicDataso the UI can maskemailAddress/employeeIdfor non-admins.edit-role-actions.ts,detail/actions.ts, andactions.ts(updatePinnedItems"Maximum 6...") with action error codes.detail/actions.tsas foundation code for a future admin user-detail page.Tests (5 → 92)
__tests__/actions.test.ts: rewrote weak prisma-mock smoke tests into 35 real tests (auth/tenant gates, schoolId scoping, role mapping, pinned items, activity logging, viewerPermission flagging).__tests__/validation.test.ts(new, 22): every Zod schema + edge cases.__tests__/contribution.test.ts(new, 12): year validation, leap-year day count, activity aggregation, streak math, missing-role-record path.detail/__tests__/permissions.test.ts(new, 23): full RBAC matrix.tests/e2e/profile/profile-flows.spec.ts(new, 6 specs): own profile, edit form, view-other, auth gate, teacher self-service.Self-QA verdict (PASS)
Promise.allfor parallel fetches@/components/uior@/components/atomunstable_cache(300s TTL) on contribution graphTest plan
pnpm tsc --noEmit— 0 errorspnpm vitest run src/components/school-dashboard/profile— 92/92 passinged.databayt.org200,demo.databayt.org/en/profile200see/flow/lang/check) — pending browser MCP reconnectiondemo.databayt.org/en/profilepost-mergeInfra
NOT_IMPLEMENTEDtoACTION_ERRORSfor honest stub responses.🤖 Generated with Claude Code