Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): add URL field to annotations for hyperlink display #30665

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions docs/src/test-api/class-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ import { test, expect } from '@playwright/test';
test('basic test', {
annotation: {
type: 'issue',
description: 'https://github.com/microsoft/playwright/issues/23180',
description: 'feature tags API',
url: 'https://github.com/microsoft/playwright/issues/23180'
},
}, async ({ page }) => {
await page.goto('https://playwright.dev/');
Expand All @@ -97,7 +98,8 @@ Test title.
- `tag` ?<[string]|[Array]<[string]>>
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]> Annotation type, for example `'issue'`.
- `description` ?<[string]> Optional annotation description, for example an issue url.
- `description` ?<[string]> Optional annotation description.
- `url` ?<[string]> Optional for example an issue url.

Additional test details.

Expand Down Expand Up @@ -440,6 +442,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

Additional details for all tests in the group.

Expand Down Expand Up @@ -568,6 +571,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -623,6 +627,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -676,6 +681,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -727,6 +733,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -782,6 +789,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -839,6 +847,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -891,6 +900,7 @@ Group title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.describe`] for details description.

Expand Down Expand Up @@ -1109,6 +1119,7 @@ Test title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.(call)`] for test details description.

Expand Down Expand Up @@ -1214,6 +1225,7 @@ Test title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.(call)`] for test details description.

Expand Down Expand Up @@ -1291,6 +1303,7 @@ Test title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.(call)`] for test details description.

Expand Down Expand Up @@ -1436,6 +1449,7 @@ Test title.
- `annotation` ?<[Object]|[Array]<[Object]>>
- `type` <[string]>
- `description` ?<[string]>
- `url` ?<[string]>

See [`method: Test.(call)`] for test details description.

Expand Down
4 changes: 2 additions & 2 deletions packages/html-reporter/src/testCaseView.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const testCase: TestCase = {
projectName: 'chromium',
location: { file: 'test.spec.ts', line: 42, column: 0 },
annotations: [
{ type: 'annotation', description: 'Annotation text' },
{ type: 'annotation', description: 'Another annotation text' },
{ type: 'annotation', description: 'Annotation text', url: 'example url' },
{ type: 'annotation', description: 'Another annotation text', url: 'Another example url' },
],
tags: [],
outcome: 'expected',
Expand Down
2 changes: 1 addition & 1 deletion packages/html-reporter/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type TestFileSummary = {
stats: Stats;
};

export type TestCaseAnnotation = { type: string, description?: string };
export type TestCaseAnnotation = { type: string, description?: string, url?: string};

export type TestCaseSummary = {
testId: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type FixturesWithLocation = {
fixtures: Fixtures;
location: Location;
};
export type Annotation = { type: string, description?: string };
export type Annotation = { type: string, description?: string, url?: string };

export const defaultTimeout = 30000;

Expand Down
6 changes: 4 additions & 2 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,8 @@ interface TestFunction<TestArgs> {
* test('basic test', {
* annotation: {
* type: 'issue',
* description: 'https://github.com/microsoft/playwright/issues/23180',
* description: 'feature tags API',
* url: 'https://github.com/microsoft/playwright/issues/23180'
* },
* }, async ({ page }) => {
* await page.goto('https://playwright.dev/');
Expand Down Expand Up @@ -2232,7 +2233,8 @@ interface TestFunction<TestArgs> {
* test('basic test', {
* annotation: {
* type: 'issue',
* description: 'https://github.com/microsoft/playwright/issues/23180',
* description: 'feature tags API',
* url: 'https://github.com/microsoft/playwright/issues/23180'
* },
* }, async ({ page }) => {
* await page.goto('https://playwright.dev/');
Expand Down
Loading