fix(reference): move the detail route under items/ (08-13)

The detail path /examples/reference-resources/:resourceId lost to the static
new and status routes, so an item with one of those ids opened the wrong
screen. The breaking route change carries registry evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-27 13:09:06 +09:00
co-authored by Claude Opus 5.5
parent cef6744299
commit d7b81c633d
5 changed files with 43 additions and 4 deletions
@@ -104,6 +104,14 @@
"compatibilityWindow": "No wire, storage or runtime-config format changes: the old id was never emitted by any producer, so no consumer could observe it.",
"rollback": "Restore the previous telemetryEvent string on QUERY_CACHE_FAILURE in src/contracts/errors.ts and widen ErrorObservationEvent back to string.",
"owner": "frontend-platform"
},
{
"changeId": "FE-REG-ROUTE:REFERENCE_RESOURCE_DETAIL:path:field-changed",
"versionBump": "The reference detail route moves from /examples/reference-resources/:resourceId to /examples/reference-resources/items/:resourceId (maturity review 08-13), so a server id equal to the static segments new or status opens its detail instead of the form or status screen.",
"migration": "The only in-app link (reference-resource-page.tsx) builds the new path from the contract route. The reference feature is a sample; downstream features that copied it keep their own paths.",
"compatibilityWindow": "None for bookmarked sample detail URLs: an old /examples/reference-resources/<id> URL no longer matches the detail route; new and status keep opening the form and status screens.",
"rollback": "Restore the previous path in src/features/reference-feature/contracts/reference-feature-contract.ts and the link in reference-resource-page.tsx, then drop this entry.",
"owner": "frontend-platform"
}
]
}
@@ -88,7 +88,8 @@ export const REFERENCE_FEATURE_CONTRACT = Object.freeze({
}),
REFERENCE_RESOURCE_DETAIL: Object.freeze({
routeId: "REFERENCE_RESOURCE_DETAIL",
path: "/examples/reference-resources/:resourceId",
// 08-13. `items/` keeps an id such as `new` or `status` off the static routes.
path: "/examples/reference-resources/items/:resourceId",
paramsSchema: "ReferenceResourceParams",
searchSchema: null,
access: "session-required",
@@ -63,7 +63,7 @@ export default function ReferenceResourcePage() {
{(query.data ?? []).map((resource) => (
<li key={resource.resourceId}>
<Link
to={`/examples/reference-resources/${encodeURIComponent(resource.resourceId)}`}
to={`/examples/reference-resources/items/${encodeURIComponent(resource.resourceId)}`}
>
{resource.title}
</Link>
@@ -16,7 +16,7 @@ describe("installed context routing", () => {
const routes = await context!.loadRoutes();
expect(routes.map((route) => [route.id, route.path])).toEqual([
["REFERENCE_RESOURCE_LIST", "/examples/reference-resources"],
["REFERENCE_RESOURCE_DETAIL", "/examples/reference-resources/:resourceId"],
["REFERENCE_RESOURCE_DETAIL", "/examples/reference-resources/items/:resourceId"],
["REFERENCE_RESOURCE_FORM", "/examples/reference-resources/new"],
["REFERENCE_RESOURCE_STATUS", "/examples/reference-resources/status"],
]);
@@ -147,7 +147,7 @@ describe("reference feature page states", () => {
const detail = renderReference(
inputWith(),
"/examples/reference-resources/reference-1",
"/examples/reference-resources/items/reference-1",
);
await screen.findByText("Detail");
const detailKey = detail.client.getQueryCache().getAll()[0]?.queryKey;
@@ -247,6 +247,36 @@ describe("reference feature page states", () => {
expect(resultCount()).toBeNull();
});
// 08-13. A server id equal to a static segment still opens its detail.
it.each(["new", "status"])(
"opens the detail screen for an item whose id is %s",
async (resourceId) => {
const user = userEvent.setup();
const getResource = vi.fn(async (id: string) => ({
ok: true as const,
value: { resourceId: id, title: "Detail", createdAt: null },
}));
renderReference(
inputWith({
listResources: async () => ({
ok: true,
value: [
{ resourceId, title: `Item ${resourceId}`, createdAt: null },
],
}),
getResource,
}),
);
await user.click(
await screen.findByRole("link", { name: `Item ${resourceId}` }),
);
expect(
await screen.findByRole("heading", { level: 1, name: "Detail" }),
).toBeVisible();
expect(getResource.mock.calls[0]?.[0]).toBe(resourceId);
},
);
it("renders backend forbidden even when the client access hint allowed entry", async () => {
const user = userEvent.setup();
renderReference(