From a00e1c9c4be893527e67a5e32d8a4681c272b869 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 19 Sep 2024 10:31:44 -0700 Subject: [PATCH] chore: make recorder tests match order of codegen calls (#32716) --- tests/library/inspector/cli-codegen-1.spec.ts | 122 +++++++++--------- tests/library/inspector/cli-codegen-2.spec.ts | 78 +++++------ tests/library/inspector/cli-codegen-3.spec.ts | 74 +++++------ tests/library/inspector/inspectorTest.ts | 9 +- 4 files changed, 142 insertions(+), 141 deletions(-) diff --git a/tests/library/inspector/cli-codegen-1.spec.ts b/tests/library/inspector/cli-codegen-1.spec.ts index c8046ef9b4..9056a890a1 100644 --- a/tests/library/inspector/cli-codegen-1.spec.ts +++ b/tests/library/inspector/cli-codegen-1.spec.ts @@ -20,8 +20,8 @@ import type { ConsoleMessage } from 'playwright'; test.describe('cli codegen', () => { test.skip(({ mode }) => mode !== 'default'); - test('should click', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should click', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -52,8 +52,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).ClickAsync();`) expect(message.text()).toBe('click'); }); - test('should double click', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should double click', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -93,8 +93,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync() ]); }); - test('should ignore programmatic events', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should ignore programmatic events', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -113,8 +113,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync() expect(clicks.length).toBe(1); }); - test('should click after same-document navigation', async ({ page, openRecorder, server }) => { - const recorder = await openRecorder(); + test('should click after same-document navigation', async ({ openRecorder, server }) => { + const { page, recorder } = await openRecorder(); server.setRoute('/foo.html', (req, res) => { res.setHeader('Content-Type', 'text/html; charset=utf-8'); @@ -143,8 +143,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).DblClickAsync() expect(message.text()).toBe('click'); }); - test('should make a positioned click on a canvas', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should make a positioned click on a canvas', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(` @@ -196,8 +196,8 @@ await page.Locator("canvas").ClickAsync(new LocatorClickOptions expect(message.text()).toBe('click 250 250'); }); - test('should work with TrustedTypes', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should work with TrustedTypes', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(` @@ -234,8 +234,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).ClickAsync();`) expect(message.text()).toBe('click'); }); - test('should not target selector preview by text regexp', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should not target selector preview by text regexp', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(`dummy`); @@ -265,8 +265,8 @@ await page.GetByRole(AriaRole.Button, new() { Name = "Submit" }).ClickAsync();`) expect(message.text()).toBe('click'); }); - test('should fill', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should fill', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); const locator = await recorder.focusElement('input'); @@ -295,8 +295,8 @@ await page.Locator("#input").FillAsync(\"John\");`); expect(message.text()).toBe('John'); }); - test('should fill japanese text', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should fill japanese text', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); // In Japanese, "てすと" or "テスト" means "test". await recorder.setContentAndWait(``); @@ -329,8 +329,8 @@ await page.Locator("#input").FillAsync(\"てすと\");`); expect(message.text()).toBe('てすと'); }); - test('should fill textarea', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should fill textarea', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); const locator = await recorder.focusElement('textarea'); @@ -346,9 +346,9 @@ await page.Locator("#input").FillAsync(\"てすと\");`); expect(message.text()).toBe('John'); }); - test('should fill textarea with new lines at the end', async ({ page, openRecorder }) => { + test('should fill textarea with new lines at the end', async ({ openRecorder }) => { test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/23774' }); - const recorder = await openRecorder(); + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); const textarea = page.locator('textarea'); await textarea.evaluate(e => e.addEventListener('input', () => (window as any).lastInputValue = e.value)); @@ -361,8 +361,8 @@ await page.Locator("#input").FillAsync(\"てすと\");`); expect(sources.get('JavaScript')!.text).not.toContain(`Enter`); }); - test('should fill [contentEditable]', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should fill [contentEditable]', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(`
`); const locator = await recorder.focusElement('div'); @@ -378,8 +378,8 @@ await page.Locator("#input").FillAsync(\"てすと\");`); expect(message.text()).toBe('John Doe'); }); - test('should press', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should press', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -412,8 +412,8 @@ await page.GetByRole(AriaRole.Textbox).PressAsync("Shift+Enter");`); expect(messages[0].text()).toBe('press'); }); - test('should update selected element after pressing Tab', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should update selected element after pressing Tab', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(` @@ -441,8 +441,8 @@ await page.GetByRole(AriaRole.Textbox).PressAsync("Shift+Enter");`); await page.locator('input[name="two"]').fill('barfoo321');`); }); - test('should record ArrowDown', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should record ArrowDown', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -463,8 +463,8 @@ await page.GetByRole(AriaRole.Textbox).PressAsync("Shift+Enter");`); expect(messages[0].text()).toBe('press:ArrowDown'); }); - test('should emit single keyup on ArrowDown', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should emit single keyup on ArrowDown', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -488,8 +488,8 @@ await page.GetByRole(AriaRole.Textbox).PressAsync("Shift+Enter");`); expect(messages[1].text()).toBe('up:ArrowDown'); }); - test('should check', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should check', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -520,8 +520,8 @@ await page.Locator("#checkbox").CheckAsync();`); expect(message.text()).toBe('true'); }); - test('should check a radio button', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should check a radio button', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -539,8 +539,8 @@ await page.Locator("#checkbox").CheckAsync();`); expect(message.text()).toBe('true'); }); - test('should check with keyboard', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should check with keyboard', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -558,8 +558,8 @@ await page.Locator("#checkbox").CheckAsync();`); expect(message.text()).toBe('true'); }); - test('should uncheck', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should uncheck', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(``); @@ -590,8 +590,8 @@ await page.Locator("#checkbox").UncheckAsync();`); expect(message.text()).toBe('false'); }); - test('should select', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should select', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(''); @@ -623,8 +623,8 @@ await page.Locator("#age").SelectOptionAsync(new[] { "2" });`); expect(message.text()).toBe('2'); }); - test('should select with size attribute', async ({ page, openRecorder }) => { - const recorder = await openRecorder(); + test('should select with size attribute', async ({ openRecorder }) => { + const { page, recorder } = await openRecorder(); await recorder.setContentAndWait(`