Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fixes

Andras Bacsaifb30ed034e21
diff --git a/packages/http-client/src/index.test.ts b/packages/http-client/src/index.test.ts
index 9428e2e13c..4e1065e9f9 100644
--- a/packages/http-client/src/index.test.ts
+++ b/packages/http-client/src/index.test.ts
@@ -1,32 +1,24 @@
import { loadProject } from "./index";
-const existingProject = "ab3619d3-831f-46f8-abb6-609558cffd99";
-const notPublishedProject = "7ec397c6-b3d0-4967-9073-9d83623fcf8e";
-const webstudioAPIUrl = "http://localhost:3000";
-const nonExistingProject = "1";
+const existingProjectId = "ab3619d3-831f-46f8-abb6-609558cffd99";
+const notPublishedProjectId = "7ec397c6-b3d0-4967-9073-9d83623fcf8e";
+const apiUrl = "http://localhost:3000";
describe("getProjectDetails", () => {
test("loads existing project", async () => {
const response = await loadProject({
- webstudioAPIUrl,
- projectId: existingProject,
+ apiUrl,
+ projectId: existingProjectId,
});
expect(response.tree.id).toBeTruthy();
});
- test("loads non-existing project", async () => {
- const response = await loadProject({
- webstudioAPIUrl,
- projectId: nonExistingProject,
- });
- expect(response.tree.errors).toBe("Project required");
- });
test("loads not published project", async () => {
const response = await loadProject({
- webstudioAPIUrl,
- projectId: notPublishedProject,
+ apiUrl,
+ projectId: notPublishedProjectId,
});
expect(response.tree.errors).toBe(
- "Site needs to be published, production tree ID is null."
+ "Project 7ec397c6-b3d0-4967-9073-9d83623fcf8e needs to be published first"
);
});
});
diff --git a/packages/http-client/src/index.ts b/packages/http-client/src/index.ts
index 51ca682cb6..6dec39ec30 100644
--- a/packages/http-client/src/index.ts
+++ b/packages/http-client/src/index.ts
@@ -2,18 +2,18 @@ import fetch from "isomorphic-fetch";
import type { Includes, Project } from "./index.d";
export const loadProject = async ({
- webstudioAPIUrl = null,
+ apiUrl,
projectId,
include = { tree: true, props: true, breakpoints: true },
}: {
- webstudioAPIUrl: string | null;
+ apiUrl: string;
projectId: string;
include?: Includes<boolean>;
}): Promise<Project> => {
- if (!webstudioAPIUrl) {
+ if (apiUrl === undefined) {
throw new Error("Webstudio API URL is required.");
}
- const baseUrl = new URL("/", `${webstudioAPIUrl}`);
+ const baseUrl = new URL(`${apiUrl}`);
const treeUrl = new URL(`/rest/tree/${projectId}`, baseUrl);
const propsUrl = new URL(`/rest/props/${projectId}`, baseUrl);
const breakpointsUrl = new URL(`/rest/breakpoints/${projectId}`, baseUrl);