Skip to content

Commit d2ffd0d

Browse files
authored
fix(ui): collapse multiline log entries (#37854)
1 parent 791ae34 commit d2ffd0d

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

packages/playwright-core/src/utils/isomorphic/protocolFormatter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
import { methodMetainfo } from './protocolMetainfo';
1818

1919
export function formatProtocolParam(params: Record<string, string> | undefined, alternatives: string): string | undefined {
20+
return _formatProtocolParam(params, alternatives)?.replaceAll('\n', '\\n');
21+
}
22+
23+
function _formatProtocolParam(params: Record<string, string> | undefined, alternatives: string): string | undefined {
2024
if (!params)
2125
return undefined;
2226

tests/library/inspector/pause.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ it('should not reset timeouts', async ({ page, recorderPageGetter, closeRecorder
4848
expect(error.message).toContain('page.goto: Timeout 1000ms exceeded.');
4949
});
5050

51+
it('should collapse log entries to a single line', async ({ page, recorderPageGetter }) => {
52+
const scriptPromise = (async () => {
53+
// @ts-ignore
54+
await page.pause({ __testHookKeepTestTimeout: true });
55+
await page.keyboard.type(`Hello
56+
world`);
57+
})();
58+
59+
const recorderPage = await recorderPageGetter();
60+
await recorderPage.click('[title="Resume (F8)"]');
61+
await expect(recorderPage.locator('.call-log-call').nth(1)).toContainText('Type "Hello\\nworld"');
62+
await scriptPromise;
63+
});
64+
5165
it.describe('pause', () => {
5266
it.skip(({ mode }) => mode !== 'default');
5367

tests/playwright-test/ui-mode-trace.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,28 @@ test('should show custom fixture titles in actions tree', async ({ runUITest })
480480
]);
481481
});
482482

483+
test('should collapse log entries to a single line', async ({ runUITest }) => {
484+
const { page } = await runUITest({
485+
'a.test.ts': `
486+
import { test, expect } from '@playwright/test';
487+
488+
test('multiline test', async ({ page }) => {
489+
await page.keyboard.type(\`line1
490+
line2\`);
491+
});
492+
`,
493+
});
494+
495+
await page.getByText('multiline test').dblclick();
496+
const listItem = page.getByTestId('actions-tree').getByRole('treeitem');
497+
await expect(listItem, 'action list').toHaveText([
498+
/Before Hooks[\d.]+m?s/,
499+
/Type "line1\\nline2"[\d.]+m?s/,
500+
/After Hooks[\d.]+m?s/,
501+
]);
502+
});
503+
504+
483505
test('should hide boxed fixtures and contents, reveal upon show all actions setting', async ({ runUITest }) => {
484506
const { page } = await runUITest({
485507
'a.test.ts': `

0 commit comments

Comments
 (0)