hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { describe, expect, it } from "vitest"; |
| 2 | import { studentInfoSource } from "./student-info-access"; |
| 3 | |
| 4 | const student = { id: "s1", role: "student" as const }; |
| 5 | |
| 6 | describe("studentInfoSource", () => { |
| 7 | it("lets the student see their own info", () => { |
| 8 | expect(studentInfoSource({ id: "s1", role: "student" }, student)).toBe("self"); |
| 9 | }); |
| 10 | |
| 11 | it("hides it from another student", () => { |
| 12 | expect(studentInfoSource({ id: "s2", role: "student" }, student)).toBeNull(); |
| 13 | }); |
| 14 | |
| 15 | it("opens it to staff, admin reading the full record", () => { |
| 16 | expect(studentInfoSource({ id: "a", role: "admin" }, student)).toBe("admin"); |
| 17 | expect(studentInfoSource({ id: "m", role: "manager" }, student)).toBe("staff"); |
| 18 | expect(studentInfoSource({ id: "t", role: "teacher" }, student)).toBe("staff"); |
| 19 | }); |
| 20 | |
| 21 | it("opens it to a parent (the profile is already a 403 for unlinked ones)", () => { |
| 22 | expect(studentInfoSource({ id: "p", role: "parent" }, student)).toBe("parent"); |
| 23 | }); |
| 24 | |
| 25 | it("never shows on a non-student profile or without a session", () => { |
| 26 | expect(studentInfoSource({ id: "a", role: "admin" }, { id: "t", role: "teacher" })).toBeNull(); |
| 27 | expect(studentInfoSource({ id: "t", role: "teacher" }, { id: "t", role: "teacher" })).toBeNull(); |
| 28 | expect(studentInfoSource(null, student)).toBeNull(); |
| 29 | }); |
| 30 | }); |