feat: enhance testing capabilities and introduce new components for question management. Add testing section in AGENTS.md with instructions for running tests and configuring the test environment. Update package.json files to include test scripts and integrate @electric-sql/pglite for in-memory database testing. Introduce CalloutCard and update FilterBar and SoalBrowser components to support visibility filters for private and public questions. Implement new test cases for various functionalities across the application.
92a1d83 | import { describe, expect, it } from "bun:test"; | |
| import { | |
| EXAM_TYPES, | |
| SECTIONS, | |
| FORMATS, | |
| TOPICS, | |
| DIFFICULTIES, | |
| QUESTION_COUNT_PRESETS, | |
| } from "../generate-constants"; | |
| describe("EXAM_TYPES", () => { | |
| it("has 8 exam types", () => { | |
| expect(EXAM_TYPES).toHaveLength(8); | |
| }); | |
| it("each entry has id, name, and code", () => { | |
| for (const exam of EXAM_TYPES) { | |
| expect(exam).toHaveProperty("id"); | |
| expect(exam).toHaveProperty("name"); | |
| expect(exam).toHaveProperty("code"); | |
| } | |
| }); | |
| it("has no duplicate IDs", () => { | |
| const ids = EXAM_TYPES.map((e) => e.id); | |
| expect(new Set(ids).size).toBe(ids.length); | |
| }); | |
| }); | |
| describe("SECTIONS", () => { | |
| it("has 2 sections with id, name, and icon", () => { | |
| expect(SECTIONS).toHaveLength(2); | |
| for (const s of SECTIONS) { | |
| expect(s).toHaveProperty("id"); | |
| expect(s).toHaveProperty("name"); | |
| expect(s).toHaveProperty("icon"); | |
| } | |
| }); | |
| }); | |
| describe("FORMATS", () => { | |
| it("has 20 question formats", () => { | |
| expect(FORMATS).toHaveLength(20); | |
| }); | |
| it("each format has id, name, and allowedExams", () => { | |
| for (const f of FORMATS) { | |
| expect(f).toHaveProperty("id"); | |
| expect(f).toHaveProperty("name"); | |
| expect(f).toHaveProperty("allowedExams"); | |
| expect(Array.isArray(f.allowedExams)).toBe(true); | |
| } | |
| }); | |
| it("no duplicate format IDs", () => { | |
| const ids = FORMATS.map((f) => f.id); | |
| expect(new Set(ids).size).toBe(ids.length); | |
| }); | |
| }); | |
| describe("TOPICS", () => { | |
| it("has at least one topic", () => { | |
| expect(TOPICS.length).toBeGreaterThanOrEqual(1); | |
| }); | |
| it("all topics are strings", () => { | |
| for (const t of TOPICS) { | |
| expect(typeof t).toBe("string"); | |
| } | |
| }); | |
| }); | |
| describe("DIFFICULTIES", () => { | |
| it("has 5 difficulty strings", () => { | |
| expect(DIFFICULTIES).toHaveLength(5); | |
| }); | |
| }); | |
| describe("QUESTION_COUNT_PRESETS", () => { | |
| it("has 4 presets", () => { | |
| expect(QUESTION_COUNT_PRESETS).toHaveLength(4); | |
| }); | |
| it("each preset has value, label, and desc", () => { | |
| for (const p of QUESTION_COUNT_PRESETS) { | |
| expect(p).toHaveProperty("value"); | |
| expect(p).toHaveProperty("label"); | |
| expect(p).toHaveProperty("desc"); | |
| } | |
| }); | |
| }); | |