Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified apps/validator/src/lib/report.ts
Binary file not shown.
3 changes: 2 additions & 1 deletion apps/validator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { excerptAt, formatPointer } from "./lib/locate.js";
import {
buildReport,
MAX_SOURCE_BYTES,
recommendationsBlurb,
type DocumentKind,
type Finding,
type Report,
Expand Down Expand Up @@ -515,7 +516,7 @@ function renderReport(report: Report, label: string): void {
renderFindings(
recommendationsBox,
"Recommendations",
"Unmet spec recommendations (SHOULD). The document is still valid; these make it easier to find, filter and subscribe to.",
recommendationsBlurb(report.specVersion),
report.recommendations,
"warn",
);
Expand Down
47 changes: 46 additions & 1 deletion apps/validator/test/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { describe, expect, it } from "vitest";

import { LATEST_VERSION } from "@opentechevents/validate";

import { buildReport, MAX_DEPTH, maxDepth, type Report } from "../src/lib/report.js";
import {
buildReport,
MAX_DEPTH,
maxDepth,
recommendationsBlurb,
type Report,
} from "../src/lib/report.js";

/** Reuses packages/validate's fixtures: one corpus, one opinion of "valid". */
function fixture(name: string): string {
Expand Down Expand Up @@ -215,3 +221,42 @@ describe("buildReport — spec versions", () => {
expect(report.recommendations).toEqual([]);
});
});

// D042: a 1.0 freezes validity, not the recommended profiles. Anything that
// scores or badges on this list has to know which version produced it.
describe("recommendationsBlurb", () => {
it("names the version whose profile produced the list", () => {
expect(recommendationsBlurb("0.6.0")).toContain("OTE 0.6.0's recommended profile");
});

it("warns that the list is not frozen the way validity is", () => {
const blurb = recommendationsBlurb("0.6.0");
expect(blurb).toContain("not frozen");
expect(blurb).toMatch(/add or drop recommendations/);
});

// The recommendations are still SHOULD-level, and saying so is what keeps
// them from reading as errors.
it("keeps the SHOULD framing and the reassurance that the document is valid", () => {
const blurb = recommendationsBlurb("0.6.0");
expect(blurb).toContain("(SHOULD)");
expect(blurb).toContain("still valid");
});

// Unreachable through the UI — no version checked means no recommendations,
// and the box stays hidden — but the sentence must not read "OTE null's".
it("does not invent a version when none was applied", () => {
const blurb = recommendationsBlurb(null);
expect(blurb).not.toContain("null");
expect(blurb).toContain("the recommended profile");
});

// The version shown is the one actually checked, which is not always the
// one the document declares — a hand-picked version has to win here too.
it("reports whichever version was checked", async () => {
const report = validated(
await buildReport(fixture("versioned/event-0.3.0.json"), { version: LATEST_VERSION }),
);
expect(recommendationsBlurb(report.specVersion)).toContain(`OTE ${LATEST_VERSION}`);
});
});
Loading