Files
Reactive-Resume/packages/resume/src/section-sort.test.ts
T
Amruth Pillai c0c7984712 test: keep only the tests that guard real breakage
Prune the unit and e2e suites to what protects security, user data, public
contracts and past regressions. Drop what slowed development without catching
bugs: markup and label assertions, wrappers that only proved Base UI works,
copied inventories and snapshots, mock call-shape checks, permutation matrices
across templates, fonts and locales, and env-gated suites that never ran in CI.

- Unit: 4749 tests in 421 files become 1212 in 227. PDF tests that rendered or
  rasterized every template, font and locale combination go; one render per
  template stays and now checks that every visible section reaches a page,
  which a blank page used to pass.
- E2E: 55 tests in 35 specs become 11 in 9, one journey per severe area: sign-up
  and sign-in, autosave, a failed save during navigation, JSON export and import,
  public and password-protected sharing, slug redirects, OAuth consent for MCP
  clients, and the assistant.
- Tests a coverage review found to be the only guard of a contract were kept or
  restored, each checked by breaking the code it guards.
- Remove exports, tooling and dev dependencies that only the pruned tests used.
- The Semantic CSS guide check now reads indented code fences, so the guide
  example it skipped is compiled too.
2026-09-29 22:31:45 +02:00

65 lines
2.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { sortSectionItemsByPeriod } from "./section-sort";
type Item = {
id: string;
period: string;
};
const item = (id: string, period: string): Item => ({ id, period });
const ids = (items: readonly Item[]) => items.map(({ id }) => id);
describe("sortSectionItemsByPeriod", () => {
it("orders ongoing, ended, equal, and unresolved periods by the documented total order", () => {
const equalFirst = item("equal-first", "2020 - 2023");
const equalSecond = item("equal-second", "2020 - 2023");
const input = [
item("blank", ""),
equalFirst,
item("ended-2024", "2020 - 2024"),
item("ongoing-2020", "2020 - Present"),
item("prose", "A long time ago"),
item("ended-2025", "2022 - 2025"),
equalSecond,
item("ongoing-2024", "January 2024 - Present"),
item("reversed", "2025 - 2024"),
];
const result = sortSectionItemsByPeriod(input, "en-US");
expect(ids(result.items)).toEqual([
"ongoing-2024",
"ongoing-2020",
"ended-2025",
"ended-2024",
"equal-first",
"equal-second",
"blank",
"prose",
"reversed",
]);
expect(result.unresolvedIds).toEqual(["blank", "prose", "reversed"]);
});
it("uses locale-aware months and ranks year precision below a known month in the same year", () => {
const input = [
item("year-only-end", "2020 - 2024"),
item("localized-march", "janvier 2020 - mars 2024"),
item("localized-february", "janvier 2020 - février 2024"),
];
const result = sortSectionItemsByPeriod(input, "fr-FR");
expect(ids(result.items)).toEqual(["localized-march", "localized-february", "year-only-end"]);
expect(result.unresolvedIds).toEqual([]);
});
it("ranks missing end points after known end points, then compares known starts", () => {
const input = [item("single-2025", "2025"), item("ended-2020", "2019 - 2020"), item("single-2024", "2024")];
const result = sortSectionItemsByPeriod(input, "en-US");
expect(ids(result.items)).toEqual(["ended-2020", "single-2025", "single-2024"]);
});
});