Trim cold E2E build setup and slow shard paths

This commit is contained in:
Oleg Isonen committed 2026-11-16 00:38:20 +00:00
1 parent 83abffabb8
commit 634ffb002f
10 files changed
+421 -482

No files matched your search

@@ -20,8 +20,6 @@ runs:
submodules-ssh-key: ${{ inputs.submodules-ssh-key }}
- uses: ./.github/actions/ci-setup
with:
run-scripts: "true"
- name: Discover shards
id: shards
-28
View File
@@ -1,28 +0,0 @@
import type { Page } from "@playwright/test";
import { waitForCanvasFrame } from "./builder";
import { waitForChangeToBeSaved, waitForSyncComplete } from "./sync-status";
export const deleteContentBlockChildAfterCanvasText = async ({
page,
text,
}: {
page: Page;
text: string;
}) => {
const canvas = await waitForCanvasFrame({ page });
await waitForSyncComplete({ page });
await page.keyboard.down("Alt");
try {
await canvas.getByText(text, { exact: true }).hover();
const deleteButton = page
.getByRole("button", { name: "Delete block" })
.last();
await deleteButton.waitFor({ state: "visible" });
const save = waitForChangeToBeSaved({ page });
await deleteButton.click();
await save;
} finally {
await page.keyboard.up("Alt");
}
};
@@ -4,10 +4,7 @@ import { openProjectBuilder, waitForCanvasText } from "../flows/builder";
import { selectCanvasTextInstance } from "../flows/canvas-selection";
import { expectGeneratedAppBuild } from "../flows/generated-app";
import { openNavigatorPanel } from "../flows/navigator";
import {
waitForChangeToBeSaved,
waitForSyncComplete,
} from "../flows/sync-status";
import { waitForSyncComplete } from "../flows/sync-status";
import { createContentModeProject } from "../fixtures/content-mode-suite";
import { test } from "../test";
import { measure } from "../perf";
@@ -52,10 +49,7 @@ const wrapSelectedInstance = async ({
);
await optionInput.waitFor();
await optionInput.fill(option);
const save = waitForChangeToBeSaved({ page });
await selectCommandPanelItem({ page, text: option });
await save;
await waitForSyncComplete({ page });
};
const selectNavigatorItem = async ({
@@ -186,23 +180,29 @@ test("Builder animation UI creates supported animation props that persist and bu
presetName,
});
await measure("animation runtime reload builder", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
});
});
await waitForCanvasText({ page, text });
await expectPersistedAnimation({
projectId: fixture.projectId,
presetName,
});
await measure("animation runtime generated app build", async () => {
await expectGeneratedAppBuild({
projectId: fixture.projectId,
expectedText: text,
});
});
const results = await Promise.allSettled([
measure("animation runtime reload builder", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
});
await waitForCanvasText({ page, text });
await expectPersistedAnimation({
projectId: fixture.projectId,
presetName,
});
}),
measure("animation runtime generated app build", () =>
expectGeneratedAppBuild({
projectId: fixture.projectId,
expectedText: text,
})
),
]);
for (const result of results) {
if (result.status === "rejected") {
throw result.reason;
}
}
});
@@ -1,218 +0,0 @@
import { expect } from "@playwright/test";
import { randomUUID } from "node:crypto";
import { createContentModeProject } from "../fixtures/content-mode-suite";
import {
createAssetFolder,
deleteSelectedAsset,
openAssetSettings,
openAssetsPanel,
replaceSelectedAsset,
uploadAsset,
waitForAsset,
} from "../flows/assets-panel";
import { openProjectBuilder, waitForCanvasFrame } from "../flows/builder";
import {
selectCanvasImage,
waitForCanvasImage,
waitForCanvasImageSourceName,
} from "../flows/canvas-media";
import { chooseSelectedAssetProperty } from "../flows/props-panel";
import {
waitForChangeToBeSaved,
waitForSyncComplete,
} from "../flows/sync-status";
import { insertTemplateAfterCanvasText } from "../flows/template-insertion";
import { measure } from "../perf";
import { e2ePaidPlanName } from "../plans";
import { test } from "../test";
test("Editor can save assets, folders, and collection entries in content mode", async ({
context,
page,
}) => {
const fixture = await createContentModeProject({
context,
devPlan: e2ePaidPlanName,
email: `content-mode-assets-${randomUUID()}@webstudio.test`,
});
const uploadFilename = "large-image.svg";
const replacementFilename = "replacement-image.svg";
const collectionName = "Content collection entries";
const folderName = "Editor ordinary assets";
const entryTitle = "Content collection entry";
const entryFilename = "content-collection-entry.mdx";
const assetsPanel = page.getByRole("tabpanel", { name: "Assets" });
const browseRoot = () =>
assetsPanel.getByRole("button", { name: "Root", exact: true }).click();
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
});
await waitForSyncComplete({ page });
await openAssetsPanel({ page });
const collection = await createAssetFolder({
page,
name: collectionName,
useAsContentCollection: true,
});
await collection.dblclick();
await page.getByRole("button", { name: "Collection settings" }).waitFor();
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
await waitForSyncComplete({ page });
await openAssetsPanel({ page });
// The last folder is remembered for this project, including across modes.
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByRole("button", { name: "Add asset" }).click();
await page.getByRole("menuitem", { name: "New entry" }).click();
const dialog = page.getByRole("dialog", { name: "New entry" });
await dialog.getByLabel("Title *").fill(entryTitle);
await Promise.all([
waitForChangeToBeSaved({ page }),
dialog.getByRole("button", { name: "Create entry" }).click(),
]);
await waitForAsset({ page, filename: entryFilename });
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByTitle("template.mdx").waitFor({ state: "visible" });
await browseRoot();
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.imageReplacementTemplateName,
});
await waitForCanvasImage({
page,
alt: fixture.imageReplacementTemplateImageAlt,
});
let uploadedAssetTitle = "";
await measure("content mode upload image source asset", async () => {
await openAssetsPanel({ page });
uploadedAssetTitle = await uploadAsset({
page,
filename: uploadFilename,
});
});
await selectCanvasImage({
page,
alt: fixture.imageReplacementTemplateImageAlt,
});
await measure("content mode choose image source asset", async () => {
await chooseSelectedAssetProperty({
page,
label: "Source",
assetFilename: uploadFilename,
});
});
await waitForCanvasImageSourceName({ page, sourceName: "large-image_" });
const canvas = await waitForCanvasFrame({ page });
const uploadedImage = canvas.locator('img[src*="large-image_"]');
await expect(uploadedImage).toHaveAttribute("width", "240");
await expect(uploadedImage).toHaveAttribute("height", "160");
let replacementAssetTitle = "";
await measure("content mode replace used image source asset", async () => {
await openAssetsPanel({ page });
await openAssetSettings({
page,
filename: uploadedAssetTitle,
});
replacementAssetTitle = await replaceSelectedAsset({
page,
filename: replacementFilename,
});
});
await waitForCanvasImageSourceName({
page,
sourceName: "replacement-image_",
});
await waitForSyncComplete({ page });
const folder = await createAssetFolder({ page, name: folderName });
await folder.dblclick();
const deletedAsset =
await test.step("Upload, replace and delete an unused asset in the ordinary folder", async () => {
const uploadFilename = "upload-image.svg";
const replacementFilename = "large-image.svg";
let uploadedAssetTitle = "";
await measure("content mode upload asset", async () => {
uploadedAssetTitle = await uploadAsset({
page,
filename: uploadFilename,
});
});
let replacementAssetTitle = "";
await measure("content mode replace asset", async () => {
await openAssetSettings({ page, filename: uploadedAssetTitle });
const assetId = await page.locator("#asset-manager-id").inputValue();
if (assetId.length === 0) {
throw new Error(
"Expected Asset settings to expose the uploaded asset id"
);
}
await page.getByText("0 uses", { exact: true }).waitFor();
replacementAssetTitle = await replaceSelectedAsset({
page,
filename: replacementFilename,
});
});
await measure("content mode delete asset", async () => {
await openAssetSettings({ page, filename: replacementAssetTitle });
await deleteSelectedAsset({
page,
filename: replacementAssetTitle,
});
});
return { uploadedAssetTitle, replacementAssetTitle };
});
await browseRoot();
await collection.dblclick();
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
await openAssetsPanel({ page });
await waitForAsset({ page, filename: entryFilename });
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByTitle("template.mdx").waitFor({ state: "visible" });
await browseRoot();
const expectDeletedAssetAbsent = async () => {
await expect(
assetsPanel.getByTitle(deletedAsset.uploadedAssetTitle)
).toHaveCount(0);
await expect(
assetsPanel.getByTitle(deletedAsset.replacementAssetTitle)
).toHaveCount(0);
};
await expectDeletedAssetAbsent();
await waitForCanvasImageSourceName({
page,
sourceName: "replacement-image_",
});
await page.getByTitle(replacementAssetTitle).waitFor();
await waitForSyncComplete({ page });
const reloadedCanvas = await waitForCanvasFrame({ page });
const replacementImage = reloadedCanvas.locator(
'img[src*="replacement-image_"]'
);
await expect(replacementImage).toHaveAttribute("width", "120");
await expect(replacementImage).toHaveAttribute("height", "80");
await folder.dblclick();
await expectDeletedAssetAbsent();
});
@@ -207,9 +207,7 @@ test("Builder style properties, grid, tokens, and custom breakpoints persist", a
const styleSourceInput = page.getByLabel("New style source input");
await styleSourceInput.fill(tokenName);
const createSave = waitForChangeToBeSaved({ page });
await page.getByText(`Create ${tokenName}`, { exact: false }).click();
await createSave;
await page.getByText(tokenName, { exact: true }).waitFor();
await setCssValue({ page, property: "color", value: "#b4234c" });
@@ -257,28 +255,30 @@ test("Builder style properties, grid, tokens, and custom breakpoints persist", a
await selectNavigatorItem({ page, itemName: "Body" });
await page.getByRole("tab", { name: "Style" }).click();
await measure("style panel runtime enable body grid", async () => {
await addCssDeclaration({ page, property: "display", value: "grid" });
});
await page.getByRole("button", { name: /Grid layout:/ }).waitFor();
const gridLayout = page.getByRole("button", { name: /Grid layout:/ });
await expect(gridLayout).toBeHidden();
await Promise.all([
measure("style panel runtime enable body grid", () =>
addCssDeclaration({ page, property: "display", value: "grid" })
),
measure("style panel runtime fill body grid", async () => {
await gridLayout.click();
await page.getByRole("button", { name: "Fill grid" }).click();
// The display declaration may save before the new children.
await expect
.poll(
() =>
getInstanceChildCount({
fixture,
instanceId: bodyInstanceId,
}),
{ message: "Fill grid saves the new Body children" }
)
.toBe(expectedBodyChildCount);
await page.keyboard.press("Escape");
}),
]);
await measure("style panel runtime fill body grid", async () => {
await page.getByRole("button", { name: /Grid layout:/ }).click();
const save = waitForChangeToBeSaved({ page });
await page.getByRole("button", { name: "Fill grid" }).click();
await save;
await page.keyboard.press("Escape");
});
const filledBodyChildCount = await getInstanceChildCount({
fixture,
instanceId: bodyInstanceId,
});
if (filledBodyChildCount !== expectedBodyChildCount) {
throw new Error(
`Expected Fill grid to grow Body children to ${expectedBodyChildCount}. Before ${initialBodyChildCount}, after ${filledBodyChildCount}`
);
}
const styles = await readBuildStylesText(fixture);
expect(styles).toContain('"display"');
expect(styles).toContain('"grid"');
@@ -299,10 +299,8 @@ test("Builder style properties, grid, tokens, and custom breakpoints persist", a
await nameInput.blur();
await nameSave;
const renameSave = waitForChangeToBeSaved({ page });
await nameInput.fill(updatedBreakpointName);
await nameInput.blur();
await renameSave;
await page.keyboard.press("Escape");
await page
@@ -1,17 +1,33 @@
import { expect } from "@playwright/test";
import { randomUUID } from "node:crypto";
import { loadDevBuild } from "../db";
import { createContentModeProject } from "../fixtures/content-mode-suite";
import { openProjectBuilder, waitForCanvasText } from "../flows/builder";
import {
createAssetFolder,
deleteSelectedAsset,
openAssetSettings,
openAssetsPanel,
replaceSelectedAsset,
uploadAsset,
waitForAsset,
} from "../flows/assets-panel";
import {
openProjectBuilder,
waitForCanvasFrame,
waitForCanvasText,
} from "../flows/builder";
import {
selectCanvasImage,
waitForCanvasImage,
waitForCanvasImageCount,
waitForCanvasImageSourceName,
waitForCanvasVideoSource,
} from "../flows/canvas-media";
import {
waitForCanvasTextStyle,
waitForCanvasTextStyleCount,
} from "../flows/canvas-style";
import { chooseSelectedAssetProperty } from "../flows/props-panel";
import {
waitForChangeToBeSaved,
waitForSyncComplete,
@@ -21,7 +37,7 @@ import { measure } from "../perf";
import { e2ePaidPlanName } from "../plans";
import { test } from "../test";
test("Content templates persist with styles and assets, including after Builder copy/paste", async ({
test("Content templates, assets, and collection entries persist across Builder modes", async ({
context,
page,
}) => {
@@ -46,98 +62,236 @@ test("Content templates persist with styles and assets, including after Builder
return references.length;
};
await measure("content mode open editor for asset template", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
const uploadFilename = "large-image.svg";
const replacementFilename = "replacement-image.svg";
const collectionName = "Content collection entries";
const folderName = "Editor ordinary assets";
const entryTitle = "Content collection entry";
const entryFilename = "content-collection-entry.mdx";
const assetsPanel = page.getByRole("tabpanel", { name: "Assets" });
const browseRoot = () =>
assetsPanel.getByRole("button", { name: "Root", exact: true }).click();
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
});
await waitForCanvasText({ page, text: "Initial content" });
await waitForSyncComplete({ page });
await openAssetsPanel({ page });
const collection = await createAssetFolder({
page,
name: collectionName,
useAsContentCollection: true,
});
await collection.dblclick();
await page.getByRole("button", { name: "Collection settings" }).waitFor();
const initialAssetReferenceCount = await getImageAssetReferenceCount();
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
await waitForSyncComplete({ page });
await openAssetsPanel({ page });
// The last folder is remembered for this project, including across modes.
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByRole("button", { name: "Add asset" }).click();
await page.getByRole("menuitem", { name: "New entry" }).click();
const dialog = page.getByRole("dialog", { name: "New entry" });
await dialog.getByLabel("Title *").fill(entryTitle);
await Promise.all([
waitForChangeToBeSaved({ page }),
dialog.getByRole("button", { name: "Create entry" }).click(),
]);
await waitForAsset({ page, filename: entryFilename });
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByTitle("template.mdx").waitFor({ state: "visible" });
// Check each insertion on the canvas, then wait for the final save before
// opening the project as Builder and checking persistence across reloads.
await measure("content mode insert asset template", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.assetTemplateName,
waitForProjectSync: false,
});
await browseRoot();
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.imageReplacementTemplateName,
});
await waitForCanvasImage({
page,
alt: fixture.assetTemplateImageAlt,
});
await waitForCanvasVideoSource({
page,
sourceName: fixture.assetTemplateVideoName,
alt: fixture.imageReplacementTemplateImageAlt,
});
await measure("content mode insert heading template", async () => {
await insertTemplateAfterCanvasText({
let uploadedAssetTitle = "";
await measure("content mode upload image source asset", async () => {
await openAssetsPanel({ page });
uploadedAssetTitle = await uploadAsset({
page,
anchorText: "Initial content",
templateName: fixture.styledHeadingTemplateName,
waitForProjectSync: false,
filename: uploadFilename,
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await waitForCanvasTextStyle({
page,
text: fixture.styledHeadingTemplateText,
property: "font-size",
value: fixture.styledHeadingTemplateFontSize,
});
await measure("content mode insert token template", async () => {
await insertTemplateAfterCanvasText({
await selectCanvasImage({
page,
alt: fixture.imageReplacementTemplateImageAlt,
});
await measure("content mode choose image source asset", async () => {
await chooseSelectedAssetProperty({
page,
anchorText: "Initial content",
templateName: fixture.tokenTemplateLabel,
waitForProjectSync: false,
label: "Source",
assetFilename: uploadFilename,
});
});
await waitForCanvasText({
page,
text: fixture.tokenTemplateVisibleText,
await waitForCanvasImageSourceName({ page, sourceName: "large-image_" });
const canvas = await waitForCanvasFrame({ page });
const uploadedImage = canvas.locator('img[src*="large-image_"]');
await expect(uploadedImage).toHaveAttribute("width", "240");
await expect(uploadedImage).toHaveAttribute("height", "160");
let replacementAssetTitle = "";
await measure("content mode replace used image source asset", async () => {
await openAssetsPanel({ page });
await openAssetSettings({
page,
filename: uploadedAssetTitle,
});
replacementAssetTitle = await replaceSelectedAsset({
page,
filename: replacementFilename,
});
});
await waitForCanvasTextStyle({
await waitForCanvasImageSourceName({
page,
text: fixture.tokenTemplateVisibleText,
property: "font-size",
value: fixture.tokenTemplateFontSize,
sourceName: "replacement-image_",
});
await waitForSyncComplete({ page });
const folder = await createAssetFolder({ page, name: folderName });
await folder.dblclick();
const deletedAsset =
await test.step("Upload, replace and delete an unused asset in the ordinary folder", async () => {
const uploadFilename = "upload-image.svg";
const replacementFilename = "large-image.svg";
let uploadedAssetTitle = "";
await measure("content mode upload asset", async () => {
uploadedAssetTitle = await uploadAsset({
page,
filename: uploadFilename,
});
});
let replacementAssetTitle = "";
await measure("content mode replace asset", async () => {
await openAssetSettings({ page, filename: uploadedAssetTitle });
const assetId = await page.locator("#asset-manager-id").inputValue();
if (assetId.length === 0) {
throw new Error(
"Expected Asset settings to expose the uploaded asset id"
);
}
await page.getByText("0 uses", { exact: true }).waitFor();
replacementAssetTitle = await replaceSelectedAsset({
page,
filename: replacementFilename,
});
});
await measure("content mode delete asset", async () => {
await openAssetSettings({ page, filename: replacementAssetTitle });
await deleteSelectedAsset({
page,
filename: replacementAssetTitle,
});
});
return { uploadedAssetTitle, replacementAssetTitle };
});
await browseRoot();
await collection.dblclick();
const initialAssetReferenceCount = await getImageAssetReferenceCount();
await test.step("Editor can insert templates with styles and assets", async () => {
await waitForCanvasText({ page, text: "Initial content" });
// Check each insertion on the canvas, then wait for the final save before
// opening the project as Builder and checking persistence across reloads.
await measure("content mode insert asset template", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.assetTemplateName,
waitForProjectSync: false,
});
});
await waitForCanvasImage({
page,
alt: fixture.assetTemplateImageAlt,
});
await waitForCanvasVideoSource({
page,
sourceName: fixture.assetTemplateVideoName,
});
await measure("content mode insert heading template", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.styledHeadingTemplateName,
waitForProjectSync: false,
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await waitForCanvasTextStyle({
page,
text: fixture.styledHeadingTemplateText,
property: "font-size",
value: fixture.styledHeadingTemplateFontSize,
});
await measure("content mode insert token template", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.tokenTemplateLabel,
waitForProjectSync: false,
});
});
await waitForCanvasText({
page,
text: fixture.tokenTemplateVisibleText,
});
await waitForCanvasTextStyle({
page,
text: fixture.tokenTemplateVisibleText,
property: "font-size",
value: fixture.tokenTemplateFontSize,
});
await measure("content mode insert local style templates", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.isolatedLocalTemplateName,
waitForProjectSync: false,
});
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.isolatedLocalTemplateName,
});
});
await waitForCanvasTextStyleCount({
page,
text: fixture.isolatedLocalTemplateText,
property: "font-size",
value: fixture.isolatedLocalTemplateFontSize,
count: 2,
});
});
await measure("content mode insert local style templates", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.isolatedLocalTemplateName,
waitForProjectSync: false,
});
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.isolatedLocalTemplateName,
});
});
await waitForCanvasTextStyleCount({
page,
text: fixture.isolatedLocalTemplateText,
property: "font-size",
value: fixture.isolatedLocalTemplateFontSize,
count: 2,
});
await test.step("Builder can copy and paste the inserted image and reload its asset references", async () => {
await test.step("Builder can copy and paste the inserted image and save its asset references", async () => {
await measure("asset copy open build mode", async () => {
await openProjectBuilder({
page,
@@ -171,18 +325,15 @@ test("Content templates persist with styles and assets, including after Builder
"Expected insertion and paste to add two asset references."
);
}
});
await measure(
"content mode reload editor after Builder copy and paste",
async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
}
);
await test.step("Reload content mode and check copied templates, assets, folders, and entries", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
await waitForCanvasVideoSource({
page,
sourceName: fixture.assetTemplateVideoName,
@@ -218,5 +369,34 @@ test("Content templates persist with styles and assets, including after Builder
) {
throw new Error("Expected reload to preserve copied asset references.");
}
await openAssetsPanel({ page });
await waitForAsset({ page, filename: entryFilename });
await page.getByTitle("collection.json").waitFor({ state: "visible" });
await page.getByTitle("template.mdx").waitFor({ state: "visible" });
await browseRoot();
const expectDeletedAssetAbsent = async () => {
await expect(
assetsPanel.getByTitle(deletedAsset.uploadedAssetTitle)
).toHaveCount(0);
await expect(
assetsPanel.getByTitle(deletedAsset.replacementAssetTitle)
).toHaveCount(0);
};
await expectDeletedAssetAbsent();
await waitForCanvasImageSourceName({
page,
sourceName: "replacement-image_",
});
await page.getByTitle(replacementAssetTitle).waitFor();
await waitForSyncComplete({ page });
const reloadedCanvas = await waitForCanvasFrame({ page });
const replacementImage = reloadedCanvas.locator(
'img[src*="replacement-image_"]'
);
await expect(replacementImage).toHaveAttribute("width", "120");
await expect(replacementImage).toHaveAttribute("height", "80");
await folder.dblclick();
await expectDeletedAssetAbsent();
});
});
@@ -1,5 +1,4 @@
import { expect } from "@playwright/test";
import { deleteContentBlockChildAfterCanvasText } from "../flows/block-outline";
import {
openProjectBuilder,
waitForCanvasFrame,
@@ -193,10 +192,14 @@ test("Editor can paste, format and delete text while protected content remains",
});
await measure("content mode delete direct child", async () => {
await deleteContentBlockChildAfterCanvasText({
page,
text: pastedContent,
});
const canvas = await waitForCanvasFrame({ page });
await page.keyboard.down("Alt");
try {
await canvas.getByText(pastedContent, { exact: true }).hover();
await page.getByRole("button", { name: "Delete block" }).last().click();
} finally {
await page.keyboard.up("Alt");
}
});
await waitForCanvasTextHidden({
page,
@@ -212,6 +215,8 @@ test("Editor can paste, format and delete text while protected content remains",
});
});
await waitForCanvasText({ page, text: formattedText });
// The preceding deletion can finish while the formatting is being applied.
await waitForSyncComplete({ page });
const boldCount = await getElementTagWithTextCount({
projectId: fixture.projectId,
@@ -145,17 +145,14 @@ test("Editor can open and save legacy content before a Builder migrates the proj
);
const editedText = "Saved legacy Editor content";
const textSave = waitForChangeToBeSaved({ page });
textSave.catch(() => undefined);
await replaceCanvasText({
page,
currentText: fixture.shareLinkEditableText,
text: editedText,
waitForProjectSync: false,
});
const editedBuild = await loadDevBuild({ projectId: fixture.projectId });
expect(JSON.parse(editedBuild.styles)).toEqual(styles);
expect(JSON.parse(editedBuild.styleSources)).toEqual(styleSources);
expect(JSON.parse(editedBuild.styleSourceSelections)).toEqual(selections);
expect(JSON.parse(editedBuild.props)).toEqual(props);
expect(unexpectedDialogs).toEqual([]);
const canvas = await waitForCanvasFrame({ page });
await canvas.getByText(readOnlyCode, { exact: true }).click();
@@ -165,6 +162,15 @@ test("Editor can open and save legacy content before a Builder migrates the proj
await selectNavigatorItem({ page, name: "Legacy literal code" });
await expect(textContent).toHaveText(code);
await expect(textContent).toHaveAttribute("contenteditable", "true");
await textSave;
const editedBuild = await loadDevBuild({ projectId: fixture.projectId });
expect(JSON.parse(editedBuild.styles)).toEqual(styles);
expect(JSON.parse(editedBuild.styleSources)).toEqual(styleSources);
expect(JSON.parse(editedBuild.styleSourceSelections)).toEqual(selections);
expect(JSON.parse(editedBuild.props)).toEqual(props);
expect(unexpectedDialogs).toEqual([]);
const editedCode = "const savedAnswer = 43;";
const codeSave = waitForChangeToBeSaved({ page });
codeSave.catch(() => undefined);
@@ -184,18 +190,15 @@ test("Editor can open and save legacy content before a Builder migrates the proj
expect(unexpectedDialogs).toEqual([]);
// Actual build permission still permits migration while using Content mode.
await withBrowserContext(browser, async (context) => {
const builderPage = await context.newPage();
await openProjectBuilder({
page: builderPage,
projectId: fixture.projectId,
authToken: fixture.builderToken,
mode: "content",
});
await waitForCanvasText({ page: builderPage, text: editedText });
await waitForCanvasText({ page: builderPage, text: editedCode });
await waitForSyncComplete({ page: builderPage });
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
mode: "content",
});
await waitForCanvasText({ page, text: editedText });
await waitForCanvasText({ page, text: editedCode });
await waitForSyncComplete({ page });
const migratedBuild = await loadDevBuild({ projectId: fixture.projectId });
expect(
JSON.parse(migratedBuild.styleSources) as StyleSource[]
@@ -196,62 +196,6 @@ test.beforeEach(async ({ browser }) => {
);
});
test("Builder can insert through the engine bridge, undo, redo, and reload", async ({
page,
}) => {
await measure("pages actions open builder for engine bridge", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
});
await waitForCanvasText({ page, text: "Initial content" });
await measure("pages actions insert template through bridge", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.styledHeadingTemplateName,
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions undo bridge insert", async () => {
await selectSavedAppMenuItem({ page, name: "Undo" });
});
await waitForCanvasTextHidden({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions redo bridge insert", async () => {
await selectSavedAppMenuItem({ page, name: "Redo" });
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions reload bridge insert", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
});
test("Builder filters the catalog and persists component actions from shortcuts and Navigator", async ({
page,
}) => {
@@ -378,3 +322,59 @@ test("Builder filters the catalog and persists component actions from shortcuts
await waitForCanvasText({ page, text: insertedButtonText });
expect(await readComponentCount()).toBe(initialCount + 3);
});
test("Builder can insert through the engine bridge, undo, redo, and reload", async ({
page,
}) => {
await measure("pages actions open builder for engine bridge", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
});
await waitForCanvasText({ page, text: "Initial content" });
await measure("pages actions insert template through bridge", async () => {
await insertTemplateAfterCanvasText({
page,
anchorText: "Initial content",
templateName: fixture.styledHeadingTemplateName,
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions undo bridge insert", async () => {
await selectSavedAppMenuItem({ page, name: "Undo" });
});
await waitForCanvasTextHidden({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions redo bridge insert", async () => {
await selectSavedAppMenuItem({ page, name: "Redo" });
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
await measure("pages actions reload bridge insert", async () => {
await openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.editorToken,
mode: "content",
});
});
await waitForCanvasText({
page,
text: fixture.styledHeadingTemplateText,
});
});
@@ -1,8 +1,7 @@
import type { BrowserContext, Page } from "@playwright/test";
import { expect, type BrowserContext, type Page } from "@playwright/test";
import { openProjectBuilder, waitForCanvasText } from "../flows/builder";
import { selectCanvasTextInstance } from "../flows/canvas-selection";
import { waitForCanvasTextStyle } from "../flows/canvas-style";
import { addCssDeclaration } from "../flows/css-declaration";
import { waitForChangeToBeSaved } from "../flows/sync-status";
import { createContentModeProject } from "../fixtures/content-mode-suite";
import type { SeededContentModeProject } from "../fixtures/content-mode-project";
@@ -113,16 +112,19 @@ test("Builder CSS variables persist across create, bind, rename, delete, and rel
await measure(
"style panel runtime create and bind css variable",
async () => {
await addCssDeclaration({
page,
property: variableName,
value: "#126bca",
});
await addCssDeclaration({
page,
property: "color",
value: `var(${variableName})`,
const editor = page.getByRole("textbox", {
name: "Styles",
exact: true,
});
await editor.click();
await editor.press("ControlOrMeta+Home");
await editor.press("ArrowDown");
await page.keyboard.insertText(
`${variableName}: #126bca;\ncolor: var(${variableName});\n`
);
const save = waitForChangeToBeSaved({ page });
await editor.press("ControlOrMeta+Enter");
await save;
}
);
@@ -226,18 +228,17 @@ test("Builder CSS variables persist across create, bind, rename, delete, and rel
text: renamedVariableName,
});
await measure(
const canvas = await measure(
"style panel runtime reload builder after css variable delete",
async () => {
await openProjectBuilder({
() =>
openProjectBuilder({
page,
projectId: fixture.projectId,
authToken: fixture.builderToken,
});
}
})
);
await expect(canvas.getByText(text, { exact: true })).toHaveCSS(
renamedVariableName,
""
);
await expectBuildStylesNotToContain({
fixture,
text: renamedVariableName,
});
});