mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-04 22:31:33 +09:00
## Summary Preserve exact Builder instance selections during initial load, authentication, and hard reload, including shared content rendered through multiple Slot instances. ## Implementation - [x] Store the complete selector in one comma-separated `instance` URL parameter. - [x] Reuse `canResolveInstanceSelector` to validate every selector path before restoring it. - [x] Resolve the selected page from the selector root. - [x] Wait for the authoritative Builder data-loaded state before applying initial URL state. - [x] Keep selection-to-URL synchronization paused until initial URL state is resolved. - [x] Let the existing auth loader derive `returnTo` directly from Builder requests. - [x] Update generated Builder links, including pre-publish audit links, to use full selectors. - [x] Add regression coverage for incomplete sync data and duplicate shared-slot child IDs. ## Verification - [x] A fresh browser session authenticates and opens a direct selector deep link. - [x] Hard reload retains the exact selector URL and selection. - [x] Clicking the first shared child creates an `instance` URL for the first Slot path; reload restores the first occurrence. - [x] Clicking the second shared child creates a distinct `instance` URL for the second Slot path; reload restores the second occurrence. - [x] Focused Vitest suite: 8 tests passed. - [x] Builder TypeScript typecheck. - [x] Focused oxlint. - [x] Focused oxfmt check. - [x] `git diff --check`. ## Compatibility and limitations No schema, migration, or public API changes. This change uses one canonical full-selector URL format; ID-only deep links are not retained as a compatibility path.
34 lines
962 B
TypeScript
34 lines
962 B
TypeScript
import { expect, test } from "vitest";
|
|
import { builderPath, builderUrl, restAssetsUploadPath } from "./path-utils";
|
|
|
|
test("includes an instance deep link in builder paths", () => {
|
|
expect(
|
|
builderPath({
|
|
pageId: "page-id",
|
|
instanceSelector: ["instance-id", "slot-id", "body-id"],
|
|
mode: "content",
|
|
})
|
|
).toBe(
|
|
"/?pageId=page-id&instance=instance-id%2Cslot-id%2Cbody-id&mode=content"
|
|
);
|
|
});
|
|
|
|
test("includes an instance deep link in builder urls", () => {
|
|
expect(
|
|
builderUrl({
|
|
projectId: "project-id",
|
|
pageId: "page-id",
|
|
instanceSelector: ["instance-id", "body-id"],
|
|
origin: "https://wstd.dev",
|
|
})
|
|
).toBe(
|
|
"https://p-project-id.wstd.dev/?pageId=page-id&instance=instance-id%2Cbody-id"
|
|
);
|
|
});
|
|
|
|
test("builds the asset upload item route", () => {
|
|
expect(restAssetsUploadPath({ name: "query", width: 100, height: 200 })).toBe(
|
|
"/rest/assets/uploads/query?width=100&height=200"
|
|
);
|
|
});
|