@ohos-ports/playwright 1.54.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +3984 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/common/config.js +272 -0
  12. package/lib/common/configLoader.js +343 -0
  13. package/lib/common/esmLoaderHost.js +102 -0
  14. package/lib/common/expectBundle.js +49 -0
  15. package/lib/common/expectBundleImpl.js +389 -0
  16. package/lib/common/fixtures.js +302 -0
  17. package/lib/common/globals.js +58 -0
  18. package/lib/common/ipc.js +60 -0
  19. package/lib/common/poolBuilder.js +85 -0
  20. package/lib/common/process.js +104 -0
  21. package/lib/common/suiteUtils.js +149 -0
  22. package/lib/common/test.js +321 -0
  23. package/lib/common/testLoader.js +100 -0
  24. package/lib/common/testType.js +307 -0
  25. package/lib/fsWatcher.js +67 -0
  26. package/lib/index.js +670 -0
  27. package/lib/internalsForTest.js +42 -0
  28. package/lib/isomorphic/events.js +77 -0
  29. package/lib/isomorphic/folders.js +30 -0
  30. package/lib/isomorphic/stringInternPool.js +69 -0
  31. package/lib/isomorphic/teleReceiver.js +507 -0
  32. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  33. package/lib/isomorphic/testServerConnection.js +211 -0
  34. package/lib/isomorphic/testServerInterface.js +16 -0
  35. package/lib/isomorphic/testTree.js +307 -0
  36. package/lib/isomorphic/types.d.js +16 -0
  37. package/lib/loader/loaderMain.js +59 -0
  38. package/lib/matchers/expect.js +326 -0
  39. package/lib/matchers/matcherHint.js +59 -0
  40. package/lib/matchers/matchers.js +360 -0
  41. package/lib/matchers/toBeTruthy.js +71 -0
  42. package/lib/matchers/toEqual.js +94 -0
  43. package/lib/matchers/toHaveURL.js +117 -0
  44. package/lib/matchers/toMatchAriaSnapshot.js +164 -0
  45. package/lib/matchers/toMatchSnapshot.js +338 -0
  46. package/lib/matchers/toMatchText.js +105 -0
  47. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  48. package/lib/plugins/index.js +28 -0
  49. package/lib/plugins/webServerPlugin.js +207 -0
  50. package/lib/program.js +392 -0
  51. package/lib/reporters/base.js +604 -0
  52. package/lib/reporters/blob.js +135 -0
  53. package/lib/reporters/dot.js +82 -0
  54. package/lib/reporters/empty.js +32 -0
  55. package/lib/reporters/github.js +127 -0
  56. package/lib/reporters/html.js +627 -0
  57. package/lib/reporters/internalReporter.js +129 -0
  58. package/lib/reporters/json.js +254 -0
  59. package/lib/reporters/junit.js +230 -0
  60. package/lib/reporters/line.js +113 -0
  61. package/lib/reporters/list.js +230 -0
  62. package/lib/reporters/markdown.js +144 -0
  63. package/lib/reporters/merge.js +533 -0
  64. package/lib/reporters/multiplexer.js +104 -0
  65. package/lib/reporters/reporterV2.js +102 -0
  66. package/lib/reporters/teleEmitter.js +295 -0
  67. package/lib/reporters/versions/blobV1.js +16 -0
  68. package/lib/runner/dispatcher.js +484 -0
  69. package/lib/runner/failureTracker.js +62 -0
  70. package/lib/runner/lastRun.js +74 -0
  71. package/lib/runner/loadUtils.js +299 -0
  72. package/lib/runner/loaderHost.js +89 -0
  73. package/lib/runner/processHost.js +161 -0
  74. package/lib/runner/projectUtils.js +235 -0
  75. package/lib/runner/rebase.js +189 -0
  76. package/lib/runner/reporters.js +162 -0
  77. package/lib/runner/runner.js +110 -0
  78. package/lib/runner/sigIntWatcher.js +96 -0
  79. package/lib/runner/taskRunner.js +127 -0
  80. package/lib/runner/tasks.js +400 -0
  81. package/lib/runner/testGroups.js +117 -0
  82. package/lib/runner/testServer.js +483 -0
  83. package/lib/runner/uiModeReporter.js +30 -0
  84. package/lib/runner/vcs.js +72 -0
  85. package/lib/runner/watchMode.js +391 -0
  86. package/lib/runner/workerHost.js +93 -0
  87. package/lib/third_party/pirates.js +62 -0
  88. package/lib/third_party/tsconfig-loader.js +103 -0
  89. package/lib/transform/babelBundle.js +43 -0
  90. package/lib/transform/babelBundleImpl.js +477 -0
  91. package/lib/transform/compilationCache.js +255 -0
  92. package/lib/transform/esmLoader.js +104 -0
  93. package/lib/transform/portTransport.js +67 -0
  94. package/lib/transform/transform.js +293 -0
  95. package/lib/util.js +426 -0
  96. package/lib/utilsBundle.js +43 -0
  97. package/lib/utilsBundleImpl.js +100 -0
  98. package/lib/worker/fixtureRunner.js +253 -0
  99. package/lib/worker/testInfo.js +474 -0
  100. package/lib/worker/testTracing.js +343 -0
  101. package/lib/worker/timeoutManager.js +174 -0
  102. package/lib/worker/util.js +31 -0
  103. package/lib/worker/workerMain.js +511 -0
  104. package/package.json +64 -0
  105. package/test.d.ts +18 -0
  106. package/test.js +24 -0
  107. package/test.mjs +33 -0
  108. package/types/test.d.ts +10141 -0
  109. package/types/testReporter.d.ts +816 -0
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var matchers_exports = {};
20
+ __export(matchers_exports, {
21
+ toBeAttached: () => toBeAttached,
22
+ toBeChecked: () => toBeChecked,
23
+ toBeDisabled: () => toBeDisabled,
24
+ toBeEditable: () => toBeEditable,
25
+ toBeEmpty: () => toBeEmpty,
26
+ toBeEnabled: () => toBeEnabled,
27
+ toBeFocused: () => toBeFocused,
28
+ toBeHidden: () => toBeHidden,
29
+ toBeInViewport: () => toBeInViewport,
30
+ toBeOK: () => toBeOK,
31
+ toBeVisible: () => toBeVisible,
32
+ toContainClass: () => toContainClass,
33
+ toContainText: () => toContainText,
34
+ toHaveAccessibleDescription: () => toHaveAccessibleDescription,
35
+ toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage,
36
+ toHaveAccessibleName: () => toHaveAccessibleName,
37
+ toHaveAttribute: () => toHaveAttribute,
38
+ toHaveCSS: () => toHaveCSS,
39
+ toHaveClass: () => toHaveClass,
40
+ toHaveCount: () => toHaveCount,
41
+ toHaveId: () => toHaveId,
42
+ toHaveJSProperty: () => toHaveJSProperty,
43
+ toHaveRole: () => toHaveRole,
44
+ toHaveText: () => toHaveText,
45
+ toHaveTitle: () => toHaveTitle,
46
+ toHaveURL: () => toHaveURL,
47
+ toHaveValue: () => toHaveValue,
48
+ toHaveValues: () => toHaveValues,
49
+ toPass: () => toPass
50
+ });
51
+ module.exports = __toCommonJS(matchers_exports);
52
+ var import_utils = require("@ohos-ports/playwright-core/lib/utils");
53
+ var import_utils2 = require("@ohos-ports/playwright-core/lib/utils");
54
+ var import_util = require("../util");
55
+ var import_toBeTruthy = require("./toBeTruthy");
56
+ var import_toEqual = require("./toEqual");
57
+ var import_toHaveURL = require("./toHaveURL");
58
+ var import_toMatchText = require("./toMatchText");
59
+ var import_config = require("../common/config");
60
+ var import_globals = require("../common/globals");
61
+ var import_testInfo = require("../worker/testInfo");
62
+ function toBeAttached(locator, options) {
63
+ const attached = !options || options.attached === void 0 || options.attached;
64
+ const expected = attached ? "attached" : "detached";
65
+ const arg = attached ? "" : "{ attached: false }";
66
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => {
67
+ return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout });
68
+ }, options);
69
+ }
70
+ function toBeChecked(locator, options) {
71
+ const checked = options?.checked;
72
+ const indeterminate = options?.indeterminate;
73
+ const expectedValue = {
74
+ checked,
75
+ indeterminate
76
+ };
77
+ let expected;
78
+ let arg;
79
+ if (options?.indeterminate) {
80
+ expected = "indeterminate";
81
+ arg = `{ indeterminate: true }`;
82
+ } else {
83
+ expected = options?.checked === false ? "unchecked" : "checked";
84
+ arg = options?.checked === false ? `{ checked: false }` : "";
85
+ }
86
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => {
87
+ return await locator._expect("to.be.checked", { isNot, timeout, expectedValue });
88
+ }, options);
89
+ }
90
+ function toBeDisabled(locator, options) {
91
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => {
92
+ return await locator._expect("to.be.disabled", { isNot, timeout });
93
+ }, options);
94
+ }
95
+ function toBeEditable(locator, options) {
96
+ const editable = !options || options.editable === void 0 || options.editable;
97
+ const expected = editable ? "editable" : "readOnly";
98
+ const arg = editable ? "" : "{ editable: false }";
99
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => {
100
+ return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout });
101
+ }, options);
102
+ }
103
+ function toBeEmpty(locator, options) {
104
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => {
105
+ return await locator._expect("to.be.empty", { isNot, timeout });
106
+ }, options);
107
+ }
108
+ function toBeEnabled(locator, options) {
109
+ const enabled = !options || options.enabled === void 0 || options.enabled;
110
+ const expected = enabled ? "enabled" : "disabled";
111
+ const arg = enabled ? "" : "{ enabled: false }";
112
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => {
113
+ return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout });
114
+ }, options);
115
+ }
116
+ function toBeFocused(locator, options) {
117
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => {
118
+ return await locator._expect("to.be.focused", { isNot, timeout });
119
+ }, options);
120
+ }
121
+ function toBeHidden(locator, options) {
122
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => {
123
+ return await locator._expect("to.be.hidden", { isNot, timeout });
124
+ }, options);
125
+ }
126
+ function toBeVisible(locator, options) {
127
+ const visible = !options || options.visible === void 0 || options.visible;
128
+ const expected = visible ? "visible" : "hidden";
129
+ const arg = visible ? "" : "{ visible: false }";
130
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => {
131
+ return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout });
132
+ }, options);
133
+ }
134
+ function toBeInViewport(locator, options) {
135
+ return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => {
136
+ return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout });
137
+ }, options);
138
+ }
139
+ function toContainText(locator, expected, options = {}) {
140
+ if (Array.isArray(expected)) {
141
+ return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
142
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
143
+ return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
144
+ }, expected, { ...options, contains: true });
145
+ } else {
146
+ return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => {
147
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
148
+ return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout });
149
+ }, expected, options);
150
+ }
151
+ }
152
+ function toHaveAccessibleDescription(locator, expected, options) {
153
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => {
154
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
155
+ return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout });
156
+ }, expected, options);
157
+ }
158
+ function toHaveAccessibleName(locator, expected, options) {
159
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => {
160
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
161
+ return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout });
162
+ }, expected, options);
163
+ }
164
+ function toHaveAccessibleErrorMessage(locator, expected, options) {
165
+ return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => {
166
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true });
167
+ return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout });
168
+ }, expected, options);
169
+ }
170
+ function toHaveAttribute(locator, name, expected, options) {
171
+ if (!options) {
172
+ if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) {
173
+ options = expected;
174
+ expected = void 0;
175
+ }
176
+ }
177
+ if (expected === void 0) {
178
+ return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => {
179
+ return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout });
180
+ }, options);
181
+ }
182
+ return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => {
183
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
184
+ return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout });
185
+ }, expected, options);
186
+ }
187
+ function toHaveClass(locator, expected, options) {
188
+ if (Array.isArray(expected)) {
189
+ return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
190
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
191
+ return await locator._expect("to.have.class.array", { expectedText, isNot, timeout });
192
+ }, expected, options);
193
+ } else {
194
+ return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => {
195
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
196
+ return await locator._expect("to.have.class", { expectedText, isNot, timeout });
197
+ }, expected, options);
198
+ }
199
+ }
200
+ function toContainClass(locator, expected, options) {
201
+ if (Array.isArray(expected)) {
202
+ if (expected.some((e) => (0, import_utils.isRegExp)(e)))
203
+ throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`);
204
+ return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
205
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
206
+ return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout });
207
+ }, expected, options);
208
+ } else {
209
+ if ((0, import_utils.isRegExp)(expected))
210
+ throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`);
211
+ return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => {
212
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
213
+ return await locator._expect("to.contain.class", { expectedText, isNot, timeout });
214
+ }, expected, options);
215
+ }
216
+ }
217
+ function toHaveCount(locator, expected, options) {
218
+ return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => {
219
+ return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout });
220
+ }, expected, options);
221
+ }
222
+ function toHaveCSS(locator, name, expected, options) {
223
+ return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => {
224
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
225
+ return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout });
226
+ }, expected, options);
227
+ }
228
+ function toHaveId(locator, expected, options) {
229
+ return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => {
230
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
231
+ return await locator._expect("to.have.id", { expectedText, isNot, timeout });
232
+ }, expected, options);
233
+ }
234
+ function toHaveJSProperty(locator, name, expected, options) {
235
+ return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => {
236
+ return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout });
237
+ }, expected, options);
238
+ }
239
+ function toHaveRole(locator, expected, options) {
240
+ if (!(0, import_utils.isString)(expected))
241
+ throw new Error(`"role" argument in toHaveRole must be a string`);
242
+ return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => {
243
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
244
+ return await locator._expect("to.have.role", { expectedText, isNot, timeout });
245
+ }, expected, options);
246
+ }
247
+ function toHaveText(locator, expected, options = {}) {
248
+ if (Array.isArray(expected)) {
249
+ return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
250
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
251
+ return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
252
+ }, expected, options);
253
+ } else {
254
+ return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => {
255
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase });
256
+ return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout });
257
+ }, expected, options);
258
+ }
259
+ }
260
+ function toHaveValue(locator, expected, options) {
261
+ return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => {
262
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]);
263
+ return await locator._expect("to.have.value", { expectedText, isNot, timeout });
264
+ }, expected, options);
265
+ }
266
+ function toHaveValues(locator, expected, options) {
267
+ return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => {
268
+ const expectedText = (0, import_utils.serializeExpectedTextValues)(expected);
269
+ return await locator._expect("to.have.values", { expectedText, isNot, timeout });
270
+ }, expected, options);
271
+ }
272
+ function toHaveTitle(page, expected, options = {}) {
273
+ return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => {
274
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true });
275
+ return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout });
276
+ }, expected, { receiverLabel: "page", ...options });
277
+ }
278
+ function toHaveURL(page, expected, options) {
279
+ if (typeof expected === "function")
280
+ return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options);
281
+ const baseURL = page.context()._options.baseURL;
282
+ expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected;
283
+ return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => {
284
+ const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase });
285
+ return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout });
286
+ }, expected, { receiverLabel: "page", ...options });
287
+ }
288
+ async function toBeOK(response) {
289
+ const matcherName = "toBeOK";
290
+ (0, import_util.expectTypes)(response, ["APIResponse"], matcherName);
291
+ const contentType = response.headers()["content-type"];
292
+ const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType);
293
+ const [log, text] = this.isNot === response.ok() ? await Promise.all([
294
+ response._fetchLog(),
295
+ isTextEncoding ? response.text() : null
296
+ ]) : [];
297
+ const message = () => this.utils.matcherHint(matcherName, void 0, "", { isNot: this.isNot }) + (0, import_util.callLogText)(log) + (text === null ? "" : `
298
+ Response text:
299
+ ${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`);
300
+ const pass = response.ok();
301
+ return { message, pass };
302
+ }
303
+ async function toPass(callback, options = {}) {
304
+ const testInfo = (0, import_globals.currentTestInfo)();
305
+ const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0);
306
+ const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]);
307
+ const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout);
308
+ const result = await (0, import_utils.pollAgainstDeadline)(async () => {
309
+ if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo)
310
+ return { continuePolling: false, result: void 0 };
311
+ try {
312
+ await callback();
313
+ return { continuePolling: !!this.isNot, result: void 0 };
314
+ } catch (e) {
315
+ return { continuePolling: !this.isNot, result: e };
316
+ }
317
+ }, deadline, intervals);
318
+ if (result.timedOut) {
319
+ const message = result.result ? [
320
+ result.result.message,
321
+ "",
322
+ `Call Log:`,
323
+ `- ${timeoutMessage}`
324
+ ].join("\n") : timeoutMessage;
325
+ return { message: () => message, pass: !!this.isNot };
326
+ }
327
+ return { pass: !this.isNot, message: () => "" };
328
+ }
329
+ // Annotate the CommonJS export names for ESM import in node:
330
+ 0 && (module.exports = {
331
+ toBeAttached,
332
+ toBeChecked,
333
+ toBeDisabled,
334
+ toBeEditable,
335
+ toBeEmpty,
336
+ toBeEnabled,
337
+ toBeFocused,
338
+ toBeHidden,
339
+ toBeInViewport,
340
+ toBeOK,
341
+ toBeVisible,
342
+ toContainClass,
343
+ toContainText,
344
+ toHaveAccessibleDescription,
345
+ toHaveAccessibleErrorMessage,
346
+ toHaveAccessibleName,
347
+ toHaveAttribute,
348
+ toHaveCSS,
349
+ toHaveClass,
350
+ toHaveCount,
351
+ toHaveId,
352
+ toHaveJSProperty,
353
+ toHaveRole,
354
+ toHaveText,
355
+ toHaveTitle,
356
+ toHaveURL,
357
+ toHaveValue,
358
+ toHaveValues,
359
+ toPass
360
+ });
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var toBeTruthy_exports = {};
20
+ __export(toBeTruthy_exports, {
21
+ toBeTruthy: () => toBeTruthy
22
+ });
23
+ module.exports = __toCommonJS(toBeTruthy_exports);
24
+ var import_util = require("../util");
25
+ var import_matcherHint = require("./matcherHint");
26
+ async function toBeTruthy(matcherName, receiver, receiverType, expected, arg, query, options = {}) {
27
+ (0, import_util.expectTypes)(receiver, [receiverType], matcherName);
28
+ const matcherOptions = {
29
+ isNot: this.isNot,
30
+ promise: this.promise
31
+ };
32
+ const timeout = options.timeout ?? this.timeout;
33
+ const { matches: pass, log, timedOut, received } = await query(!!this.isNot, timeout);
34
+ if (pass === !this.isNot) {
35
+ return {
36
+ name: matcherName,
37
+ message: () => "",
38
+ pass,
39
+ expected
40
+ };
41
+ }
42
+ const notFound = received === import_matcherHint.kNoElementsFoundError ? received : void 0;
43
+ let printedReceived;
44
+ let printedExpected;
45
+ if (pass) {
46
+ printedExpected = `Expected: not ${expected}`;
47
+ printedReceived = `Received: ${notFound ? import_matcherHint.kNoElementsFoundError : expected}`;
48
+ } else {
49
+ printedExpected = `Expected: ${expected}`;
50
+ printedReceived = `Received: ${notFound ? import_matcherHint.kNoElementsFoundError : received}`;
51
+ }
52
+ const message = () => {
53
+ const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", arg, matcherOptions, timedOut ? timeout : void 0);
54
+ const logText = (0, import_util.callLogText)(log);
55
+ return `${header}${printedExpected}
56
+ ${printedReceived}${logText}`;
57
+ };
58
+ return {
59
+ message,
60
+ pass,
61
+ actual: received,
62
+ name: matcherName,
63
+ expected,
64
+ log,
65
+ timeout: timedOut ? timeout : void 0
66
+ };
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ toBeTruthy
71
+ });
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var toEqual_exports = {};
20
+ __export(toEqual_exports, {
21
+ toEqual: () => toEqual
22
+ });
23
+ module.exports = __toCommonJS(toEqual_exports);
24
+ var import_utils = require("@ohos-ports/playwright-core/lib/utils");
25
+ var import_util = require("../util");
26
+ var import_matcherHint = require("./matcherHint");
27
+ const EXPECTED_LABEL = "Expected";
28
+ const RECEIVED_LABEL = "Received";
29
+ async function toEqual(matcherName, receiver, receiverType, query, expected, options = {}) {
30
+ (0, import_util.expectTypes)(receiver, [receiverType], matcherName);
31
+ const matcherOptions = {
32
+ comment: options.contains ? "" : "deep equality",
33
+ isNot: this.isNot,
34
+ promise: this.promise
35
+ };
36
+ const timeout = options.timeout ?? this.timeout;
37
+ const { matches: pass, received, log, timedOut } = await query(!!this.isNot, timeout);
38
+ if (pass === !this.isNot) {
39
+ return {
40
+ name: matcherName,
41
+ message: () => "",
42
+ pass,
43
+ expected
44
+ };
45
+ }
46
+ let printedReceived;
47
+ let printedExpected;
48
+ let printedDiff;
49
+ if (pass) {
50
+ printedExpected = `Expected: not ${this.utils.printExpected(expected)}`;
51
+ printedReceived = `Received: ${this.utils.printReceived(received)}`;
52
+ } else if (Array.isArray(expected) && Array.isArray(received)) {
53
+ const normalizedExpected = expected.map((exp, index) => {
54
+ const rec = received[index];
55
+ if ((0, import_utils.isRegExp)(exp))
56
+ return exp.test(rec) ? rec : exp;
57
+ return exp;
58
+ });
59
+ printedDiff = this.utils.printDiffOrStringify(
60
+ normalizedExpected,
61
+ received,
62
+ EXPECTED_LABEL,
63
+ RECEIVED_LABEL,
64
+ false
65
+ );
66
+ } else {
67
+ printedDiff = this.utils.printDiffOrStringify(
68
+ expected,
69
+ received,
70
+ EXPECTED_LABEL,
71
+ RECEIVED_LABEL,
72
+ false
73
+ );
74
+ }
75
+ const message = () => {
76
+ const header = (0, import_matcherHint.matcherHint)(this, receiver, matcherName, "locator", void 0, matcherOptions, timedOut ? timeout : void 0);
77
+ const details = printedDiff || `${printedExpected}
78
+ ${printedReceived}`;
79
+ return `${header}${details}${(0, import_util.callLogText)(log)}`;
80
+ };
81
+ return {
82
+ actual: received,
83
+ expected,
84
+ message,
85
+ name: matcherName,
86
+ pass,
87
+ log,
88
+ timeout: timedOut ? timeout : void 0
89
+ };
90
+ }
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ toEqual
94
+ });
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var toHaveURL_exports = {};
20
+ __export(toHaveURL_exports, {
21
+ toHaveURLWithPredicate: () => toHaveURLWithPredicate
22
+ });
23
+ module.exports = __toCommonJS(toHaveURL_exports);
24
+ var import_utils = require("@ohos-ports/playwright-core/lib/utils");
25
+ var import_utils2 = require("@ohos-ports/playwright-core/lib/utils");
26
+ var import_expect = require("./expect");
27
+ var import_matcherHint = require("./matcherHint");
28
+ var import_expectBundle = require("../common/expectBundle");
29
+ async function toHaveURLWithPredicate(page, expected, options) {
30
+ const matcherName = "toHaveURL";
31
+ const expression = "page";
32
+ const matcherOptions = {
33
+ isNot: this.isNot,
34
+ promise: this.promise
35
+ };
36
+ if (typeof expected !== "function") {
37
+ throw new Error(
38
+ [
39
+ // Always display `expected` in expectation place
40
+ (0, import_matcherHint.matcherHint)(this, void 0, matcherName, expression, void 0, matcherOptions),
41
+ `${import_utils2.colors.bold("Matcher error")}: ${(0, import_expectBundle.EXPECTED_COLOR)("expected")} value must be a string, regular expression, or predicate`,
42
+ this.utils.printWithType("Expected", expected, this.utils.printExpected)
43
+ ].join("\n\n")
44
+ );
45
+ }
46
+ const timeout = options?.timeout ?? this.timeout;
47
+ const baseURL = page.context()._options.baseURL;
48
+ let conditionSucceeded = false;
49
+ let lastCheckedURLString = void 0;
50
+ try {
51
+ await page.mainFrame().waitForURL(
52
+ (url) => {
53
+ lastCheckedURLString = url.toString();
54
+ if (options?.ignoreCase) {
55
+ return !this.isNot === (0, import_utils.urlMatches)(
56
+ baseURL?.toLocaleLowerCase(),
57
+ lastCheckedURLString.toLocaleLowerCase(),
58
+ expected
59
+ );
60
+ }
61
+ return !this.isNot === (0, import_utils.urlMatches)(baseURL, lastCheckedURLString, expected);
62
+ },
63
+ { timeout }
64
+ );
65
+ conditionSucceeded = true;
66
+ } catch (e) {
67
+ conditionSucceeded = false;
68
+ }
69
+ if (conditionSucceeded)
70
+ return { name: matcherName, pass: !this.isNot, message: () => "" };
71
+ return {
72
+ name: matcherName,
73
+ pass: this.isNot,
74
+ message: () => toHaveURLMessage(
75
+ this,
76
+ matcherName,
77
+ expression,
78
+ expected,
79
+ lastCheckedURLString,
80
+ this.isNot,
81
+ true,
82
+ timeout
83
+ ),
84
+ actual: lastCheckedURLString,
85
+ timeout
86
+ };
87
+ }
88
+ function toHaveURLMessage(state, matcherName, expression, expected, received, pass, didTimeout, timeout) {
89
+ const matcherOptions = {
90
+ isNot: state.isNot,
91
+ promise: state.promise
92
+ };
93
+ const receivedString = received || "";
94
+ const messagePrefix = (0, import_matcherHint.matcherHint)(state, void 0, matcherName, expression, void 0, matcherOptions, didTimeout ? timeout : void 0);
95
+ let printedReceived;
96
+ let printedExpected;
97
+ let printedDiff;
98
+ if (typeof expected === "function") {
99
+ printedExpected = `Expected predicate to ${!state.isNot ? "succeed" : "fail"}`;
100
+ printedReceived = `Received string: ${(0, import_expectBundle.printReceived)(receivedString)}`;
101
+ } else {
102
+ if (pass) {
103
+ printedExpected = `Expected pattern: not ${state.utils.printExpected(expected)}`;
104
+ const formattedReceived = (0, import_expect.printReceivedStringContainExpectedResult)(receivedString, null);
105
+ printedReceived = `Received string: ${formattedReceived}`;
106
+ } else {
107
+ const labelExpected = `Expected ${typeof expected === "string" ? "string" : "pattern"}`;
108
+ printedDiff = state.utils.printDiffOrStringify(expected, receivedString, labelExpected, "Received string", false);
109
+ }
110
+ }
111
+ const resultDetails = printedDiff ? printedDiff : printedExpected + "\n" + printedReceived;
112
+ return messagePrefix + resultDetails;
113
+ }
114
+ // Annotate the CommonJS export names for ESM import in node:
115
+ 0 && (module.exports = {
116
+ toHaveURLWithPredicate
117
+ });