diff --git a/apps/builder/app/builder/features/publish/publish-session.render.test.tsx b/apps/builder/app/builder/features/publish/publish-session.render.test.tsx index 6e5e17498a..57eb67dc90 100644 --- a/apps/builder/app/builder/features/publish/publish-session.render.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-session.render.test.tsx @@ -245,12 +245,20 @@ const publish = async () => { document.body.querySelector('[role="checkbox"]')?.click() ); } - const button = Array.from( - domain!.closest("form")!.querySelectorAll("button") - ).at(-1)!; - await waitFor(() => expect(button.disabled).toBe(false)); + const getButton = () => + Array.from( + document.body + .querySelector('input[name="domainToPublish[]"]') + ?.closest("form") + ?.querySelectorAll("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 () => { diff --git a/apps/builder/app/builder/features/publish/publish-static.test.tsx b/apps/builder/app/builder/features/publish/publish-static.test.tsx index 5db7be3e58..4b667cfcba 100644 --- a/apps/builder/app/builder/features/publish/publish-static.test.tsx +++ b/apps/builder/app/builder/features/publish/publish-static.test.tsx @@ -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); diff --git a/apps/builder/app/shared/nano-states/props.test.tsx b/apps/builder/app/shared/nano-states/props.test.tsx index d9e779a244..5f67aff441 100644 --- a/apps/builder/app/shared/nano-states/props.test.tsx +++ b/apps/builder/app/shared/nano-states/props.test.tsx @@ -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([ { diff --git a/apps/builder/app/shared/sync/sync-stores.ts b/apps/builder/app/shared/sync/sync-stores.ts index 3bca9cc157..627d9df75d 100644 --- a/apps/builder/app/shared/sync/sync-stores.ts +++ b/apps/builder/app/shared/sync/sync-stores.ts @@ -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),