|
1
|
"use strict"; |
|
2
|
var __create = Object.create; |
|
3
|
var __defProp = Object.defineProperty; |
|
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
5
|
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
6
|
var __getProtoOf = Object.getPrototypeOf; |
|
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
8
|
var __export = (target, all) => { |
|
9
|
for (var name in all) |
|
10
|
__defProp(target, name, { get: all[name], enumerable: true }); |
|
11
|
}; |
|
12
|
var __copyProps = (to, from, except, desc) => { |
|
13
|
if (from && typeof from === "object" || typeof from === "function") { |
|
14
|
for (let key of __getOwnPropNames(from)) |
|
15
|
if (!__hasOwnProp.call(to, key) && key !== except) |
|
16
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
17
|
} |
|
18
|
return to; |
|
19
|
}; |
|
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
21
|
// If the importer is in node compatibility mode or this is not an ESM |
|
22
|
// file that has been converted to a CommonJS file using a Babel- |
|
23
|
// compatible transform (i.e. "__esModule" has not been set), then set |
|
24
|
// "default" to the CommonJS "module.exports" for node compatibility. |
|
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
26
|
mod |
|
27
|
)); |
|
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
29
|
var suiteUtils_exports = {}; |
|
30
|
__export(suiteUtils_exports, { |
|
31
|
applyRepeatEachIndex: () => applyRepeatEachIndex, |
|
32
|
bindFileSuiteToProject: () => bindFileSuiteToProject, |
|
33
|
filterByFocusedLine: () => filterByFocusedLine, |
|
34
|
filterOnly: () => filterOnly, |
|
35
|
filterSuite: () => filterSuite, |
|
36
|
filterTestsRemoveEmptySuites: () => filterTestsRemoveEmptySuites |
|
37
|
}); |
|
38
|
module.exports = __toCommonJS(suiteUtils_exports); |
|
39
|
var import_path = __toESM(require("path")); |
|
40
|
var import_utils = require("playwright-core/lib/utils"); |
|
41
|
var import_util = require("../util"); |
|
42
|
function filterSuite(suite, suiteFilter, testFilter) { |
|
43
|
for (const child of suite.suites) { |
|
44
|
if (!suiteFilter(child)) |
|
45
|
filterSuite(child, suiteFilter, testFilter); |
|
46
|
} |
|
47
|
const filteredTests = suite.tests.filter(testFilter); |
|
48
|
const entries = /* @__PURE__ */ new Set([...suite.suites, ...filteredTests]); |
|
49
|
suite._entries = suite._entries.filter((e) => entries.has(e)); |
|
50
|
} |
|
51
|
function filterTestsRemoveEmptySuites(suite, filter) { |
|
52
|
const filteredSuites = suite.suites.filter((child) => filterTestsRemoveEmptySuites(child, filter)); |
|
53
|
const filteredTests = suite.tests.filter(filter); |
|
54
|
const entries = /* @__PURE__ */ new Set([...filteredSuites, ...filteredTests]); |
|
55
|
suite._entries = suite._entries.filter((e) => entries.has(e)); |
|
56
|
return !!suite._entries.length; |
|
57
|
} |
|
58
|
function bindFileSuiteToProject(project, suite) { |
|
59
|
const relativeFile = import_path.default.relative(project.project.testDir, suite.location.file); |
|
60
|
const fileId = (0, import_utils.calculateSha1)((0, import_utils.toPosixPath)(relativeFile)).slice(0, 20); |
|
61
|
const result = suite._deepClone(); |
|
62
|
result._fileId = fileId; |
|
63
|
result.forEachTest((test, suite2) => { |
|
64
|
suite2._fileId = fileId; |
|
65
|
const [file, ...titles] = test.titlePath(); |
|
66
|
const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")}`; |
|
67
|
const testId = fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20); |
|
68
|
test.id = testId; |
|
69
|
test._projectId = project.id; |
|
70
|
let inheritedRetries; |
|
71
|
let inheritedTimeout; |
|
72
|
for (let parentSuite = suite2; parentSuite; parentSuite = parentSuite.parent) { |
|
73
|
if (parentSuite._staticAnnotations.length) |
|
74
|
test.annotations.unshift(...parentSuite._staticAnnotations); |
|
75
|
if (inheritedRetries === void 0 && parentSuite._retries !== void 0) |
|
76
|
inheritedRetries = parentSuite._retries; |
|
77
|
if (inheritedTimeout === void 0 && parentSuite._timeout !== void 0) |
|
78
|
inheritedTimeout = parentSuite._timeout; |
|
79
|
} |
|
80
|
test.retries = inheritedRetries ?? project.project.retries; |
|
81
|
test.timeout = inheritedTimeout ?? project.project.timeout; |
|
82
|
if (test.annotations.some((a) => a.type === "skip" || a.type === "fixme")) |
|
83
|
test.expectedStatus = "skipped"; |
|
84
|
if (test._poolDigest) |
|
85
|
test._workerHash = `${project.id}-${test._poolDigest}-0`; |
|
86
|
}); |
|
87
|
return result; |
|
88
|
} |
|
89
|
function applyRepeatEachIndex(project, fileSuite, repeatEachIndex) { |
|
90
|
fileSuite.forEachTest((test, suite) => { |
|
91
|
if (repeatEachIndex) { |
|
92
|
const [file, ...titles] = test.titlePath(); |
|
93
|
const testIdExpression = `[project=${project.id}]${(0, import_utils.toPosixPath)(file)}${titles.join("")} (repeat:${repeatEachIndex})`; |
|
94
|
const testId = suite._fileId + "-" + (0, import_utils.calculateSha1)(testIdExpression).slice(0, 20); |
|
95
|
test.id = testId; |
|
96
|
test.repeatEachIndex = repeatEachIndex; |
|
97
|
if (test._poolDigest) |
|
98
|
test._workerHash = `${project.id}-${test._poolDigest}-${repeatEachIndex}`; |
|
99
|
} |
|
100
|
}); |
|
101
|
} |
|
102
|
function filterOnly(suite) { |
|
103
|
if (!suite._getOnlyItems().length) |
|
104
|
return; |
|
105
|
const suiteFilter = (suite2) => suite2._only; |
|
106
|
const testFilter = (test) => test._only; |
|
107
|
return filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter); |
|
108
|
} |
|
109
|
function filterSuiteWithOnlySemantics(suite, suiteFilter, testFilter) { |
|
110
|
const onlySuites = suite.suites.filter((child) => filterSuiteWithOnlySemantics(child, suiteFilter, testFilter) || suiteFilter(child)); |
|
111
|
const onlyTests = suite.tests.filter(testFilter); |
|
112
|
const onlyEntries = /* @__PURE__ */ new Set([...onlySuites, ...onlyTests]); |
|
113
|
if (onlyEntries.size) { |
|
114
|
suite._entries = suite._entries.filter((e) => onlyEntries.has(e)); |
|
115
|
return true; |
|
116
|
} |
|
117
|
return false; |
|
118
|
} |
|
119
|
function filterByFocusedLine(suite, focusedTestFileLines) { |
|
120
|
if (!focusedTestFileLines.length) |
|
121
|
return; |
|
122
|
const matchers = focusedTestFileLines.map(createFileMatcherFromFilter); |
|
123
|
const testFileLineMatches = (testFileName, testLine, testColumn) => matchers.some((m) => m(testFileName, testLine, testColumn)); |
|
124
|
const suiteFilter = (suite2) => !!suite2.location && testFileLineMatches(suite2.location.file, suite2.location.line, suite2.location.column); |
|
125
|
const testFilter = (test) => testFileLineMatches(test.location.file, test.location.line, test.location.column); |
|
126
|
return filterSuite(suite, suiteFilter, testFilter); |
|
127
|
} |
|
128
|
function createFileMatcherFromFilter(filter) { |
|
129
|
const fileMatcher = (0, import_util.createFileMatcher)(filter.re || filter.exact || ""); |
|
130
|
return (testFileName, testLine, testColumn) => fileMatcher(testFileName) && (filter.line === testLine || filter.line === null) && (filter.column === testColumn || filter.column === null); |
|
131
|
} |
|
132
|
// Annotate the CommonJS export names for ESM import in node: |
|
133
|
0 && (module.exports = { |
|
134
|
applyRepeatEachIndex, |
|
135
|
bindFileSuiteToProject, |
|
136
|
filterByFocusedLine, |
|
137
|
filterOnly, |
|
138
|
filterSuite, |
|
139
|
filterTestsRemoveEmptySuites |
|
140
|
}); |
|
141
|
|