Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: initial target in codegen (#36864)
Pavel Feldman0b7c67293248
diff --git a/packages/recorder/src/recorder.tsx b/packages/recorder/src/recorder.tsxindex c470fe5f23..2630357086 100644--- a/packages/recorder/src/recorder.tsx+++ b/packages/recorder/src/recorder.tsx@@ -52,22 +52,22 @@ export const Recorder: React.FC<RecorderProps> = ({React.useEffect(() => {if (!sources.length)return;- const selectedSource = sources.find(s => s.id === selectedFileId);+ // When no selected file id present, pick the primary source (target language).+ let fileId = selectedFileId ?? sources.find(s => s.isPrimary)?.id;+ const selectedSource = sources.find(s => s.id === fileId);const newestSource = sources.sort((a, b) => b.timestamp - a.timestamp)[0];if (!selectedSource || newestSource.isRecorded !== selectedSource.isRecorded) {- // Debugger kicked in, or recording resumed. Switch selection to the newest source.- setSelectedFileId(newestSource.id);+ // When debugger kicks in, or recording is resumed switch the selection to the newest source.+ fileId = newestSource.id;}+ // If changes above force the selection to change, update the state.+ if (fileId !== selectedFileId)+ setSelectedFileId(fileId);}, [sources, selectedFileId]);const source = React.useMemo(() => {const source = sources.find(s => s.id === selectedFileId);- if (source)- return source;- const primarySource = sources.find(s => s.isPrimary);- if (primarySource)- return primarySource;- return emptySource();+ return source ?? emptySource();}, [sources, selectedFileId]);const [locator, setLocator] = React.useState('');diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.tsindex e7ed9a9526..57b20f92c1 100644--- a/tests/library/inspector/inspectorTest.ts+++ b/tests/library/inspector/inspectorTest.ts@@ -28,7 +28,7 @@ export { expect } from '@playwright/test';type CLITestArgs = {recorderPageGetter: () => Promise<Page>;closeRecorder: () => Promise<void>;- openRecorder: (options?: { testIdAttributeName: string }) => Promise<{ recorder: Recorder, page: Page }>;+ openRecorder: (options?: { testIdAttributeName?: string, language?: string }) => Promise<{ recorder: Recorder, page: Page }>;runCLI: (args: string[], options?: { autoExitWhen?: string }) => CLIMock;};@@ -87,7 +87,6 @@ export const test = contextTest.extend<CLITestArgs>({openRecorder: async ({ context, recorderPageGetter }, use) => {await use(async options => {await (context as any)._enableRecorder({- language: 'javascript',mode: 'recording',...options});diff --git a/tests/library/inspector/title.spec.ts b/tests/library/inspector/title.spec.tsindex b4dd50ee36..a2569e74e6 100644--- a/tests/library/inspector/title.spec.ts+++ b/tests/library/inspector/title.spec.ts@@ -57,3 +57,9 @@ test('should update primary page URL when original primary closes', async ({`Playwright Inspector - ${server.PREFIX}/dom.html`,);});++test('should render primary language', async ({ openRecorder }) => {+ const { recorder } = await openRecorder({ language: 'python' });+ await recorder.setContentAndWait('');+ await expect(recorder.recorderPage.getByRole('combobox', { name: 'Source chooser' })).toHaveValue('python');+});