chore: do not show other metadata in html report (#35001)

This commit is contained in:
Pavel Feldman 2025-03-03 15:28:18 -08:00 committed by GitHub
parent 85c6405093
commit ee2a5264ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 35 deletions

View File

@ -71,8 +71,6 @@ import LiteYouTube from '@site/src/components/LiteYouTube';
});
```
* HTML reporter now shows the contents of [`property: TestConfig.metadata`].
### Miscellaneous
* New option `contrast` for methods [`method: Page.emulateMedia`] and [`method: Browser.newContext`] allows to emulate the `prefers-contrast` media feature.

View File

@ -23,6 +23,7 @@ import type { Metadata } from '@playwright/test';
import type { CIInfo, GitCommitInfo, MetadataWithCommitInfo } from '@testIsomorphic/types';
import { CopyToClipboardContainer } from './copyToClipboard';
import { linkifyText } from '@web/renderUtils';
import { SearchParamsContext } from './links';
class ErrorBoundary extends React.Component<React.PropsWithChildren<{}>, { error: Error | null, errorInfo: React.ErrorInfo | null }> {
override state: { error: Error | null, errorInfo: React.ErrorInfo | null } = {
@ -55,8 +56,9 @@ export const MetadataView: React.FC<{ metadata: Metadata }> = params => {
};
const InnerMetadataView: React.FC<{ metadata: Metadata }> = params => {
const searchParams = React.useContext(SearchParamsContext);
const commitInfo = params.metadata as MetadataWithCommitInfo;
const otherEntries = Object.entries(params.metadata).filter(([key]) => !ignoreKeys.has(key));
const otherEntries = searchParams.has('show-metadata-other') ? Object.entries(params.metadata).filter(([key]) => !ignoreKeys.has(key)) : [];
const hasMetadata = commitInfo.ci || commitInfo.gitCommit || otherEntries.length > 0;
if (!hasMetadata)
return;

View File

@ -1193,7 +1193,6 @@ for (const useIntermediateMergeReport of [true, false] as const) {
'playwright.config.ts': `
export default {
captureGitInfo: { commit: true },
metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
};
`,
'example.spec.ts': `
@ -1216,21 +1215,13 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- list:
- listitem: "chore(html): make this test look nice"
- listitem: /William <shakespeare@example\\.local>/
- list:
- listitem: "foo : value1"
- listitem: "bar : {\\"prop\\":\\"value2\\"}"
- listitem: "baz : [\\"value3\\",123]"
`);
});
test('should include commit metadata w/ CI', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
'playwright.config.ts': `
export default {
metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
};
`,
'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({}) => { expect(2).toBe(2); });
@ -1256,21 +1247,13 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- listitem:
- 'link "chore(html): make this test look nice"'
- listitem: /William <shakespeare@example\\.local>/
- list:
- listitem: "foo : value1"
- listitem: "bar : {\\"prop\\":\\"value2\\"}"
- listitem: "baz : [\\"value3\\",123]"
`);
});
test('should include PR metadata on GHA', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
'playwright.config.ts': `
export default {
metadata: { foo: 'value1', bar: { prop: 'value2' }, baz: ['value3', 123] }
};
`,
'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({}) => { expect(2).toBe(2); });
@ -1307,10 +1290,6 @@ for (const useIntermediateMergeReport of [true, false] as const) {
- listitem:
- link "My PR"
- listitem: /William <shakespeare@example.local>/
- list:
- listitem: "foo : value1"
- listitem: "bar : {\\"prop\\":\\"value2\\"}"
- listitem: "baz : [\\"value3\\",123]"
`);
});
@ -2770,15 +2749,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
test('should show AI prompt', async ({ runInlineTest, writeFiles, showReport, page }) => {
const files = {
'uncommitted.txt': `uncommitted file`,
'playwright.config.ts': `
export default {
metadata: {
foo: 'value1',
bar: { prop: 'value2' },
baz: ['value3', 123]
}
};
`,
'playwright.config.ts': `export default {}`,
'example.spec.ts': `
import { test, expect } from '@playwright/test';
test('sample', async ({ page }) => {