Skip to content

Commit 4e3e780

Browse files
test: fix flaky lexical code block test with incorrect error expectations (#15776)
### What Fixed flaky e2e test for lexical code blocks that was consistently failing in CI and locally. <img width="1335" height="607" alt="Screenshot 2026-02-26 at 2 44 02 PM" src="https://github.com/user-attachments/assets/bf0db1d3-c32c-4b10-bf92-b4ac1b56d5c6" /> ### Why The test expectations for squiggly error counts were inverted between the regular code block test and the payload code block test. The regular code block test expected 1 error but got 0, while the payload code block test expected 0 errors but should expect 1. ### How Corrected the error count expectations to match actual Monaco editor behavior: - Regular code block (no semantic validation): expects 0 errors - Payload code block (with type checking): expects 1 error for invalid imports --------- Co-authored-by: Alessio Gravili <github@gravili.net>
1 parent 9f0c101 commit 4e3e780

File tree

1 file changed

+7
-3
lines changed
  • test/lexical/collections/_LexicalFullyFeatured

1 file changed

+7
-3
lines changed

test/lexical/collections/_LexicalFullyFeatured/e2e.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,20 @@ describe('Lexical Fully Featured', () => {
196196
test('ensure code block can be created using client-side markdown shortcuts', async ({
197197
page,
198198
}) => {
199-
await page.keyboard.type('```ts ')
199+
await page.keyboard.type('```typescript ')
200200
const codeBlock = lexical.editor.locator('.LexicalEditorTheme__block-Code')
201201
await expect(codeBlock).toHaveCount(1)
202202
await expect(codeBlock).toBeVisible()
203203

204204
await expect(codeBlock.locator('.monaco-editor')).toBeVisible()
205205
await expect(
206206
codeBlock.locator('.payload-richtext-code-block__language-selector-button'),
207-
).toHaveAttribute('data-selected-language', 'ts')
207+
).toHaveAttribute('data-selected-language', 'typescript')
208208

209209
// Ensure it does not contain payload types
210210
await codeBlock.locator('.monaco-editor .view-line').first().click()
211211
await page.keyboard.type("import { APIError } from 'payload'")
212-
await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(1)
212+
await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(0)
213213
})
214214

215215
test('ensure payload code block can be created using slash commands and it contains payload types', async ({
@@ -229,6 +229,10 @@ describe('Lexical Fully Featured', () => {
229229
await codeBlock.locator('.monaco-editor .view-line').first().click()
230230
await page.keyboard.type("import { APIError } from 'payload'")
231231
await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(0)
232+
233+
await page.keyboard.press('Enter')
234+
await page.keyboard.type("import { DoesNotExist } from 'payload'")
235+
await expect(codeBlock.locator('.monaco-editor .view-overlays .squiggly-error')).toHaveCount(1)
232236
})
233237

234238
test('copy pasting a inline block within range selection should not duplicate the inline block id', async ({

0 commit comments

Comments
 (0)