From 08c6072b6d1e195fb07fa376f8fbefd3e21d9d58 Mon Sep 17 00:00:00 2001 From: Wes Date: Mon, 3 Feb 2025 17:48:16 -0700 Subject: [PATCH] fix: e2e tests could have correct input (#4278) - This should make the filling of the request form more reliable and reduce flakiness --- frontend/console/e2e/helpers.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/console/e2e/helpers.ts b/frontend/console/e2e/helpers.ts index e06de4e3af..44af9e1727 100644 --- a/frontend/console/e2e/helpers.ts +++ b/frontend/console/e2e/helpers.ts @@ -24,8 +24,25 @@ export const setVerbRequestBody = async (page: Page, content: string) => { const editor = page.locator('#body-editor .cm-content[contenteditable="true"]') await expect(editor).toBeVisible() + // Ensure editor is ready and focused await editor.click() - await editor.page().keyboard.press('Control+A') - await editor.page().keyboard.press('Delete') + + // Clear the editor by filling with empty content + await editor.fill('') + await expect(editor).toHaveText('') + + // Fill with the new content await editor.fill(content) + + // Verify content matches by normalizing both strings + const normalizeJSON = (str: string) => { + try { + return JSON.stringify(JSON.parse(str)) + } catch { + return str.replace(/\s+/g, '') + } + } + + const editorContent = await editor.textContent() + expect(normalizeJSON(editorContent || '')).toBe(normalizeJSON(content)) }