|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
3 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
5 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
6 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
7 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
8 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
9 |
}; |
|
f7eb47b…
|
lmata
|
10 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
11 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
12 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
13 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
14 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
15 |
} |
|
f7eb47b…
|
lmata
|
16 |
return to; |
|
f7eb47b…
|
lmata
|
17 |
}; |
|
f7eb47b…
|
lmata
|
18 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
19 |
var matchers_exports = {}; |
|
f7eb47b…
|
lmata
|
20 |
__export(matchers_exports, { |
|
f7eb47b…
|
lmata
|
21 |
computeMatcherTitleSuffix: () => computeMatcherTitleSuffix, |
|
f7eb47b…
|
lmata
|
22 |
toBeAttached: () => toBeAttached, |
|
f7eb47b…
|
lmata
|
23 |
toBeChecked: () => toBeChecked, |
|
f7eb47b…
|
lmata
|
24 |
toBeDisabled: () => toBeDisabled, |
|
f7eb47b…
|
lmata
|
25 |
toBeEditable: () => toBeEditable, |
|
f7eb47b…
|
lmata
|
26 |
toBeEmpty: () => toBeEmpty, |
|
f7eb47b…
|
lmata
|
27 |
toBeEnabled: () => toBeEnabled, |
|
f7eb47b…
|
lmata
|
28 |
toBeFocused: () => toBeFocused, |
|
f7eb47b…
|
lmata
|
29 |
toBeHidden: () => toBeHidden, |
|
f7eb47b…
|
lmata
|
30 |
toBeInViewport: () => toBeInViewport, |
|
f7eb47b…
|
lmata
|
31 |
toBeOK: () => toBeOK, |
|
f7eb47b…
|
lmata
|
32 |
toBeVisible: () => toBeVisible, |
|
f7eb47b…
|
lmata
|
33 |
toContainClass: () => toContainClass, |
|
f7eb47b…
|
lmata
|
34 |
toContainText: () => toContainText, |
|
f7eb47b…
|
lmata
|
35 |
toHaveAccessibleDescription: () => toHaveAccessibleDescription, |
|
f7eb47b…
|
lmata
|
36 |
toHaveAccessibleErrorMessage: () => toHaveAccessibleErrorMessage, |
|
f7eb47b…
|
lmata
|
37 |
toHaveAccessibleName: () => toHaveAccessibleName, |
|
f7eb47b…
|
lmata
|
38 |
toHaveAttribute: () => toHaveAttribute, |
|
f7eb47b…
|
lmata
|
39 |
toHaveCSS: () => toHaveCSS, |
|
f7eb47b…
|
lmata
|
40 |
toHaveClass: () => toHaveClass, |
|
f7eb47b…
|
lmata
|
41 |
toHaveCount: () => toHaveCount, |
|
f7eb47b…
|
lmata
|
42 |
toHaveId: () => toHaveId, |
|
f7eb47b…
|
lmata
|
43 |
toHaveJSProperty: () => toHaveJSProperty, |
|
f7eb47b…
|
lmata
|
44 |
toHaveRole: () => toHaveRole, |
|
f7eb47b…
|
lmata
|
45 |
toHaveText: () => toHaveText, |
|
f7eb47b…
|
lmata
|
46 |
toHaveTitle: () => toHaveTitle, |
|
f7eb47b…
|
lmata
|
47 |
toHaveURL: () => toHaveURL, |
|
f7eb47b…
|
lmata
|
48 |
toHaveValue: () => toHaveValue, |
|
f7eb47b…
|
lmata
|
49 |
toHaveValues: () => toHaveValues, |
|
f7eb47b…
|
lmata
|
50 |
toPass: () => toPass |
|
f7eb47b…
|
lmata
|
51 |
}); |
|
f7eb47b…
|
lmata
|
52 |
module.exports = __toCommonJS(matchers_exports); |
|
f7eb47b…
|
lmata
|
53 |
var import_utils = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
54 |
var import_utils2 = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
55 |
var import_util = require("../util"); |
|
f7eb47b…
|
lmata
|
56 |
var import_toBeTruthy = require("./toBeTruthy"); |
|
f7eb47b…
|
lmata
|
57 |
var import_toEqual = require("./toEqual"); |
|
f7eb47b…
|
lmata
|
58 |
var import_toHaveURL = require("./toHaveURL"); |
|
f7eb47b…
|
lmata
|
59 |
var import_toMatchText = require("./toMatchText"); |
|
f7eb47b…
|
lmata
|
60 |
var import_toMatchSnapshot = require("./toMatchSnapshot"); |
|
f7eb47b…
|
lmata
|
61 |
var import_config = require("../common/config"); |
|
f7eb47b…
|
lmata
|
62 |
var import_globals = require("../common/globals"); |
|
f7eb47b…
|
lmata
|
63 |
var import_testInfo = require("../worker/testInfo"); |
|
f7eb47b…
|
lmata
|
64 |
function toBeAttached(locator, options) { |
|
f7eb47b…
|
lmata
|
65 |
const attached = !options || options.attached === void 0 || options.attached; |
|
f7eb47b…
|
lmata
|
66 |
const expected = attached ? "attached" : "detached"; |
|
f7eb47b…
|
lmata
|
67 |
const arg = attached ? "" : "{ attached: false }"; |
|
f7eb47b…
|
lmata
|
68 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeAttached", locator, "Locator", expected, arg, async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
69 |
return await locator._expect(attached ? "to.be.attached" : "to.be.detached", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
70 |
}, options); |
|
f7eb47b…
|
lmata
|
71 |
} |
|
f7eb47b…
|
lmata
|
72 |
function toBeChecked(locator, options) { |
|
f7eb47b…
|
lmata
|
73 |
const checked = options?.checked; |
|
f7eb47b…
|
lmata
|
74 |
const indeterminate = options?.indeterminate; |
|
f7eb47b…
|
lmata
|
75 |
const expectedValue = { |
|
f7eb47b…
|
lmata
|
76 |
checked, |
|
f7eb47b…
|
lmata
|
77 |
indeterminate |
|
f7eb47b…
|
lmata
|
78 |
}; |
|
f7eb47b…
|
lmata
|
79 |
let expected; |
|
f7eb47b…
|
lmata
|
80 |
let arg; |
|
f7eb47b…
|
lmata
|
81 |
if (options?.indeterminate) { |
|
f7eb47b…
|
lmata
|
82 |
expected = "indeterminate"; |
|
f7eb47b…
|
lmata
|
83 |
arg = `{ indeterminate: true }`; |
|
f7eb47b…
|
lmata
|
84 |
} else { |
|
f7eb47b…
|
lmata
|
85 |
expected = options?.checked === false ? "unchecked" : "checked"; |
|
f7eb47b…
|
lmata
|
86 |
arg = options?.checked === false ? `{ checked: false }` : ""; |
|
f7eb47b…
|
lmata
|
87 |
} |
|
f7eb47b…
|
lmata
|
88 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeChecked", locator, "Locator", expected, arg, async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
89 |
return await locator._expect("to.be.checked", { isNot, timeout, expectedValue }); |
|
f7eb47b…
|
lmata
|
90 |
}, options); |
|
f7eb47b…
|
lmata
|
91 |
} |
|
f7eb47b…
|
lmata
|
92 |
function toBeDisabled(locator, options) { |
|
f7eb47b…
|
lmata
|
93 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeDisabled", locator, "Locator", "disabled", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
94 |
return await locator._expect("to.be.disabled", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
95 |
}, options); |
|
f7eb47b…
|
lmata
|
96 |
} |
|
f7eb47b…
|
lmata
|
97 |
function toBeEditable(locator, options) { |
|
f7eb47b…
|
lmata
|
98 |
const editable = !options || options.editable === void 0 || options.editable; |
|
f7eb47b…
|
lmata
|
99 |
const expected = editable ? "editable" : "readOnly"; |
|
f7eb47b…
|
lmata
|
100 |
const arg = editable ? "" : "{ editable: false }"; |
|
f7eb47b…
|
lmata
|
101 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeEditable", locator, "Locator", expected, arg, async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
102 |
return await locator._expect(editable ? "to.be.editable" : "to.be.readonly", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
103 |
}, options); |
|
f7eb47b…
|
lmata
|
104 |
} |
|
f7eb47b…
|
lmata
|
105 |
function toBeEmpty(locator, options) { |
|
f7eb47b…
|
lmata
|
106 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeEmpty", locator, "Locator", "empty", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
107 |
return await locator._expect("to.be.empty", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
108 |
}, options); |
|
f7eb47b…
|
lmata
|
109 |
} |
|
f7eb47b…
|
lmata
|
110 |
function toBeEnabled(locator, options) { |
|
f7eb47b…
|
lmata
|
111 |
const enabled = !options || options.enabled === void 0 || options.enabled; |
|
f7eb47b…
|
lmata
|
112 |
const expected = enabled ? "enabled" : "disabled"; |
|
f7eb47b…
|
lmata
|
113 |
const arg = enabled ? "" : "{ enabled: false }"; |
|
f7eb47b…
|
lmata
|
114 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeEnabled", locator, "Locator", expected, arg, async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
115 |
return await locator._expect(enabled ? "to.be.enabled" : "to.be.disabled", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
116 |
}, options); |
|
f7eb47b…
|
lmata
|
117 |
} |
|
f7eb47b…
|
lmata
|
118 |
function toBeFocused(locator, options) { |
|
f7eb47b…
|
lmata
|
119 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeFocused", locator, "Locator", "focused", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
120 |
return await locator._expect("to.be.focused", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
121 |
}, options); |
|
f7eb47b…
|
lmata
|
122 |
} |
|
f7eb47b…
|
lmata
|
123 |
function toBeHidden(locator, options) { |
|
f7eb47b…
|
lmata
|
124 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeHidden", locator, "Locator", "hidden", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
125 |
return await locator._expect("to.be.hidden", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
126 |
}, options); |
|
f7eb47b…
|
lmata
|
127 |
} |
|
f7eb47b…
|
lmata
|
128 |
function toBeVisible(locator, options) { |
|
f7eb47b…
|
lmata
|
129 |
const visible = !options || options.visible === void 0 || options.visible; |
|
f7eb47b…
|
lmata
|
130 |
const expected = visible ? "visible" : "hidden"; |
|
f7eb47b…
|
lmata
|
131 |
const arg = visible ? "" : "{ visible: false }"; |
|
f7eb47b…
|
lmata
|
132 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeVisible", locator, "Locator", expected, arg, async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
133 |
return await locator._expect(visible ? "to.be.visible" : "to.be.hidden", { isNot, timeout }); |
|
f7eb47b…
|
lmata
|
134 |
}, options); |
|
f7eb47b…
|
lmata
|
135 |
} |
|
f7eb47b…
|
lmata
|
136 |
function toBeInViewport(locator, options) { |
|
f7eb47b…
|
lmata
|
137 |
return import_toBeTruthy.toBeTruthy.call(this, "toBeInViewport", locator, "Locator", "in viewport", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
138 |
return await locator._expect("to.be.in.viewport", { isNot, expectedNumber: options?.ratio, timeout }); |
|
f7eb47b…
|
lmata
|
139 |
}, options); |
|
f7eb47b…
|
lmata
|
140 |
} |
|
f7eb47b…
|
lmata
|
141 |
function toContainText(locator, expected, options = {}) { |
|
f7eb47b…
|
lmata
|
142 |
if (Array.isArray(expected)) { |
|
f7eb47b…
|
lmata
|
143 |
return import_toEqual.toEqual.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
144 |
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
|
f7eb47b…
|
lmata
|
145 |
return await locator._expect("to.contain.text.array", { expectedText, isNot, useInnerText: options.useInnerText, timeout }); |
|
f7eb47b…
|
lmata
|
146 |
}, expected, { ...options, contains: true }); |
|
f7eb47b…
|
lmata
|
147 |
} else { |
|
f7eb47b…
|
lmata
|
148 |
return import_toMatchText.toMatchText.call(this, "toContainText", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
149 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { matchSubstring: true, normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
|
f7eb47b…
|
lmata
|
150 |
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options.useInnerText, timeout }); |
|
f7eb47b…
|
lmata
|
151 |
}, expected, { ...options, matchSubstring: true }); |
|
f7eb47b…
|
lmata
|
152 |
} |
|
f7eb47b…
|
lmata
|
153 |
} |
|
f7eb47b…
|
lmata
|
154 |
function toHaveAccessibleDescription(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
155 |
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleDescription", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
156 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true }); |
|
f7eb47b…
|
lmata
|
157 |
return await locator._expect("to.have.accessible.description", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
158 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
159 |
} |
|
f7eb47b…
|
lmata
|
160 |
function toHaveAccessibleName(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
161 |
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleName", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
162 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true }); |
|
f7eb47b…
|
lmata
|
163 |
return await locator._expect("to.have.accessible.name", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
164 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
165 |
} |
|
f7eb47b…
|
lmata
|
166 |
function toHaveAccessibleErrorMessage(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
167 |
return import_toMatchText.toMatchText.call(this, "toHaveAccessibleErrorMessage", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
168 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase, normalizeWhiteSpace: true }); |
|
f7eb47b…
|
lmata
|
169 |
return await locator._expect("to.have.accessible.error.message", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
170 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
171 |
} |
|
f7eb47b…
|
lmata
|
172 |
function toHaveAttribute(locator, name, expected, options) { |
|
f7eb47b…
|
lmata
|
173 |
if (!options) { |
|
f7eb47b…
|
lmata
|
174 |
if (typeof expected === "object" && !(0, import_utils.isRegExp)(expected)) { |
|
f7eb47b…
|
lmata
|
175 |
options = expected; |
|
f7eb47b…
|
lmata
|
176 |
expected = void 0; |
|
f7eb47b…
|
lmata
|
177 |
} |
|
f7eb47b…
|
lmata
|
178 |
} |
|
f7eb47b…
|
lmata
|
179 |
if (expected === void 0) { |
|
f7eb47b…
|
lmata
|
180 |
return import_toBeTruthy.toBeTruthy.call(this, "toHaveAttribute", locator, "Locator", "have attribute", "", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
181 |
return await locator._expect("to.have.attribute", { expressionArg: name, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
182 |
}, options); |
|
f7eb47b…
|
lmata
|
183 |
} |
|
f7eb47b…
|
lmata
|
184 |
return import_toMatchText.toMatchText.call(this, "toHaveAttribute", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
185 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase }); |
|
f7eb47b…
|
lmata
|
186 |
return await locator._expect("to.have.attribute.value", { expressionArg: name, expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
187 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
188 |
} |
|
f7eb47b…
|
lmata
|
189 |
function toHaveClass(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
190 |
if (Array.isArray(expected)) { |
|
f7eb47b…
|
lmata
|
191 |
return import_toEqual.toEqual.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
192 |
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected); |
|
f7eb47b…
|
lmata
|
193 |
return await locator._expect("to.have.class.array", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
194 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
195 |
} else { |
|
f7eb47b…
|
lmata
|
196 |
return import_toMatchText.toMatchText.call(this, "toHaveClass", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
197 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
198 |
return await locator._expect("to.have.class", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
199 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
200 |
} |
|
f7eb47b…
|
lmata
|
201 |
} |
|
f7eb47b…
|
lmata
|
202 |
function toContainClass(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
203 |
if (Array.isArray(expected)) { |
|
f7eb47b…
|
lmata
|
204 |
if (expected.some((e) => (0, import_utils.isRegExp)(e))) |
|
f7eb47b…
|
lmata
|
205 |
throw new Error(`"expected" argument in toContainClass cannot contain RegExp values`); |
|
f7eb47b…
|
lmata
|
206 |
return import_toEqual.toEqual.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
207 |
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected); |
|
f7eb47b…
|
lmata
|
208 |
return await locator._expect("to.contain.class.array", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
209 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
210 |
} else { |
|
f7eb47b…
|
lmata
|
211 |
if ((0, import_utils.isRegExp)(expected)) |
|
f7eb47b…
|
lmata
|
212 |
throw new Error(`"expected" argument in toContainClass cannot be a RegExp value`); |
|
f7eb47b…
|
lmata
|
213 |
return import_toMatchText.toMatchText.call(this, "toContainClass", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
214 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
215 |
return await locator._expect("to.contain.class", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
216 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
217 |
} |
|
f7eb47b…
|
lmata
|
218 |
} |
|
f7eb47b…
|
lmata
|
219 |
function toHaveCount(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
220 |
return import_toEqual.toEqual.call(this, "toHaveCount", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
221 |
return await locator._expect("to.have.count", { expectedNumber: expected, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
222 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
223 |
} |
|
f7eb47b…
|
lmata
|
224 |
function toHaveCSS(locator, name, expected, options) { |
|
f7eb47b…
|
lmata
|
225 |
return import_toMatchText.toMatchText.call(this, "toHaveCSS", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
226 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
227 |
return await locator._expect("to.have.css", { expressionArg: name, expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
228 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
229 |
} |
|
f7eb47b…
|
lmata
|
230 |
function toHaveId(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
231 |
return import_toMatchText.toMatchText.call(this, "toHaveId", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
232 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
233 |
return await locator._expect("to.have.id", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
234 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
235 |
} |
|
f7eb47b…
|
lmata
|
236 |
function toHaveJSProperty(locator, name, expected, options) { |
|
f7eb47b…
|
lmata
|
237 |
return import_toEqual.toEqual.call(this, "toHaveJSProperty", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
238 |
return await locator._expect("to.have.property", { expressionArg: name, expectedValue: expected, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
239 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
240 |
} |
|
f7eb47b…
|
lmata
|
241 |
function toHaveRole(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
242 |
if (!(0, import_utils.isString)(expected)) |
|
f7eb47b…
|
lmata
|
243 |
throw new Error(`"role" argument in toHaveRole must be a string`); |
|
f7eb47b…
|
lmata
|
244 |
return import_toMatchText.toMatchText.call(this, "toHaveRole", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
245 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
246 |
return await locator._expect("to.have.role", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
247 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
248 |
} |
|
f7eb47b…
|
lmata
|
249 |
function toHaveText(locator, expected, options = {}) { |
|
f7eb47b…
|
lmata
|
250 |
if (Array.isArray(expected)) { |
|
f7eb47b…
|
lmata
|
251 |
return import_toEqual.toEqual.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
252 |
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected, { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
|
f7eb47b…
|
lmata
|
253 |
return await locator._expect("to.have.text.array", { expectedText, isNot, useInnerText: options?.useInnerText, timeout }); |
|
f7eb47b…
|
lmata
|
254 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
255 |
} else { |
|
f7eb47b…
|
lmata
|
256 |
return import_toMatchText.toMatchText.call(this, "toHaveText", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
257 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true, ignoreCase: options.ignoreCase }); |
|
f7eb47b…
|
lmata
|
258 |
return await locator._expect("to.have.text", { expectedText, isNot, useInnerText: options?.useInnerText, timeout }); |
|
f7eb47b…
|
lmata
|
259 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
260 |
} |
|
f7eb47b…
|
lmata
|
261 |
} |
|
f7eb47b…
|
lmata
|
262 |
function toHaveValue(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
263 |
return import_toMatchText.toMatchText.call(this, "toHaveValue", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
264 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected]); |
|
f7eb47b…
|
lmata
|
265 |
return await locator._expect("to.have.value", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
266 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
267 |
} |
|
f7eb47b…
|
lmata
|
268 |
function toHaveValues(locator, expected, options) { |
|
f7eb47b…
|
lmata
|
269 |
return import_toEqual.toEqual.call(this, "toHaveValues", locator, "Locator", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
270 |
const expectedText = (0, import_utils.serializeExpectedTextValues)(expected); |
|
f7eb47b…
|
lmata
|
271 |
return await locator._expect("to.have.values", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
272 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
273 |
} |
|
f7eb47b…
|
lmata
|
274 |
function toHaveTitle(page, expected, options = {}) { |
|
f7eb47b…
|
lmata
|
275 |
return import_toMatchText.toMatchText.call(this, "toHaveTitle", page, "Page", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
276 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { normalizeWhiteSpace: true }); |
|
f7eb47b…
|
lmata
|
277 |
return await page.mainFrame()._expect("to.have.title", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
278 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
279 |
} |
|
f7eb47b…
|
lmata
|
280 |
function toHaveURL(page, expected, options) { |
|
f7eb47b…
|
lmata
|
281 |
if (typeof expected === "function") |
|
f7eb47b…
|
lmata
|
282 |
return import_toHaveURL.toHaveURLWithPredicate.call(this, page, expected, options); |
|
f7eb47b…
|
lmata
|
283 |
const baseURL = page.context()._options.baseURL; |
|
f7eb47b…
|
lmata
|
284 |
expected = typeof expected === "string" ? (0, import_utils.constructURLBasedOnBaseURL)(baseURL, expected) : expected; |
|
f7eb47b…
|
lmata
|
285 |
return import_toMatchText.toMatchText.call(this, "toHaveURL", page, "Page", async (isNot, timeout) => { |
|
f7eb47b…
|
lmata
|
286 |
const expectedText = (0, import_utils.serializeExpectedTextValues)([expected], { ignoreCase: options?.ignoreCase }); |
|
f7eb47b…
|
lmata
|
287 |
return await page.mainFrame()._expect("to.have.url", { expectedText, isNot, timeout }); |
|
f7eb47b…
|
lmata
|
288 |
}, expected, options); |
|
f7eb47b…
|
lmata
|
289 |
} |
|
f7eb47b…
|
lmata
|
290 |
async function toBeOK(response) { |
|
f7eb47b…
|
lmata
|
291 |
const matcherName = "toBeOK"; |
|
f7eb47b…
|
lmata
|
292 |
(0, import_util.expectTypes)(response, ["APIResponse"], matcherName); |
|
f7eb47b…
|
lmata
|
293 |
const contentType = response.headers()["content-type"]; |
|
f7eb47b…
|
lmata
|
294 |
const isTextEncoding = contentType && (0, import_utils.isTextualMimeType)(contentType); |
|
f7eb47b…
|
lmata
|
295 |
const [log, text] = this.isNot === response.ok() ? await Promise.all([ |
|
f7eb47b…
|
lmata
|
296 |
response._fetchLog(), |
|
f7eb47b…
|
lmata
|
297 |
isTextEncoding ? response.text() : null |
|
f7eb47b…
|
lmata
|
298 |
]) : []; |
|
f7eb47b…
|
lmata
|
299 |
const message = () => (0, import_utils.formatMatcherMessage)(this.utils, { |
|
f7eb47b…
|
lmata
|
300 |
isNot: this.isNot, |
|
f7eb47b…
|
lmata
|
301 |
promise: this.promise, |
|
f7eb47b…
|
lmata
|
302 |
matcherName, |
|
f7eb47b…
|
lmata
|
303 |
receiver: "response", |
|
f7eb47b…
|
lmata
|
304 |
expectation: "", |
|
f7eb47b…
|
lmata
|
305 |
log |
|
f7eb47b…
|
lmata
|
306 |
}) + (text === null ? "" : ` |
|
f7eb47b…
|
lmata
|
307 |
Response text: |
|
f7eb47b…
|
lmata
|
308 |
${import_utils2.colors.dim(text?.substring(0, 1e3) || "")}`); |
|
f7eb47b…
|
lmata
|
309 |
const pass = response.ok(); |
|
f7eb47b…
|
lmata
|
310 |
return { message, pass }; |
|
f7eb47b…
|
lmata
|
311 |
} |
|
f7eb47b…
|
lmata
|
312 |
async function toPass(callback, options = {}) { |
|
f7eb47b…
|
lmata
|
313 |
const testInfo = (0, import_globals.currentTestInfo)(); |
|
f7eb47b…
|
lmata
|
314 |
const timeout = (0, import_config.takeFirst)(options.timeout, testInfo?._projectInternal.expect?.toPass?.timeout, 0); |
|
f7eb47b…
|
lmata
|
315 |
const intervals = (0, import_config.takeFirst)(options.intervals, testInfo?._projectInternal.expect?.toPass?.intervals, [100, 250, 500, 1e3]); |
|
f7eb47b…
|
lmata
|
316 |
const { deadline, timeoutMessage } = testInfo ? testInfo._deadlineForMatcher(timeout) : import_testInfo.TestInfoImpl._defaultDeadlineForMatcher(timeout); |
|
f7eb47b…
|
lmata
|
317 |
const result = await (0, import_utils.pollAgainstDeadline)(async () => { |
|
f7eb47b…
|
lmata
|
318 |
if (testInfo && (0, import_globals.currentTestInfo)() !== testInfo) |
|
f7eb47b…
|
lmata
|
319 |
return { continuePolling: false, result: void 0 }; |
|
f7eb47b…
|
lmata
|
320 |
try { |
|
f7eb47b…
|
lmata
|
321 |
await callback(); |
|
f7eb47b…
|
lmata
|
322 |
return { continuePolling: !!this.isNot, result: void 0 }; |
|
f7eb47b…
|
lmata
|
323 |
} catch (e) { |
|
f7eb47b…
|
lmata
|
324 |
return { continuePolling: !this.isNot, result: e }; |
|
f7eb47b…
|
lmata
|
325 |
} |
|
f7eb47b…
|
lmata
|
326 |
}, deadline, intervals); |
|
f7eb47b…
|
lmata
|
327 |
if (result.timedOut) { |
|
f7eb47b…
|
lmata
|
328 |
const message = result.result ? [ |
|
f7eb47b…
|
lmata
|
329 |
result.result.message, |
|
f7eb47b…
|
lmata
|
330 |
"", |
|
f7eb47b…
|
lmata
|
331 |
`Call Log:`, |
|
f7eb47b…
|
lmata
|
332 |
`- ${timeoutMessage}` |
|
f7eb47b…
|
lmata
|
333 |
].join("\n") : timeoutMessage; |
|
f7eb47b…
|
lmata
|
334 |
return { message: () => message, pass: !!this.isNot }; |
|
f7eb47b…
|
lmata
|
335 |
} |
|
f7eb47b…
|
lmata
|
336 |
return { pass: !this.isNot, message: () => "" }; |
|
f7eb47b…
|
lmata
|
337 |
} |
|
f7eb47b…
|
lmata
|
338 |
function computeMatcherTitleSuffix(matcherName, receiver, args) { |
|
f7eb47b…
|
lmata
|
339 |
if (matcherName === "toHaveScreenshot") { |
|
f7eb47b…
|
lmata
|
340 |
const title = (0, import_toMatchSnapshot.toHaveScreenshotStepTitle)(...args); |
|
f7eb47b…
|
lmata
|
341 |
return { short: title ? `(${title})` : "" }; |
|
f7eb47b…
|
lmata
|
342 |
} |
|
f7eb47b…
|
lmata
|
343 |
if (receiver && typeof receiver === "object" && receiver.constructor?.name === "Locator") { |
|
f7eb47b…
|
lmata
|
344 |
try { |
|
f7eb47b…
|
lmata
|
345 |
return { long: " " + (0, import_utils.asLocatorDescription)("javascript", receiver._selector) }; |
|
f7eb47b…
|
lmata
|
346 |
} catch { |
|
f7eb47b…
|
lmata
|
347 |
} |
|
f7eb47b…
|
lmata
|
348 |
} |
|
f7eb47b…
|
lmata
|
349 |
return {}; |
|
f7eb47b…
|
lmata
|
350 |
} |
|
f7eb47b…
|
lmata
|
351 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
352 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
353 |
computeMatcherTitleSuffix, |
|
f7eb47b…
|
lmata
|
354 |
toBeAttached, |
|
f7eb47b…
|
lmata
|
355 |
toBeChecked, |
|
f7eb47b…
|
lmata
|
356 |
toBeDisabled, |
|
f7eb47b…
|
lmata
|
357 |
toBeEditable, |
|
f7eb47b…
|
lmata
|
358 |
toBeEmpty, |
|
f7eb47b…
|
lmata
|
359 |
toBeEnabled, |
|
f7eb47b…
|
lmata
|
360 |
toBeFocused, |
|
f7eb47b…
|
lmata
|
361 |
toBeHidden, |
|
f7eb47b…
|
lmata
|
362 |
toBeInViewport, |
|
f7eb47b…
|
lmata
|
363 |
toBeOK, |
|
f7eb47b…
|
lmata
|
364 |
toBeVisible, |
|
f7eb47b…
|
lmata
|
365 |
toContainClass, |
|
f7eb47b…
|
lmata
|
366 |
toContainText, |
|
f7eb47b…
|
lmata
|
367 |
toHaveAccessibleDescription, |
|
f7eb47b…
|
lmata
|
368 |
toHaveAccessibleErrorMessage, |
|
f7eb47b…
|
lmata
|
369 |
toHaveAccessibleName, |
|
f7eb47b…
|
lmata
|
370 |
toHaveAttribute, |
|
f7eb47b…
|
lmata
|
371 |
toHaveCSS, |
|
f7eb47b…
|
lmata
|
372 |
toHaveClass, |
|
f7eb47b…
|
lmata
|
373 |
toHaveCount, |
|
f7eb47b…
|
lmata
|
374 |
toHaveId, |
|
f7eb47b…
|
lmata
|
375 |
toHaveJSProperty, |
|
f7eb47b…
|
lmata
|
376 |
toHaveRole, |
|
f7eb47b…
|
lmata
|
377 |
toHaveText, |
|
f7eb47b…
|
lmata
|
378 |
toHaveTitle, |
|
f7eb47b…
|
lmata
|
379 |
toHaveURL, |
|
f7eb47b…
|
lmata
|
380 |
toHaveValue, |
|
f7eb47b…
|
lmata
|
381 |
toHaveValues, |
|
f7eb47b…
|
lmata
|
382 |
toPass |
|
f7eb47b…
|
lmata
|
383 |
}); |