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
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ describe("ExperimentResultsComparison ordering and states", () => {
expect(text).toContain("Confidence interval unavailable");
});

it("does not format estimates or differences without the Metric type", () => {
it("does not format estimates or differences when the Metric is missing from the catalog", () => {
const text = visibleText(
renderToStaticMarkup(
<ExperimentResultsComparison
results={resultsFixture(statsWithAnalysisControl())}
run={runFixture()}
metrics={[{ id: "checkout_conversion", name: "Checkout conversion" }]}
metrics={[]}
baseline="control"
variantOrder={["control", "treatment"]}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const ExperimentConclusionDialog = lazy(() =>
})),
);

import type { Metric } from "@splitch/contracts";
import type { PanelExperimentRun } from "@splitch/control-plane-sdk/panel-experiments";
import { useSuspenseQuery } from "@tanstack/react-query";
import {
Expand All @@ -16,6 +15,7 @@ import {
ExperimentResultsWaiting,
} from "#components/experiments/experiment-results";
import { experimentResultsQuery } from "#lib/experiments/experiments-query";
import type { ComparisonMetric } from "#lib/experiments/metric-comparison-rows";

/**
* Route-facing wrapper: resolves the Run to read, then renders it.
Expand Down Expand Up @@ -43,7 +43,7 @@ export function ExperimentResultsPanel({
flagId: string;
environmentId: string;
experimentId: string;
metrics: readonly Pick<Metric, "id" | "name">[];
metrics: readonly ComparisonMetric[];
run: PanelExperimentRun | undefined;
}) {
if (!run) return <ExperimentResultsEmpty />;
Expand Down Expand Up @@ -77,7 +77,7 @@ function ExperimentResultsForRun({
flagId: string;
environmentId: string;
experimentId: string;
metrics: readonly Pick<Metric, "id" | "name">[];
metrics: readonly ComparisonMetric[];
run: PanelExperimentRun;
}) {
const [concluding, setConcluding] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
PanelExperimentResultsReady,
PanelExperimentRun,
} from "@splitch/control-plane-sdk/panel-experiments";
import type { ComparisonMetric } from "#lib/experiments/metric-comparison-rows";

/**
* Panel fixtures built the way the Worker builds the payload: the gate is
Expand Down Expand Up @@ -251,10 +252,10 @@ export function resultsNoDataFixture(
}

/** Catalog rows for the Metric ids the stats fixtures use, as the detail read returns them. */
export function metricsFixture(): { id: string; name: string }[] {
export function metricsFixture(): ComparisonMetric[] {
return [
{ id: "checkout_conversion", name: "Checkout conversion" },
{ id: "checkout_latency_p95", name: "Checkout latency p95" },
{ id: "checkout_conversion", name: "Checkout conversion", kind: "binomial", direction: null },
{ id: "checkout_latency_p95", name: "Checkout latency p95", kind: "count", direction: null },
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { type MetricNames, metricDisplayName, metricNamesById } from "./metric-n
* arrive computed.
*/

export type ComparisonMetric = Pick<Metric, "id" | "name"> &
Partial<Pick<Metric, "kind" | "direction">>;
export type ComparisonMetric = Pick<Metric, "id" | "name" | "kind" | "direction">;

export type MetricComparisonRole = "decision" | "guardrail" | "exploratory";

Expand Down
20 changes: 9 additions & 11 deletions apps/marketing/src/docs/markdown-route.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { quickstartMarkdown } from "./markdown";
import { markdownForPath, staticMarkdownPaths } from "./markdown-route";
import { staticPagePaths } from "./sitemap";
import { markdownForPath } from "./markdown-route";
import { canonicalPageUrls, staticPagePaths } from "./sitemap";

function markdownUrlForPage(path: string): string {
if (path === "/") return "/.md";
Expand Down Expand Up @@ -32,16 +32,14 @@ describe("markdownForPath", () => {
expect(markdown).toMatch(/^# Zero to a resolving Flag/m);
});

it("serves the .md suffix for every static HTML page, including top-level ones", () => {
const topLevelHtmlPages = staticPagePaths.filter((path) => !path.startsWith("/docs"));
expect(topLevelHtmlPages).toEqual(["/", "/quickstart"]);
expect(staticMarkdownPaths).toContain("/quickstart");
expect(staticMarkdownPaths.filter((path) => !path.startsWith("/docs"))).toEqual([
"/",
"/quickstart",
]);
it("serves the .md suffix for every canonical HTML page, including top-level ones", () => {
// The Worker answers `<page>.md` before the router runs, so this is the
// only guard that a new page ships with its markdown twin.
const pages = canonicalPageUrls.map((href) => new URL(href).pathname);
expect(pages.filter((path) => !path.startsWith("/docs"))).toEqual(["/", "/quickstart"]);
expect(pages.length).toBeGreaterThan(staticPagePaths.length);

for (const path of staticMarkdownPaths) {
for (const path of pages) {
const markdown = markdownForPath(path);
expect(markdown, path).not.toBeNull();
expect(markdownForPath(markdownUrlForPage(path)), markdownUrlForPage(path)).toBe(markdown);
Expand Down
2 changes: 0 additions & 2 deletions apps/marketing/src/docs/markdown-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ const staticMarkdown = new Map<string, () => string>([
["/docs/errors", errorIndexMarkdown],
]);

export const staticMarkdownPaths = [...staticMarkdown.keys()] as const;

export function markdownForPath(pathname: string): string | null {
const documentPath = htmlPathForMarkdownUrl(pathname);
const staticDocument = staticMarkdown.get(documentPath);
Expand Down
Loading
Loading