Skip to content
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
3 changes: 2 additions & 1 deletion packages/html-reporter/src/testCaseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
limitations under the License.
*/

import type { TestCase, TestAnnotation, TestCaseSummary } from './types';
import type { TestAnnotation } from '@playwright/test';
import type { TestCase, TestCaseSummary } from './types';
import * as React from 'react';
import { TabbedPane } from './tabbedPane';
import { AutoChip } from './chip';
Expand Down
4 changes: 1 addition & 3 deletions packages/html-reporter/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import type { Metadata } from '@playwright/test';
import type { TestAnnotation, Metadata } from '@playwright/test';

export type Stats = {
total: number;
Expand Down Expand Up @@ -59,8 +59,6 @@ export type TestFileSummary = {
stats: Stats;
};

export type TestAnnotation = { type: string, description?: string };

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

export const defaultTimeout = 30000;

Expand Down
7 changes: 4 additions & 3 deletions packages/playwright/src/common/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
import { rootTestType } from './testType';
import { computeTestCaseOutcome } from '../isomorphic/teleReceiver';

import type { Annotation, FixturesWithLocation, FullProjectInternal } from './config';
import type { FixturesWithLocation, FullProjectInternal } from './config';
import type { FixturePool } from './fixtures';
import type { TestTypeImpl } from './testType';
import type { TestAnnotation } from '../../types/test';
import type * as reporterTypes from '../../types/testReporter';
import type { FullProject, Location } from '../../types/testReporter';

Expand Down Expand Up @@ -50,7 +51,7 @@ export class Suite extends Base {
_timeout: number | undefined;
_retries: number | undefined;
// Annotations known statically before running the test, e.g. `test.describe.skip()` or `test.describe({ annotation }, body)`.
_staticAnnotations: Annotation[] = [];
_staticAnnotations: TestAnnotation[] = [];
// Explicitly declared tags that are not a part of the title.
_tags: string[] = [];
_modifiers: Modifier[] = [];
Expand Down Expand Up @@ -252,7 +253,7 @@ export class TestCase extends Base implements reporterTypes.TestCase {

expectedStatus: reporterTypes.TestStatus = 'passed';
timeout = 0;
annotations: Annotation[] = [];
annotations: TestAnnotation[] = [];
retries = 0;
repeatEachIndex = 0;

Expand Down
11 changes: 5 additions & 6 deletions packages/playwright/src/isomorphic/teleReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
* limitations under the License.
*/

import type { Metadata } from '../../types/test';
import type { Metadata, TestAnnotation } from '../../types/test';
import type * as reporterTypes from '../../types/testReporter';
import type { Annotation } from '../common/config';
import type { ReporterV2 } from '../reporters/reporterV2';

export type StringIntern = (s: string) => string;
Expand Down Expand Up @@ -68,7 +67,7 @@ export type JsonTestCase = {
retries: number;
tags?: string[];
repeatEachIndex: number;
annotations?: Annotation[];
annotations?: TestAnnotation[];
};

export type JsonTestEnd = {
Expand Down Expand Up @@ -96,7 +95,7 @@ export type JsonTestResultEnd = {
errors: reporterTypes.TestError[];
/** No longer emitted, but kept for backwards compatibility */
attachments?: JsonAttachment[];
annotations?: Annotation[];
annotations?: TestAnnotation[];
};

export type JsonTestStepStart = {
Expand All @@ -113,7 +112,7 @@ export type JsonTestStepEnd = {
duration: number;
error?: reporterTypes.TestError;
attachments?: number[]; // index of JsonTestResultEnd.attachments
annotations?: Annotation[];
annotations?: TestAnnotation[];
};

export type JsonTestResultOnAttach = {
Expand Down Expand Up @@ -503,7 +502,7 @@ export class TeleTestCase implements reporterTypes.TestCase {

expectedStatus: reporterTypes.TestStatus = 'passed';
timeout = 0;
annotations: Annotation[] = [];
annotations: TestAnnotation[] = [];
retries = 0;
tags: string[] = [];
repeatEachIndex = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright/src/reporters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import { codeFrameColumns } from '../transform/babelBundle';
import { resolveReporterOutputPath, stripAnsiEscapes } from '../util';

import type { ReporterV2 } from './reporterV2';
import type { Metadata } from '../../types/test';
import type { Metadata, TestAnnotation } from '../../types/test';
import type * as api from '../../types/testReporter';
import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep, TestAnnotation } from '@html-reporter/types';
import type { HTMLReport, Stats, TestAttachment, TestCase, TestCaseSummary, TestFile, TestFileSummary, TestResult, TestStep } from '@html-reporter/types';
import type { ZipFile } from 'playwright-core/lib/zipBundle';
import type { TransformCallback } from 'stream';

Expand Down
8 changes: 4 additions & 4 deletions packages/playwright/src/worker/testInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { TestTracing } from './testTracing';
import { testInfoError } from './util';

import type { RunnableDescription } from './timeoutManager';
import type { FullProject, TestInfo, TestStatus, TestStepInfo } from '../../types/test';
import type { FullProject, TestInfo, TestStatus, TestStepInfo, TestAnnotation } from '../../types/test';
import type { FullConfig, Location } from '../../types/testReporter';
import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config';
import type { FullConfigInternal, FullProjectInternal } from '../common/config';
import type { AttachmentPayload, StepBeginPayload, StepEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc';
import type { TestCase } from '../common/test';
import type { StackFrame } from '@protocol/channels';
Expand Down Expand Up @@ -90,7 +90,7 @@ export class TestInfoImpl implements TestInfo {
readonly fn: Function;
expectedStatus: TestStatus;
duration: number = 0;
readonly annotations: Annotation[] = [];
readonly annotations: TestAnnotation[] = [];
readonly attachments: TestInfo['attachments'] = [];
status: TestStatus = 'passed';
snapshotSuffix: string = '';
Expand Down Expand Up @@ -501,7 +501,7 @@ export class TestInfoImpl implements TestInfo {
}

export class TestStepInfoImpl implements TestStepInfo {
annotations: Annotation[] = [];
annotations: TestAnnotation[] = [];

private _testInfo: TestInfoImpl;
private _stepId: string;
Expand Down
11 changes: 6 additions & 5 deletions packages/playwright/src/worker/workerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ import { loadTestFile } from '../common/testLoader';

import type { TimeSlot } from './timeoutManager';
import type { Location } from '../../types/testReporter';
import type { Annotation, FullConfigInternal, FullProjectInternal } from '../common/config';
import type { FullConfigInternal, FullProjectInternal } from '../common/config';
import type { DonePayload, RunPayload, TeardownErrorsPayload, TestBeginPayload, TestEndPayload, TestInfoErrorImpl, WorkerInitParams } from '../common/ipc';
import type { Suite, TestCase } from '../common/test';
import type { TestAnnotation } from '../../types/test';

export class WorkerMain extends ProcessRunner {
private _params: WorkerInitParams;
Expand All @@ -60,7 +61,7 @@ export class WorkerMain extends ProcessRunner {
// Suites that had their beforeAll hooks, but not afterAll hooks executed.
// These suites still need afterAll hooks to be executed for the proper cleanup.
// Contains dynamic annotations originated by modifiers with a callback, e.g. `test.skip(() => true)`.
private _activeSuites = new Map<Suite, Annotation[]>();
private _activeSuites = new Map<Suite, TestAnnotation[]>();

constructor(params: WorkerInitParams) {
super();
Expand Down Expand Up @@ -264,7 +265,7 @@ export class WorkerMain extends ProcessRunner {
stepEndPayload => this.dispatchEvent('stepEnd', stepEndPayload),
attachment => this.dispatchEvent('attach', attachment));

const processAnnotation = (annotation: Annotation) => {
const processAnnotation = (annotation: TestAnnotation) => {
testInfo.annotations.push(annotation);
switch (annotation.type) {
case 'fixme':
Expand Down Expand Up @@ -511,12 +512,12 @@ export class WorkerMain extends ProcessRunner {
private async _runBeforeAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl) {
if (this._activeSuites.has(suite))
return;
const extraAnnotations: Annotation[] = [];
const extraAnnotations: TestAnnotation[] = [];
this._activeSuites.set(suite, extraAnnotations);
await this._runAllHooksForSuite(suite, testInfo, 'beforeAll', extraAnnotations);
}

private async _runAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl, type: 'beforeAll' | 'afterAll', extraAnnotations?: Annotation[]) {
private async _runAllHooksForSuite(suite: Suite, testInfo: TestInfoImpl, type: 'beforeAll' | 'afterAll', extraAnnotations?: TestAnnotation[]) {
// Always run all the hooks, and capture the first error.
let firstError: Error | undefined;
for (const hook of this._collectHooksAndModifiers(suite, type, testInfo)) {
Expand Down
2 changes: 2 additions & 0 deletions packages/playwright/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,8 @@ export type TestDetailsAnnotation = {
description?: string;
};

export type TestAnnotation = TestDetailsAnnotation;

export type TestDetails = {
tag?: string | string[];
annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];
Expand Down
5 changes: 2 additions & 3 deletions packages/trace-viewer/src/ui/annotationsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import * as React from 'react';
import './annotationsTab.css';
import { PlaceholderPanel } from './placeholderPanel';
import { linkifyText } from '@web/renderUtils';

type Annotation = { type: string; description?: string; };
import type { TestAnnotation } from '@playwright/test';

export const AnnotationsTab: React.FunctionComponent<{
annotations: Annotation[],
annotations: TestAnnotation[],
}> = ({ annotations }) => {

if (!annotations.length)
Expand Down
3 changes: 2 additions & 1 deletion packages/trace-viewer/src/ui/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { testStatusIcon, testStatusText } from './testUtils';
import type { UITestStatus } from './testUtils';
import type { AfterActionTraceEventAttachment } from '@trace/trace';
import type { HighlightedElement } from './snapshotTab';
import type { TestAnnotation } from '@playwright/test';

export const Workbench: React.FunctionComponent<{
model?: modelUtil.MultiTraceModel,
Expand All @@ -51,7 +52,7 @@ export const Workbench: React.FunctionComponent<{
isLive?: boolean,
hideTimeline?: boolean,
status?: UITestStatus,
annotations?: { type: string; description?: string; }[];
annotations?: TestAnnotation[];
inert?: boolean,
onOpenExternally?: (location: modelUtil.SourceLocation) => void,
revealSource?: boolean,
Expand Down
2 changes: 2 additions & 0 deletions utils/generate_types/overrides-test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export type TestDetailsAnnotation = {
description?: string;
};

export type TestAnnotation = TestDetailsAnnotation;

export type TestDetails = {
tag?: string | string[];
annotation?: TestDetailsAnnotation | TestDetailsAnnotation[];
Expand Down
Loading