Skip to content

Commit cd3157a

Browse files
jaysin586claude
andcommitted
fix(test): use getByTestId for reliable fills in webkit
Replace page.fill('[data-testid=...]') with page.getByTestId().fill() to fix webkit race condition where CSS selector fills didn't update Svelte reactive state before assertions fired. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d58dc3d commit cd3157a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/default.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ test.describe('SvelteDiffMatchPatch', () => {
66
})
77

88
test('renders a visible diff', async ({ page }) => {
9-
await page.fill('[data-testid="text1"]', 'hello world')
10-
await page.fill('[data-testid="text2"]', 'hello brave world')
9+
await page.getByTestId('text1').fill('hello world')
10+
await page.getByTestId('text2').fill('hello brave world')
1111
await expect(page.getByTestId('diff-result')).toContainText('brave')
1212
await expect(page.getByTestId('diff-result')).toContainText('hello')
1313
await expect(page.getByTestId('diff-result')).toContainText('world')
1414
})
1515

1616
test('applies custom rendererClasses', async ({ page }) => {
17-
await page.fill('[data-testid="text1"]', 'foo shoo')
18-
await page.fill('[data-testid="text2"]', 'bar shoo')
17+
await page.getByTestId('text1').fill('foo shoo')
18+
await page.getByTestId('text2').fill('bar shoo')
1919
await expect(page.getByTestId('diff-result').locator('.diff-remove')).toBeVisible()
2020
await expect(page.getByTestId('diff-result').locator('.diff-insert')).toBeVisible()
2121
await expect(page.getByTestId('diff-result').locator('.diff-equal')).toBeVisible()

tests/snippets.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ test.describe('SvelteDiffMatchPatch', () => {
1616
})
1717

1818
test('applies custom rendererClasses', async ({ page }) => {
19-
await page.fill('[data-testid="text1"]', 'foo shoo')
20-
await page.fill('[data-testid="text2"]', 'bar shoo')
19+
await page.getByTestId('text1').fill('foo shoo')
20+
await page.getByTestId('text2').fill('bar shoo')
2121
await expect(page.getByTestId('diff-result').locator('.diff-remove')).toBeVisible()
2222
await expect(page.getByTestId('diff-result').locator('.diff-insert')).toBeVisible()
2323
await expect(page.getByTestId('diff-result').locator('.diff-equal')).toBeVisible()

0 commit comments

Comments
 (0)