Skip to content

Commit 2fce5d9

Browse files
committed
PRO-14812 fix: really skip skipped tests in Playwright
1 parent ee8b0d9 commit 2fce5d9

File tree

7 files changed

+52
-33
lines changed

7 files changed

+52
-33
lines changed

src/types/checks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* This type checks that the type `true` is passed to it.
33
*/
4-
export type Expect<T extends true> = T;
4+
export type Expect<Type extends true> = Type;
55

66
/**
77
* Returns `true` if types are exactly equal and `false` otherwise.
88
* IsEqual<{foo: string}, {foo: string}> = true.
99
* IsEqual<{readonly foo: string}, {foo: string}> = false.
1010
*/
1111
export type IsEqual<X, Y> =
12-
(<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
12+
(<Type>() => Type extends X ? 1 : 2) extends <Type>() => Type extends Y ? 1 : 2 ? true : false;
1313

1414
/**
1515
* Returns `true` if key is readonly in object and `false` otherwise.

src/utils/report/client/groupLogEvents.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LogEventType} from '../../../constants/internal';
1+
import {LogEventStatus, LogEventType} from '../../../constants/internal';
22

33
import type {LogEvent, LogEventWithChildren} from '../../../types/internal';
44

@@ -16,14 +16,18 @@ export const groupLogEvents = (logEvents: readonly LogEvent[]): readonly LogEven
1616
LogEventType.InternalAssert,
1717
];
1818

19+
const isTopLevelEvent = (logEvent: LogEvent): boolean =>
20+
topLevelTypes.includes(logEvent.type) ||
21+
logEvent.payload?.logEventStatus === LogEventStatus.Failed;
22+
1923
const result: LogEventWithChildren[] = [];
2024

2125
for (const logEvent of logEvents) {
2226
const last = result.at(-1);
2327
const newEvent: LogEventWithChildren = {children: [], ...logEvent};
2428

25-
if (topLevelTypes.includes(logEvent.type)) {
26-
if (last && !topLevelTypes.includes(last.type)) {
29+
if (isTopLevelEvent(logEvent)) {
30+
if (last && !isTopLevelEvent(last)) {
2731
const firstTopLevel: LogEventWithChildren = {
2832
children: [...result],
2933
message: 'Initialization',
@@ -38,7 +42,7 @@ export const groupLogEvents = (logEvents: readonly LogEvent[]): readonly LogEven
3842
}
3943

4044
result.push(newEvent);
41-
} else if (last && topLevelTypes.includes(last.type)) {
45+
} else if (last && isTopLevelEvent(last)) {
4246
(last.children as LogEventWithChildren[]).push(newEvent);
4347
} else {
4448
result.push(newEvent);

src/utils/report/client/render/TestRunDescription.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
3131
const valueWithLinks = parseMarkdownLinks`${value}`;
3232
const metaHtml = (
3333
<>
34-
<dt class="test-description__term">{key}</dt>
34+
<dt class="test-description__term">{key}</dt>{' '}
3535
<dd class="test-description__definition">{valueWithLinks}</dd>
3636
</>
3737
);
@@ -49,7 +49,7 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
4949

5050
traceHtml = (
5151
<>
52-
<dt class="test-description__term">{traceLabel}</dt>
52+
<dt class="test-description__term">{traceLabel}</dt>{' '}
5353
<dd class="test-description__definition">
5454
<a href={traceUrl} download={traceName} aria-label={traceLabel}>
5555
{traceName}
@@ -63,11 +63,11 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
6363
<dl class="test-description" aria-label="Test meta data">
6464
<List elements={metaHtmls} />
6565
{traceHtml}
66-
<dt class="test-description__term">Date</dt>
66+
<dt class="test-description__term">Date</dt>{' '}
6767
<dd class="test-description__definition">
6868
<DatesInterval endTimeInMs={endTimeInMs} startTimeInMs={startTimeInMs} />
6969
</dd>
70-
<dt class="test-description__term">Duration</dt>
70+
<dt class="test-description__term">Duration</dt>{' '}
7171
<dd class="test-description__definition">
7272
<Duration durationInMs={endTimeInMs - startTimeInMs} />
7373
</dd>

src/utils/test/beforeTest.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {getTestFnAndReject} from './getTestFnAndReject';
2121

2222
import type {TestRunEvent, TestUnit, UtcTimeInMs} from '../../types/internal';
2323

24-
import {test} from '@playwright/test';
24+
import {test as playwrightTest} from '@playwright/test';
2525

2626
const additionToPlaywrightTestTimeout = 500;
2727

@@ -59,7 +59,9 @@ export const beforeTest = ({
5959
const testTimeout =
6060
IS_DEBUG || isUiMode ? MAX_TIMEOUT_IN_MS : (options.testTimeout ?? testTimeoutFromConfig);
6161

62-
test.setTimeout(testTimeout + additionToPlaywrightTestTimeout + (Date.now() - startTimeInMs));
62+
playwrightTest.setTimeout(
63+
testTimeout + additionToPlaywrightTestTimeout + (Date.now() - startTimeInMs),
64+
);
6365

6466
setTestIdleTimeout(testIdleTimeout);
6567
setTestTimeout(testTimeout);
@@ -75,6 +77,7 @@ export const beforeTest = ({
7577
const {onlog, reject, testFnWithReject} = getTestFnAndReject({
7678
isSkipped,
7779
runId,
80+
skipReason,
7881
testFn,
7982
testIdleTimeout,
8083
testTimeout,

src/utils/test/getTestFnAndReject.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ import {getPromiseWithResolveAndReject} from '../promise';
88

99
import type {Onlog, RejectTestRun, RunId, TestFn, Void} from '../../types/internal';
1010

11+
import {test as playwrightTest} from '@playwright/test';
12+
1113
type Options = Readonly<{
1214
isSkipped: boolean;
1315
runId: RunId;
16+
skipReason: string | undefined;
1417
testFn: TestFn;
1518
testIdleTimeout: number;
1619
testTimeout: number;
1720
}>;
1821

1922
type Return = Readonly<{onlog: Onlog; reject: RejectTestRun; testFnWithReject: TestFn}>;
2023

21-
const skippedTestFnAndReject: Return = {
22-
onlog: () => undefined,
23-
reject: () => undefined,
24-
testFnWithReject: () => RESOLVED_PROMISE,
25-
};
26-
2724
/**
2825
* Get test function with execution timeout, idle timeout, reject and onlog functions,
2926
* by isSkipped flag, test function, runId, test execution timeout and test idle timeouts.
@@ -32,12 +29,23 @@ const skippedTestFnAndReject: Return = {
3229
export const getTestFnAndReject = ({
3330
isSkipped,
3431
runId,
32+
skipReason,
3533
testFn,
3634
testIdleTimeout,
3735
testTimeout,
3836
}: Options): Return => {
3937
if (isSkipped) {
40-
return skippedTestFnAndReject;
38+
return {
39+
onlog: () => undefined,
40+
reject: () => undefined,
41+
testFnWithReject: () => {
42+
try {
43+
playwrightTest.skip(true, skipReason);
44+
} catch {}
45+
46+
return RESOLVED_PROMISE;
47+
},
48+
};
4149
}
4250

4351
const {

src/utils/test/waitBeforeRetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {getPreviousRunId} from './getPreviousRunId';
77

88
import type {FullTestRun, RunId, TestStaticOptions} from '../../types/internal';
99

10-
import {test} from '@playwright/test';
10+
import {test as playwrightTest} from '@playwright/test';
1111

1212
const additionToTimeout = 10_000;
1313

@@ -57,7 +57,7 @@ export const waitBeforeRetry = async (
5757
return;
5858
}
5959

60-
test.setTimeout(timeoutInMs + additionToTimeout);
60+
playwrightTest.setTimeout(timeoutInMs + additionToTimeout);
6161

6262
const timeoutObject = setInterval(() => {
6363
void writeLogEventTime();

styles/report.css

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ body {
8282
margin: 0;
8383
padding: 0;
8484
width: 100%;
85-
height: auto;
8685
min-height: 100vh;
8786
font-family: system-ui;
8887
font-size: var(--font-size);
@@ -121,6 +120,7 @@ a:visited {
121120
.errors,
122121
.warnings {
123122
padding: 2px var(--retry-padding);
123+
overflow-wrap: break-word;
124124
}
125125
.errors__error {
126126
margin: 4px 0;
@@ -146,7 +146,6 @@ a:visited {
146146
.column-1 {
147147
grid-area: column-1;
148148
width: 100vw;
149-
overflow: hidden;
150149
}
151150
.header,
152151
.column-1 {
@@ -176,6 +175,9 @@ a:visited {
176175
background: var(--item-bg-color);
177176
}
178177
.main {
178+
overflow: hidden;
179+
contain: layout;
180+
container-type: inline-size;
179181
grid-area: main;
180182
min-width: 0;
181183
display: flex;
@@ -553,7 +555,7 @@ a:visited {
553555
color: var(--subtitle-color);
554556
}
555557
.test-description__term::after {
556-
content: ':\00a0';
558+
content: ':';
557559
}
558560
.test-description__definition {
559561
margin: 0;
@@ -1073,9 +1075,12 @@ a:visited {
10731075
.test-link[aria-current='true'] {
10741076
--box-shadow-width: 1px;
10751077

1076-
box-shadow: 0 0 0 var(--box-shadow-width) var(--drag-container-bg-color) inset;
1078+
box-shadow: 0 0 0 var(--box-shadow-width) var(--passed-color) inset;
10771079
cursor: default;
10781080
}
1081+
.test-link[aria-current='true'][data-status='failed'] {
1082+
box-shadow: 0 0 0 var(--box-shadow-width) var(--failed-color) inset;
1083+
}
10791084
.test-link[data-status='failed'],
10801085
.test-link[data-status='unknown'],
10811086
.step[data-status='failed'] > .step__head,
@@ -1206,7 +1211,7 @@ a:visited {
12061211
overflow: hidden;
12071212
border-radius: var(--main-radius);
12081213
background: var(--secondary-bg-color);
1209-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
1214+
box-shadow: 0 0 10px rgb(0, 0, 0, 0.3);
12101215
}
12111216
.screenshot-dialog[open] {
12121217
display: flex;
@@ -1226,7 +1231,7 @@ a:visited {
12261231
text-overflow: ellipsis;
12271232
}
12281233
.screenshot-dialog::backdrop {
1229-
background: rgba(0, 0, 0, 0.5);
1234+
background: rgb(0, 0, 0, 0.5);
12301235
}
12311236
.screenshot-dialog__main {
12321237
padding: var(--padding);
@@ -1348,10 +1353,6 @@ button:focus-visible,
13481353
outline-color: var(--accent-color);
13491354
outline-offset: -2px;
13501355
}
1351-
.main {
1352-
contain: layout;
1353-
container-type: inline-size;
1354-
}
13551356
@container (min-width: 350px) {
13561357
.test-link__name,
13571358
.step__name {
@@ -1361,17 +1362,20 @@ button:focus-visible,
13611362
}
13621363

13631364
@media (min-width: 390px) {
1365+
body {
1366+
height: 100vh;
1367+
}
13641368
.main {
13651369
flex-direction: row;
13661370
}
13671371
.column-2 {
1372+
overflow-y: auto;
13681373
width: calc(40% - var(--drag-container-width));
13691374
}
13701375
.column-3 {
1371-
max-height: 100vh;
1376+
overflow-y: auto;
13721377
will-change: transform;
13731378
flex: 1 0 180px;
1374-
overflow-y: scroll;
13751379
}
13761380
.drag-container {
13771381
position: relative;

0 commit comments

Comments
 (0)