-
Notifications
You must be signed in to change notification settings - Fork 73
Add educator verification history timeline #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zeemscript
merged 6 commits into
Deen-Bridge:main
from
Baytizz:fix/237-educator-verification-history
Aug 31, 2026
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9e34d5a
feat: add educator verification history timeline
Baytizz a3f925f
fix: prevent stale verification history updates
Baytizz a859d03
Merge upstream main into verification history branch
Obaara293 e57d4f8
Merge main into fix/237-educator-verification-history
Baytizz 246081f
Merge main into educator verification history branch
Baytizz 8bea2c0
Fix AI dashboard page export
Baytizz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
96 changes: 96 additions & 0 deletions
96
__tests__/admin/admin-verification-history.service.test.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import { describe, it, expect, vi, beforeEach } from "vitest"; | ||
|
|
||
| const mockAxios = vi.hoisted(() => ({ | ||
| get: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("@/lib/config/axios.config", () => ({ | ||
| default: mockAxios, | ||
| })); | ||
|
|
||
| import { | ||
| composeVerificationHistoryFromUser, | ||
| fetchEducatorVerificationHistory, | ||
| } from "@/lib/actions/admin-verification-history"; | ||
|
|
||
| describe("admin verification history service", () => { | ||
| beforeEach(() => { | ||
| mockAxios.get.mockReset(); | ||
| }); | ||
|
|
||
| it("uses backend verification events when the endpoint is available", async () => { | ||
| mockAxios.get.mockResolvedValue({ | ||
| data: { | ||
| events: [ | ||
| { | ||
| id: "evt_1", | ||
| type: "approved", | ||
| actor: { name: "Admin reviewer" }, | ||
| timestamp: "2026-01-03T12:00:00.000Z", | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| const result = await fetchEducatorVerificationHistory("usr_1", {}); | ||
|
|
||
| expect(mockAxios.get).toHaveBeenCalledWith( | ||
| "/api/admin/educators/usr_1/verification-history" | ||
| ); | ||
| expect(result.source).toBe("backend"); | ||
| expect(result.events[0]).toMatchObject({ | ||
| type: "approved", | ||
| actor: "Admin reviewer", | ||
| label: "Approved", | ||
| }); | ||
| }); | ||
|
|
||
| it("composes newest-first fallback events from educator record fields", async () => { | ||
| mockAxios.get.mockRejectedValue(new Error("Not found")); | ||
|
|
||
| const result = await fetchEducatorVerificationHistory("usr_2", { | ||
| email: "educator@example.com", | ||
| verification: { | ||
| submittedAt: "2026-01-01T09:00:00.000Z", | ||
| infoRequestedAt: "2026-01-02T09:00:00.000Z", | ||
| approvedAt: "2026-01-03T09:00:00.000Z", | ||
| reviewedBy: "Amina Admin", | ||
| infoRequestReason: "Certificate scan was unclear.", | ||
| }, | ||
| }); | ||
|
|
||
| expect(result.source).toBe("composed"); | ||
| expect(result.events.map((event) => event.type)).toEqual([ | ||
| "approved", | ||
| "info_requested", | ||
| "submitted", | ||
| ]); | ||
| expect(result.events[1].note).toBe("Certificate scan was unclear."); | ||
| }); | ||
|
|
||
| it("normalizes explicit history arrays from the user record", () => { | ||
| const events = composeVerificationHistoryFromUser({ | ||
| verificationHistory: [ | ||
| { type: "submitted", timestamp: "2026-01-01T00:00:00Z", actor: "Educator" }, | ||
| { type: "re_verified", timestamp: "2026-01-04T00:00:00Z", actor: "Admin" }, | ||
| ], | ||
| }); | ||
|
|
||
| expect(events).toHaveLength(2); | ||
| expect(events[0].type).toBe("re_verified"); | ||
| expect(events[0].label).toBe("Re-verified"); | ||
| }); | ||
|
|
||
| it("does not treat a generic review timestamp as rejection for an approved record", () => { | ||
| const events = composeVerificationHistoryFromUser({ | ||
| verification: { | ||
| status: "approved", | ||
| submittedAt: "2026-01-01T00:00:00Z", | ||
| reviewedAt: "2026-01-02T00:00:00Z", | ||
| approvedAt: "2026-01-02T00:00:00Z", | ||
| }, | ||
| }); | ||
|
|
||
| expect(events.map((event) => event.type)).toEqual(["approved", "submitted"]); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not compose history from the hard-coded fallback user.
If
getUserById(userId)returnsnullor nouser, this flow uses the hard-coded educator record.fetchEducatorVerificationHistorythen composes submitted and approved events from that record when its endpoint request fails. The page can display Amina Yusuf's fabricated audit history for the requesteduserId.Treat a missing user response as an error or not-found state. Skip the history request in that case.
🤖 Prompt for AI Agents