mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
Reuse workflow pages in shard 6 project setup
This commit is contained in:
1 parent
493f6518ad
commit
dbb365e5e5
7 files changed
+32
-10
No files matched your search
@@ -1,10 +1,11 @@
|
||||
import type { BrowserContext } from "@playwright/test";
|
||||
import type { BrowserContext, Page } from "@playwright/test";
|
||||
import { measure } from "../perf";
|
||||
import { prepareExistingContentModeProject } from "./content-mode-project";
|
||||
import { createProjectThroughApi } from "./create-project";
|
||||
|
||||
type ContentModeProjectOptions = {
|
||||
context: BrowserContext;
|
||||
page?: Page;
|
||||
email?: string;
|
||||
title?: string;
|
||||
devPlan?: string;
|
||||
@@ -16,6 +17,7 @@ type ContentModeProjectOptions = {
|
||||
|
||||
export const createContentModeProject = async ({
|
||||
context,
|
||||
page,
|
||||
email = "content-mode-e2e@webstudio.test",
|
||||
title = "Content Mode E2E",
|
||||
devPlan,
|
||||
@@ -26,7 +28,7 @@ export const createContentModeProject = async ({
|
||||
}: ContentModeProjectOptions) => {
|
||||
const projectId = await measure(
|
||||
"content mode fixture login/create project",
|
||||
() => createProjectThroughApi({ context, email, title, devPlan })
|
||||
() => createProjectThroughApi({ context, page, email, title, devPlan })
|
||||
);
|
||||
|
||||
return await measure("content mode fixture prepare project", async () => {
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
import type { BrowserContext, Page } from "@playwright/test";
|
||||
import type { BrowserContext, Page, Route } from "@playwright/test";
|
||||
import env from "../../app/env/env.server";
|
||||
import { getWorkerEmail } from "../flows/dashboard";
|
||||
import { dashboardUrl } from "../test";
|
||||
|
||||
const openApiOrigin = async (page: Page, keepRoute: boolean) => {
|
||||
const originUrl = `${dashboardUrl}/__e2e_origin`;
|
||||
const fulfillOrigin = (route: Route) =>
|
||||
route.fulfill({ contentType: "text/html", body: "<!doctype html>" });
|
||||
await page.route(originUrl, fulfillOrigin);
|
||||
try {
|
||||
await page.goto(originUrl);
|
||||
} finally {
|
||||
if (keepRoute === false) {
|
||||
await page.unroute(originUrl, fulfillOrigin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const apiPages = new WeakMap<BrowserContext, Promise<Page>>();
|
||||
const getApiPage = (context: BrowserContext) => {
|
||||
let page = apiPages.get(context);
|
||||
if (page === undefined) {
|
||||
page = (async () => {
|
||||
const page = await context.newPage();
|
||||
const originUrl = `${dashboardUrl}/__e2e_origin`;
|
||||
try {
|
||||
await page.route(originUrl, (route) =>
|
||||
route.fulfill({ contentType: "text/html", body: "<!doctype html>" })
|
||||
);
|
||||
await page.goto(originUrl);
|
||||
await openApiOrigin(page, true);
|
||||
return page;
|
||||
} catch (error) {
|
||||
await page.close();
|
||||
@@ -28,11 +38,13 @@ const getApiPage = (context: BrowserContext) => {
|
||||
|
||||
export const createProjectThroughApi = async ({
|
||||
context,
|
||||
page: workflowPage,
|
||||
email,
|
||||
title,
|
||||
devPlan,
|
||||
}: {
|
||||
context: BrowserContext;
|
||||
page?: Page;
|
||||
email: string;
|
||||
title: string;
|
||||
devPlan?: string;
|
||||
@@ -43,7 +55,10 @@ export const createProjectThroughApi = async ({
|
||||
if (devPlan !== undefined) {
|
||||
await context.clearCookies();
|
||||
}
|
||||
const page = await getApiPage(context);
|
||||
const page = workflowPage ?? (await getApiPage(context));
|
||||
if (workflowPage !== undefined) {
|
||||
await openApiOrigin(workflowPage, false);
|
||||
}
|
||||
await page.evaluate(
|
||||
async ({ email, devPlan, secret }) => {
|
||||
const loginPage = await fetch("/login");
|
||||
|
||||
@@ -64,6 +64,7 @@ test("Share links enforce viewer, editor, builder, admin, and owner permissions"
|
||||
}) => {
|
||||
const fixture = await createContentModeProject({
|
||||
context,
|
||||
page: ownerPage,
|
||||
email: ownerEmail,
|
||||
title: "Share Link E2E",
|
||||
devPlan: e2ePaidPlanName,
|
||||
|
||||
@@ -67,6 +67,7 @@ test("Generated Preview delivers MCP-authored forms with readable email and brow
|
||||
await startPreviewFormMcpClient();
|
||||
const projectId = await createProjectThroughApi({
|
||||
context,
|
||||
page,
|
||||
email: "mcp-default-contact@webstudio.test",
|
||||
title: "MCP default contact Form",
|
||||
});
|
||||
|
||||
@@ -43,6 +43,7 @@ test("Content templates, assets, and collection entries persist across Builder m
|
||||
}) => {
|
||||
const fixture = await createContentModeProject({
|
||||
context,
|
||||
page,
|
||||
devPlan: e2ePaidPlanName,
|
||||
email: `content-mode-assets-${randomUUID()}@webstudio.test`,
|
||||
});
|
||||
|
||||
@@ -22,9 +22,10 @@ import { e2ePaidPlanName } from "../plans";
|
||||
|
||||
let fixture: SeededContentModeProject;
|
||||
|
||||
test.beforeEach(async ({ context }) => {
|
||||
test.beforeEach(async ({ context, page }) => {
|
||||
fixture = await createContentModeProject({
|
||||
context,
|
||||
page,
|
||||
devPlan: e2ePaidPlanName,
|
||||
email: `content-mode-pages-${randomUUID()}@webstudio.test`,
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ test("MCP-authored Resources show blocked HTTP failures and preview email withou
|
||||
}) => {
|
||||
const fixture = await createContentModeProject({
|
||||
context,
|
||||
page,
|
||||
email: "mcp-resource-inspector@webstudio.test",
|
||||
title: "MCP Resource inspector",
|
||||
assetNamePrefix: "mcp-resource-inspector-",
|
||||
|
||||
Reference in new issue
Block a user