Skip to content

Commit 3987f20

Browse files
committed
Use fill() for Blueprint Editor E2E test
The character-by-character typing approach was fragile because it triggered CodeMirror's auto-bracket insertion, requiring manual cleanup of extra brackets. Using Playwright's fill() method on the contenteditable element is more reliable because it fills the content directly without triggering auto-completion. Also added a verification step to confirm the blueprint content was inserted before clicking the Run Blueprint button.
1 parent a796c56 commit 3987f20

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

packages/playground/website/playwright/e2e/website-ui.spec.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,7 @@ test('should edit a file in the code editor and see changes in the viewport', as
242242
test('should edit a blueprint in the blueprint editor and recreate the playground', async ({
243243
website,
244244
wordpress,
245-
browserName,
246245
}) => {
247-
test.skip(
248-
browserName === 'firefox',
249-
'Firefox has inconsistent keyboard handling in the CodeMirror editor, causing the blueprint to have validation errors'
250-
);
251246
await website.goto('./');
252247

253248
// Open site manager
@@ -278,28 +273,34 @@ test('should edit a blueprint in the blueprint editor and recreate the playgroun
278273
2
279274
);
280275

281-
// Focus the editor and select all existing content
276+
// Focus the editor
282277
await editor.click();
278+
// Wait a moment for the editor to be fully ready
279+
await website.page.waitForTimeout(100);
280+
281+
// Select all existing content
283282
await website.page.keyboard.press(
284283
process.platform === 'darwin' ? 'Meta+A' : 'Control+A'
285284
);
286285

287-
// Dispatch a paste event to replace content - avoids auto-bracket insertion issues
288-
await website.page.evaluate((content) => {
289-
const dataTransfer = new DataTransfer();
290-
dataTransfer.setData('text/plain', content);
291-
document.activeElement?.dispatchEvent(
292-
new ClipboardEvent('paste', {
293-
clipboardData: dataTransfer,
294-
bubbles: true,
295-
cancelable: true,
296-
})
297-
);
298-
}, blueprint);
286+
// Delete the selected content
287+
await website.page.keyboard.press('Backspace');
288+
await website.page.waitForTimeout(100);
289+
290+
// Use Playwright's fill method on the contenteditable .cm-content element
291+
// This is more reliable than character-by-character typing which triggers
292+
// auto-bracket insertion
293+
const cmContent = editor.locator('.cm-content');
294+
await cmContent.fill(blueprint);
299295

300296
// Wait for validation to complete (linter has 300ms debounce)
301297
await website.page.waitForTimeout(500);
302298

299+
// Verify the blueprint was inserted by checking the editor content
300+
await expect(cmContent).toContainText('writeFile', {
301+
timeout: 5000,
302+
});
303+
303304
// Click the "Run Blueprint" button
304305
await website.page
305306
.getByRole('button', {

0 commit comments

Comments
 (0)