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.

1.3 KB
Raw Blame
import type { BrowserContext } from "@playwright/test";
import { loginAndCreateBlankProject } from "../flows/dashboard";
import { measure } from "../perf";
import { prepareExistingContentModeProject } from "./content-mode-project";

type ContentModeProjectOptions = {
  context: BrowserContext;
  email?: string;
  title?: string;
  devPlan?: string;
  assetNamePrefix?: string;
  editorToken?: string;
  editorCanUseApi?: boolean;
  builderToken?: string;
};

export const createContentModeProject = async ({
  context,
  email = "[email protected]",
  title = "Content Mode E2E",
  devPlan,
  assetNamePrefix,
  editorToken,
  editorCanUseApi,
  builderToken,
}: ContentModeProjectOptions) => {
  const ownerPage = await context.newPage();

  try {
    const projectId = await measure(
      "content mode fixture login/create project",
      async () =>
        await loginAndCreateBlankProject({
          page: ownerPage,
          email,
          title,
          devPlan,
        })
    );

    return await measure("content mode fixture prepare project", async () => {
      return await prepareExistingContentModeProject({
        projectId,
        assetNamePrefix,
        editorToken,
        editorCanUseApi,
        builderToken,
      });
    });
  } finally {
    await ownerPage.close();
  }
};