fix: Show origin-based resource data in canvas (#6710)

A resource using `system.origin` can show the right value in Settings
while Canvas and Preview stay empty. Canvas needs the same published
host as Builder to find the cached resource response.

This PR targets `main` from `org.staging`. It does not change stored
project data or the published runtime.

## Plan and verification
- [x] Apply the minimal host synchronization fix on top of `main`.
- [x] Confirm the regression test fails before the fix and passes
afterward.
- [x] Run 97 focused tests, Builder typecheck, lint, format, and
package-boundary checks on `main`.
- [x] Check the staging behavior with a real shared project (confirmed
by the reporter).
- [x] Run a local database-backed Builder and Canvas check with a
non-default publisher host (passed).
- [x] Review documentation impact: existing behavior is restored; no
docs update needed.
- [x] Review fixture impact: the current `main` merge supplied the
required E2E schema snapshot; no fixture change is needed in this PR.
- [ ] Stabilize the two publish tests that failed in the full CI suite
after the `main` merge.
- [ ] Required PR checks pass.

The local full Builder core suite also reported unrelated style and form
test failures under parallel load; the focused publish tests passed. The
PR run is the final verification for the CI test fix.

Ref #3343
This commit is contained in:
Oleg Isonen authored and GitHub committed 2026-11-17 18:05:31 +01:00
1 parent 244b26e310
commit aeb34e3c70
4 files changed
+29 -11

No files matched your search

@@ -245,12 +245,20 @@ const publish = async () => {
document.body.querySelector<HTMLElement>('[role="checkbox"]')?.click()
);
}
const button = Array.from(
domain!.closest("form")!.querySelectorAll<HTMLButtonElement>("button")
).at(-1)!;
await waitFor(() => expect(button.disabled).toBe(false));
const getButton = () =>
Array.from(
document.body
.querySelector<HTMLInputElement>('input[name="domainToPublish[]"]')
?.closest("form")
?.querySelectorAll<HTMLButtonElement>("button") ?? []
).at(-1);
await waitFor(() => expect(getButton()?.disabled).toBe(false));
const previousRequests = publishRequests;
await act(async () => button.click());
await act(async () => {
const button = getButton();
expect(button).toBeDefined();
button?.click();
});
await waitFor(() => expect(publishRequests).toBe(previousRequests + 1));
};
const openReport = async () => {
@@ -307,12 +307,14 @@ test("the static failure alert opens an audit rejection instead of an older succ
await act(async () => {});
expect(downloads).toHaveBeenCalledOnce();
expect(staticButton()?.dataset.state).not.toBe("pending");
expect(staticButton()?.disabled).toBe(false);
});
staticResponse = {
success: false,
auditFindings: [{ severity: "error", message: "audit-rejection" }],
};
await act(async () => staticButton()?.click());
await waitFor(() => expect(publishRequests).toBe(2));
const activeTab = () =>
document.body.querySelector('[role="tab"][aria-selected="true"]')
?.textContent;
@@ -343,4 +345,4 @@ test("the static failure alert opens an audit rejection instead of an older succ
?.click()
);
expect(activeTab()).toBe("Errors");
});
}, 30_000);
@@ -20,6 +20,7 @@ import {
$dataSources,
$props,
$resources,
$publisherHost,
} from "../sync/data-stores";
import {
$propValuesByInstanceSelector,
@@ -39,7 +40,7 @@ import {
ws,
} from "@webstudio-is/template";
import { $systemDataByPage, updateCurrentSystem } from "../system";
import { registerContainers } from "../sync/sync-stores";
import { createObjectPool, registerContainers } from "../sync/sync-stores";
import { $resourcesCache, getResourceKey } from "../resources";
import { $externalContentRoots } from "../external-content-mutations";
@@ -107,6 +108,7 @@ afterEach(() => {
unsubscribeResourceRequestPlan?.();
unsubscribeResourceRequestPlan = undefined;
resourceRequests = [];
$publisherHost.set("wstd.work");
});
test("provides occurrence frontmatter to a repeated Content Block", async () => {
@@ -862,7 +864,7 @@ test("access parameter value from variables values", async () => {
);
});
test("compute props bound to resource variables", async () => {
test("compute props bound to resources using the synced published origin", async () => {
$instances.set(
toMap([{ id: "body", type: "instance", component: "Body", children: [] }])
);
@@ -884,7 +886,7 @@ test("compute props bound to resource variables", async () => {
{
id: "resourceId",
name: "my-resource",
url: `""`,
url: "$ws$system.origin",
method: "get",
headers: [],
},
@@ -892,12 +894,17 @@ test("compute props bound to resource variables", async () => {
);
const key = getResourceKey({
name: "my-resource",
url: "",
url: "https://undefined.wstd.io",
method: "get",
headers: [],
searchParams: [],
});
$resourcesCache.set(new Map([[key, "my-value"]]));
createObjectPool().applyTransaction({
id: "published-host",
object: "publisherHost",
payload: "wstd.io",
});
$props.set(
toMap([
{
+2 -1
View File
@@ -3,7 +3,7 @@ import { enableMapSet, setAutoFreeze } from "immer";
import { useEffect } from "react";
import { batched } from "nanostores";
import { createId } from "@webstudio-is/sdk";
import { $project } from "./data-stores";
import { $project, $publisherHost } from "./data-stores";
import {
$selectedPageHash,
$selectedInstanceSizes,
@@ -345,6 +345,7 @@ export const createObjectPool = () => {
new NanostoresSyncObject("temporaryInstances", $temporaryInstances),
new NanostoresSyncObject("project", $project),
new NanostoresSyncObject("publisherHost", $publisherHost),
new NanostoresSyncObject("dataSourceVariables", $dataSourceVariables),
new NanostoresSyncObject("resourcesCache", $resourcesCache),
new NanostoresSyncObject("resourcesState", $resourcesState),