Files
webstudio/apps/builder/app/shared/router-utils/path-utils.test.ts
T
Oleg Isonen 9ce325b94c feat: Deep-link Builder instances (#5923)
## Summary

- add optional `instanceId` support to the shared Builder link
parameters used by `builderPath` and `builderUrl`
- synchronize the selected instance into the Builder URL without adding
a browser-history entry for every selection
- restore the selected page and full instance selector when opening an
instance deep link
- render a **Show element** link for pre-publish audit findings that
identify an instance
- switch to the affected page, select and scroll to the instance, and
close the publish popover when the link is used

## Why

The pre-publish audit introduced in #5922 identifies the invalid page
and instance, but its error was text-only. Users still had to locate the
offending element manually. A shared instance deep-link parameter also
makes these links copyable and reusable outside the audit UI.

## Impact

Builder URLs can now include `instanceId` alongside `pageId`. Existing
page-opening links continue using the same central
`builderPath`/`builderUrl` abstraction. Missing or stale instance IDs
safely fall back to the requested page.

## Validation

- focused Builder tests passed (4 tests)
- `@webstudio-is/builder` typecheck passed
- focused Oxlint passed
- focused Oxfmt check passed
- `git diff --check` passed
2026-07-20 01:40:42 +02:00

26 lines
661 B
TypeScript

import { expect, test } from "vitest";
import { builderPath, builderUrl } from "./path-utils";
test("includes an instance deep link in builder paths", () => {
expect(
builderPath({
pageId: "page-id",
instanceId: "instance-id",
mode: "content",
})
).toBe("/?pageId=page-id&instanceId=instance-id&mode=content");
});
test("includes an instance deep link in builder urls", () => {
expect(
builderUrl({
projectId: "project-id",
pageId: "page-id",
instanceId: "instance-id",
origin: "https://wstd.dev",
})
).toBe(
"https://p-project-id.wstd.dev/?pageId=page-id&instanceId=instance-id"
);
});