Skip to content

Commit a0d82a8

Browse files
committed
move closer to other button tests
1 parent b4da04a commit a0d82a8

File tree

1 file changed

+27
-27
lines changed
  • packages/kit/test/apps/basics/test

1 file changed

+27
-27
lines changed

packages/kit/test/apps/basics/test/test.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,19 +1138,28 @@ test.describe('Actions', () => {
11381138
);
11391139
});
11401140

1141-
test('use:enhance does not clear form on second submit', async ({ page }) => {
1141+
test('use:enhance button with formenctype', async ({ page }) => {
11421142
await page.goto('/actions/enhance');
11431143

1144-
await page.locator('input[name="message"]').fill('hello');
1144+
expect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));
1145+
expect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));
11451146

1146-
await page.locator('.form3').click();
1147-
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));
1148-
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));
1147+
const fileInput = page.locator('input[type="file"].form-file-input');
11491148

1150-
await page.locator('.form3').click();
1151-
await page.waitForTimeout(0); // wait for next tick
1152-
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));
1153-
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));
1149+
await fileInput.setInputFiles({
1150+
name: 'test-file.txt',
1151+
mimeType: 'text/plain',
1152+
buffer: Buffer.from('this is test')
1153+
});
1154+
1155+
await page.locator('button.form-file-submit').click();
1156+
1157+
await expect(page.locator('pre.formdata1')).toHaveText(
1158+
JSON.stringify({ result: 'file name:test-file.txt' })
1159+
);
1160+
await expect(page.locator('pre.formdata2')).toHaveText(
1161+
JSON.stringify({ result: 'file name:test-file.txt' })
1162+
);
11541163
});
11551164

11561165
test('use:enhance has `application/x-www-form-urlencoded` as default value for `ContentType` request header', async ({
@@ -1180,28 +1189,19 @@ test.describe('Actions', () => {
11801189
await expect(page.locator('input[name="username"]')).toHaveValue('');
11811190
});
11821191

1183-
test('use:enhance button with formenctype', async ({ page }) => {
1192+
test('use:enhance does not clear form on second submit', async ({ page }) => {
11841193
await page.goto('/actions/enhance');
11851194

1186-
expect(await page.textContent('pre.formdata1')).toBe(JSON.stringify(null));
1187-
expect(await page.textContent('pre.formdata2')).toBe(JSON.stringify(null));
1188-
1189-
const fileInput = page.locator('input[type="file"].form-file-input');
1190-
1191-
await fileInput.setInputFiles({
1192-
name: 'test-file.txt',
1193-
mimeType: 'text/plain',
1194-
buffer: Buffer.from('this is test')
1195-
});
1195+
await page.locator('input[name="message"]').fill('hello');
11961196

1197-
await page.locator('button.form-file-submit').click();
1197+
await page.locator('.form3').click();
1198+
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));
1199+
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));
11981200

1199-
await expect(page.locator('pre.formdata1')).toHaveText(
1200-
JSON.stringify({ result: 'file name:test-file.txt' })
1201-
);
1202-
await expect(page.locator('pre.formdata2')).toHaveText(
1203-
JSON.stringify({ result: 'file name:test-file.txt' })
1204-
);
1201+
await page.locator('.form3').click();
1202+
await page.waitForTimeout(0); // wait for next tick
1203+
await expect(page.locator('pre.formdata1')).toHaveText(JSON.stringify({ message: 'hello' }));
1204+
await expect(page.locator('pre.formdata2')).toHaveText(JSON.stringify({ message: 'hello' }));
12051205
});
12061206

12071207
test('redirect', async ({ page, javaScriptEnabled }) => {

0 commit comments

Comments
 (0)