Skip to content

Commit

Permalink
fix: e2e tests could have correct input (#4278)
Browse files Browse the repository at this point in the history
- This should make the filling of the request form more reliable and
reduce flakiness
  • Loading branch information
wesbillman authored Feb 4, 2025
1 parent a32e44b commit 08c6072
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions frontend/console/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 08c6072

Please sign in to comment.