mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-20 21:41:43 +10:00
* fix(import): auto-detect JSON format and show readable errors (#1) Readable import errors, a fail-soft v4 parser, and auto-detect of the JSON format so uploads just work. The format dropdown becomes an optional override. PDF and DOCX (AI) paths are untouched. * fix(import): address review feedback on the v4 guard and error message - reactive-resume-v4-json.tsx: reject arrays in isRecord so array-valued basics, sections, or metadata no longer pass the v4 shape guard. - reactive-resume-v4-json.tsx: reuse the guard's error instance in the catch arm instead of allocating a duplicate NOT_V4_MESSAGE. - error.ts: use a singular "Problem" label for root-level Zod issues so the message stays grammatical. - add a regression test for array-valued v4 branches. * fix(import): preserve selected JSON format * test(import): cover selected JSON parser --------- Co-authored-by: MrTig-afk <MrTig-afk@users.noreply.github.com> Co-authored-by: Amruth Pillai <im.amruth@gmail.com>
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { detectJsonImportType } from "./import.utils";
|
|
|
|
describe("detectJsonImportType", () => {
|
|
it("detects JSON Resume by a top-level basics without Reactive Resume sections/metadata", () => {
|
|
expect(detectJsonImportType({ basics: { name: "A" }, work: [] })).toBe("json-resume-json");
|
|
});
|
|
|
|
it("detects the current Reactive Resume schema by metadata.page", () => {
|
|
expect(detectJsonImportType({ basics: {}, sections: {}, metadata: { page: { locale: "en-US" } } })).toBe(
|
|
"reactive-resume-json",
|
|
);
|
|
});
|
|
|
|
it("detects the legacy v4 schema by metadata without a page key", () => {
|
|
expect(detectJsonImportType({ basics: {}, sections: {}, metadata: { template: "azurill" } })).toBe(
|
|
"reactive-resume-v4-json",
|
|
);
|
|
});
|
|
|
|
it("returns an empty string for unrecognized shapes", () => {
|
|
expect(detectJsonImportType({})).toBe("");
|
|
expect(detectJsonImportType({ foo: "bar" })).toBe("");
|
|
expect(detectJsonImportType(null)).toBe("");
|
|
expect(detectJsonImportType("nope")).toBe("");
|
|
});
|
|
});
|