Skip to content

Commit

Permalink
chore: input text using fill to reduce test flakiness (#8545)
Browse files Browse the repository at this point in the history
  • Loading branch information
thenbe authored Jan 16, 2023
1 parent 770ab1f commit 5e12d3e
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1808,8 +1808,8 @@ test.describe('Actions', () => {

test('Form fields are persisted', async ({ page, javaScriptEnabled }) => {
await page.goto('/actions/form-errors-persist-fields');
await page.type('input[name="username"]', 'foo');
await page.type('input[name="password"]', 'bar');
await page.locator('input[name="username"]').fill('foo');
await page.locator('input[name="password"]').fill('bar');
await Promise.all([
page.waitForRequest((request) =>
request.url().includes('/actions/form-errors-persist-fields')
Expand All @@ -1830,11 +1830,8 @@ test.describe('Actions', () => {

expect(await page.textContent('pre')).toBe(JSON.stringify(null));

await page.type('input[name="username"]', 'foo');
await Promise.all([
page.waitForRequest((request) => request.url().includes('/actions/success-data')),
page.click('button[formenctype="multipart/form-data"]')
]);
await page.locator('input[name="username"]').fill('foo');
await page.locator('button[formenctype="multipart/form-data"]').click();

await expect(page.locator('pre')).toHaveText(JSON.stringify({ result: 'foo' }));
});
Expand All @@ -1844,11 +1841,8 @@ test.describe('Actions', () => {

expect(await page.textContent('pre')).toBe(JSON.stringify(null));

await page.type('input[name="username"]', 'bar');
await Promise.all([
page.waitForRequest((request) => request.url().includes('/actions/success-data')),
page.click('button[formenctype="application/x-www-form-urlencoded"]')
]);
await page.locator('input[name="username"]').fill('bar');
await page.locator('button[formenctype="application/x-www-form-urlencoded"]').click();

await expect(page.locator('pre')).toHaveText(JSON.stringify({ result: 'bar' }));
});
Expand Down Expand Up @@ -1917,11 +1911,8 @@ test.describe('Actions', () => {
expect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));
expect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));

await page.type('input[name="username"]', 'foo');
await Promise.all([
page.waitForRequest((request) => request.url().includes('/actions/enhance')),
page.click('button.form1')
]);
await page.locator('input[name="username"]').fill('foo');
await page.locator('button.form1').click();

await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ result: 'foo' }));
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ result: 'foo' }));
Expand Down Expand Up @@ -1950,11 +1941,8 @@ test.describe('Actions', () => {

expect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));

await page.type('input[name="username"]', 'foo');
await Promise.all([
page.waitForRequest((request) => request.url().includes('/actions/enhance')),
page.click('button.form1-register')
]);
await page.locator('input[name="username"]').fill('foo');
await page.locator('button.form1-register').click();

await expect(page.locator('pre.formdata1')).toHaveText(
JSON.stringify({ result: 'register: foo' })
Expand Down

0 comments on commit 5e12d3e

Please sign in to comment.