playwright-clipboard-testing 0.4.0 → 0.5.0
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.
- package/README.md +68 -32
- package/dist/index.cjs +165 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -90
- package/dist/index.d.ts +130 -90
- package/dist/index.js +163 -43
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Testing the Clipboard API in Playwright usually requires boilerplate code to man
|
|
|
15
15
|
**playwright-clipboard-testing** simplifies this with:
|
|
16
16
|
- 🔌 **Zero configuration** — Chromium permissions are granted automatically under the hood (Firefox requires a 1-line config setup).
|
|
17
17
|
- 🔄 **Built-in Auto-retries & Polling** — Uses Playwright's native `expect` polling to wait until the clipboard updates asynchronously.
|
|
18
|
-
- 📦 **TypeScript Ready** — Full type safety for JSON objects with `readJSON<T>()`.
|
|
18
|
+
- 📦 **TypeScript Ready** — Full type safety for JSON objects with `readJSON<T>()` and `writeJSON<T>()`.
|
|
19
19
|
|
|
20
20
|
## Table of Contents
|
|
21
21
|
- [Why?](#why)
|
|
@@ -25,10 +25,12 @@ Testing the Clipboard API in Playwright usually requires boilerplate code to man
|
|
|
25
25
|
- [Direct Usage](#direct-usage)
|
|
26
26
|
- [Extended Usage](#extended-usage)
|
|
27
27
|
- [API](#api)
|
|
28
|
-
- [
|
|
28
|
+
- [Fixtures](#fixtures)
|
|
29
|
+
- [ClipboardHandler](#clipboardhandler)
|
|
30
|
+
- [toBeBlank Matcher](#tobeblank-matcher)
|
|
29
31
|
- [toHaveTextContent Matcher](#tohavetextcontent-matcher)
|
|
30
32
|
- [toHaveJSONContent Matcher](#tohavejsoncontent-matcher)
|
|
31
|
-
- [
|
|
33
|
+
- [PATTERNS](#patterns)
|
|
32
34
|
- [Author](#author)
|
|
33
35
|
- [License](#license)
|
|
34
36
|
|
|
@@ -105,30 +107,60 @@ export const expect = baseExpect.extend(clipboardMatchers);
|
|
|
105
107
|
```
|
|
106
108
|
|
|
107
109
|
## API
|
|
108
|
-
### Clipboard Fixtures
|
|
109
|
-
The package exports `clipboardFixtures` (containing `context` and `clipboard` fixtures) as well as individual fixtures `clipboardFixture` and `contextFixture`:
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
### Fixtures
|
|
112
|
+
The package exports the following fixtures for Playwright test configuration:
|
|
113
|
+
|
|
114
|
+
- `clipboardFixtures` — Object containing both `context` and `clipboard` fixtures. Recommended for extending test fixtures.
|
|
115
|
+
- `contextFixture` (`context`) — Playwright context fixture that automatically grants `clipboard-read` and `clipboard-write` permissions in Chromium.
|
|
116
|
+
- `clipboardFixture` (`clipboard`) — Playwright test fixture that provides access to the `ClipboardHandler` instance in your tests.
|
|
117
|
+
|
|
118
|
+
### ClipboardHandler
|
|
119
|
+
The `clipboard` fixture provides direct access to the `ClipboardHandler` instance for managing clipboard state:
|
|
120
|
+
|
|
121
|
+
| Method | Return Type | Description |
|
|
122
|
+
|:-------------------------------|:------------------|:-------------------------------------------------------------------------------------------------------------------------|
|
|
123
|
+
| `clipboard.read()` | `Promise<string>` | Reads plain text content from the clipboard. |
|
|
124
|
+
| `clipboard.write(text)` | `Promise<void>` | Writes the specified plain text to the clipboard. |
|
|
125
|
+
| `clipboard.readJSON<T>()` | `Promise<T>` | Reads clipboard content and parses it as a JSON object of type `T`. Throws an error if invalid JSON. |
|
|
126
|
+
| `clipboard.writeJSON<T>(data)` | `Promise<void>` | Serializes an object of type `T` to JSON and writes it to the clipboard. Throws an error if object cannot be serialized. |
|
|
127
|
+
| `clipboard.clear()` | `Promise<void>` | Clears all clipboard content. |
|
|
116
128
|
|
|
117
129
|

|
|
118
130
|
|
|
131
|
+
### toBeBlank Matcher
|
|
132
|
+
`expect(clipboard).toBeBlank(options?)`
|
|
133
|
+
Asserts that the clipboard is empty. Uses Playwright's smart polling mechanism to wait for the clipboard to update.
|
|
134
|
+
- `options.timeout: number (optional, default: 10000ms)`
|
|
135
|
+
- `options.trim: boolean (optional, default: false)` — Trims whitespace from the clipboard content before checking if it's blank.
|
|
136
|
+
```ts
|
|
137
|
+
// assert that the clipboard is empty
|
|
138
|
+
await expect(clipboard).toBeBlank();
|
|
139
|
+
```
|
|
140
|
+
```ts
|
|
141
|
+
// assert that the clipboard is not empty with a custom timeout
|
|
142
|
+
await expect(clipboard).not.toBeBlank({ timeout: 5000 });
|
|
143
|
+
```
|
|
144
|
+
|
|
119
145
|
### toHaveTextContent Matcher
|
|
120
146
|
`expect(clipboard).toHaveTextContent(expected, options?)`
|
|
121
147
|
|
|
122
|
-
Asserts that the clipboard content matches the expected string. Uses Playwright's smart polling mechanism to wait for the clipboard to update.
|
|
123
|
-
- `expected: string` — Expected text to
|
|
148
|
+
Asserts that the clipboard content matches the expected string or regular expression. Uses Playwright's smart polling mechanism to wait for the clipboard to update.
|
|
149
|
+
- `expected: string | RegExp` — Expected text string or regular expression to match against.
|
|
124
150
|
- `options.timeout: number (optional, default: 10000ms)` — Time in milliseconds to wait for the clipboard content to match.
|
|
151
|
+
- `options.ignoreCase: boolean (optional, default: false)` — Ignores case when comparing strings or matching regular expressions.
|
|
152
|
+
- `options.trim: boolean (optional, default: false)` — Trims whitespace from both expected and actual string before comparison.
|
|
125
153
|
```ts
|
|
126
154
|
// assert that the clipboard contains the expected text
|
|
127
155
|
await expect(clipboard).toHaveTextContent('Hello, World!');
|
|
128
156
|
```
|
|
129
157
|
```ts
|
|
130
|
-
//
|
|
131
|
-
await expect(clipboard).toHaveTextContent(
|
|
158
|
+
// assert that the clipboard text matches a regular expression
|
|
159
|
+
await expect(clipboard).toHaveTextContent(/Hello, World!/i);
|
|
160
|
+
```
|
|
161
|
+
```ts
|
|
162
|
+
// assert that the clipboard is not containing the expected text with a custom timeout
|
|
163
|
+
await expect(clipboard).not.toHaveTextContent('Async copied value', { timeout: 5000 });
|
|
132
164
|
```
|
|
133
165
|
|
|
134
166
|
### toHaveJSONContent Matcher
|
|
@@ -141,29 +173,33 @@ Asserts that the clipboard content matches the expected JSON value. Uses Playwri
|
|
|
141
173
|
await expect(clipboard).toHaveJSONContent({ message: 'Hello, World!' });
|
|
142
174
|
```
|
|
143
175
|
```ts
|
|
144
|
-
//
|
|
145
|
-
await expect(clipboard).toHaveJSONContent({ message: 'Async copied value' }, { timeout: 5000 });
|
|
176
|
+
// assert that the clipboard is not containing the expected JSON data with a custom timeout
|
|
177
|
+
await expect(clipboard).not.toHaveJSONContent({ message: 'Async copied value' }, { timeout: 5000 });
|
|
146
178
|
```
|
|
147
179
|
|
|
148
|
-
###
|
|
149
|
-
|
|
180
|
+
### PATTERNS
|
|
181
|
+
The package exports pre-defined regular expression patterns for common data formats (`PATTERNS`), which can be passed directly to `toHaveTextContent`:
|
|
150
182
|
|
|
151
|
-
|
|
183
|
+
| Pattern | Description | Example Match |
|
|
184
|
+
|:---------------------|:-------------------------------------|:------------------------------------------|
|
|
185
|
+
| `PATTERNS.UUID` | UUID v1–v5 format | `123e4567-e89b-12d3-a456-426614174000` |
|
|
186
|
+
| `PATTERNS.EMAIL` | Email address format | `user@example.com` |
|
|
187
|
+
| `PATTERNS.JWT` | JWT token format | `header.payload.signature` |
|
|
188
|
+
| `PATTERNS.BEARER` | Bearer authentication token format | `Bearer token123` |
|
|
189
|
+
| `PATTERNS.HEX_COLOR` | HEX color format | `#FFF`, `#FFFFFF`, `#FFFFFFFF` |
|
|
190
|
+
| `PATTERNS.IP.V4` | IPv4 address format | `192.168.1.1` |
|
|
191
|
+
| `PATTERNS.IP.V6` | IPv6 address format | `2001:0db8:85a3:0000:0000:8a2e:0370:7334` |
|
|
192
|
+
| `PATTERNS.IP.ANY` | Any IP address format (IPv4 or IPv6) | `192.168.1.1` or `2001:db8::1` |
|
|
152
193
|
|
|
153
|
-
Asserts that the clipboard content matches the expected string or JSON object. Uses Playwright's smart polling mechanism to wait for the clipboard to update.
|
|
154
|
-
- `expected: unknown` — Expected text or object to compare against.
|
|
155
|
-
- `options.timeout: number (optional, default: 10000ms)` — Time in milliseconds to wait for the clipboard data to match.
|
|
156
194
|
```ts
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// Custom timeout
|
|
166
|
-
await expect(clipboard).toHaveData('Async copied value', { timeout: 5000 });
|
|
195
|
+
import { test, expect, PATTERNS } from 'playwright-clipboard-testing';
|
|
196
|
+
|
|
197
|
+
test('should copy UUID to clipboard', async ({ page, clipboard }) => {
|
|
198
|
+
await page.goto('https://example.com');
|
|
199
|
+
await page.locator('#copy-uuid-button').click();
|
|
200
|
+
|
|
201
|
+
await expect(clipboard).toHaveTextContent(PATTERNS.UUID);
|
|
202
|
+
});
|
|
167
203
|
```
|
|
168
204
|
|
|
169
205
|
## Author
|
package/dist/index.cjs
CHANGED
|
@@ -21,24 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
ClipboardHandler: () => ClipboardHandler,
|
|
24
|
+
PATTERNS: () => PATTERNS,
|
|
24
25
|
clipboardFixture: () => clipboardFixture,
|
|
25
26
|
clipboardFixtures: () => clipboardFixtures,
|
|
26
27
|
clipboardMatchers: () => clipboardMatchers,
|
|
27
28
|
contextFixture: () => contextFixture,
|
|
28
|
-
expect: () =>
|
|
29
|
+
expect: () => expect4,
|
|
29
30
|
firefoxClipboardPrefs: () => firefoxClipboardPrefs,
|
|
30
31
|
test: () => test
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(index_exports);
|
|
33
34
|
|
|
34
|
-
// src/
|
|
35
|
-
var
|
|
36
|
-
"dom.events.testing.asyncClipboard": true,
|
|
37
|
-
"dom.events.asyncClipboard.readText": true,
|
|
38
|
-
"dom.events.asyncClipboard.writeText": true,
|
|
39
|
-
"permissions.default.clipboard-read": 1,
|
|
40
|
-
"permissions.default.clipboard-write": 1
|
|
41
|
-
};
|
|
35
|
+
// src/baseFixtures.ts
|
|
36
|
+
var import_test4 = require("@playwright/test");
|
|
42
37
|
|
|
43
38
|
// src/utils/clipboardHandler.ts
|
|
44
39
|
var ClipboardHandler = class {
|
|
@@ -69,9 +64,43 @@ var ClipboardHandler = class {
|
|
|
69
64
|
try {
|
|
70
65
|
return JSON.parse(text);
|
|
71
66
|
} catch {
|
|
72
|
-
throw new Error(
|
|
67
|
+
throw new Error(
|
|
68
|
+
`[playwright-clipboard] Clipboard content is not a valid JSON: ${JSON.stringify(text)}`
|
|
69
|
+
);
|
|
73
70
|
}
|
|
74
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Writes the provided string data to the browser clipboard.
|
|
74
|
+
* @param data The data to write to the clipboard.
|
|
75
|
+
*/
|
|
76
|
+
async write(data) {
|
|
77
|
+
await this.page.evaluate((value) => navigator.clipboard.writeText(value), data);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Writes the provided data to the browser clipboard as a JSON string.
|
|
81
|
+
* @param data The data to write to the clipboard. It will be stringified as JSON.
|
|
82
|
+
*/
|
|
83
|
+
async writeJSON(data) {
|
|
84
|
+
const errorMessage = "[playwright-clipboard] Provided data cannot be stringified to valid JSON";
|
|
85
|
+
let jsonString;
|
|
86
|
+
try {
|
|
87
|
+
jsonString = JSON.stringify(data);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const message = error instanceof Error ? error : String(error);
|
|
90
|
+
throw new Error(`${errorMessage}: ${message}`);
|
|
91
|
+
}
|
|
92
|
+
if (jsonString === void 0) {
|
|
93
|
+
throw new Error(`${errorMessage} (received undefined).`);
|
|
94
|
+
}
|
|
95
|
+
await this.write(jsonString);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Clears the browser clipboard by writing an empty string to it.
|
|
99
|
+
* This effectively removes any existing content from the clipboard.
|
|
100
|
+
*/
|
|
101
|
+
async clear() {
|
|
102
|
+
await this.write("");
|
|
103
|
+
}
|
|
75
104
|
};
|
|
76
105
|
|
|
77
106
|
// src/fixtures/clipboardFixture.ts
|
|
@@ -100,10 +129,7 @@ var clipboardFixtures = {
|
|
|
100
129
|
clipboard: clipboardFixture
|
|
101
130
|
};
|
|
102
131
|
|
|
103
|
-
// src/
|
|
104
|
-
var import_test3 = require("@playwright/test");
|
|
105
|
-
|
|
106
|
-
// src/matchers/toHaveJSONContent.ts
|
|
132
|
+
// src/matchers/toBeBlank.ts
|
|
107
133
|
var import_test = require("@playwright/test");
|
|
108
134
|
|
|
109
135
|
// src/utils/matcherUtils.ts
|
|
@@ -121,15 +147,75 @@ ${error.message}`;
|
|
|
121
147
|
return () => message + `Expected: ${this.isNot ? "not " : ""}${this.utils.printExpected(expected)}
|
|
122
148
|
Received: ${this.utils.printReceived(actual)}`;
|
|
123
149
|
}
|
|
150
|
+
function normalizeText(data, options = {}) {
|
|
151
|
+
const { ignoreCase, trim } = options;
|
|
152
|
+
if (typeof data === "string") {
|
|
153
|
+
let result = data;
|
|
154
|
+
if (trim) result = result.trim();
|
|
155
|
+
if (ignoreCase) result = result.toLowerCase();
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
if (data instanceof RegExp) {
|
|
159
|
+
const flags = data.flags.replace(/[gy]/g, "");
|
|
160
|
+
const clearFlags = ignoreCase && !flags.includes("i") ? `${flags}i` : flags;
|
|
161
|
+
return new RegExp(data.source, clearFlags);
|
|
162
|
+
}
|
|
163
|
+
return data;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/matchers/toBeBlank.ts
|
|
167
|
+
async function toBeBlank(clipboard, options = {}) {
|
|
168
|
+
const name = "toBeBlank";
|
|
169
|
+
let pass;
|
|
170
|
+
let actual;
|
|
171
|
+
let normalizedActual;
|
|
172
|
+
const expected = "";
|
|
173
|
+
let errorReason = null;
|
|
174
|
+
const { timeout = 1e4, trim = false } = options;
|
|
175
|
+
const poll = import_test.expect.poll(
|
|
176
|
+
async () => {
|
|
177
|
+
try {
|
|
178
|
+
actual = await clipboard.read();
|
|
179
|
+
normalizedActual = actual;
|
|
180
|
+
normalizedActual = normalizeText(normalizedActual, { trim });
|
|
181
|
+
errorReason = null;
|
|
182
|
+
return normalizedActual;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
errorReason = error instanceof Error ? error : new Error(String(error));
|
|
185
|
+
actual = void 0;
|
|
186
|
+
normalizedActual = void 0;
|
|
187
|
+
throw errorReason;
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{ timeout }
|
|
191
|
+
);
|
|
192
|
+
try {
|
|
193
|
+
const expectation = this.isNot ? poll.not : poll;
|
|
194
|
+
await expectation.toEqual(expected);
|
|
195
|
+
pass = true;
|
|
196
|
+
} catch {
|
|
197
|
+
pass = false;
|
|
198
|
+
}
|
|
199
|
+
if (this.isNot) pass = !pass;
|
|
200
|
+
const matcherReturn = {
|
|
201
|
+
message: getErrorMessage.call(this, name, expected, actual, errorReason),
|
|
202
|
+
pass,
|
|
203
|
+
name,
|
|
204
|
+
expected,
|
|
205
|
+
actual
|
|
206
|
+
};
|
|
207
|
+
return matcherReturn;
|
|
208
|
+
}
|
|
124
209
|
|
|
125
210
|
// src/matchers/toHaveJSONContent.ts
|
|
211
|
+
var import_test2 = require("@playwright/test");
|
|
126
212
|
async function toHaveJSONContent(clipboard, expected, options = {}) {
|
|
127
213
|
const name = "toHaveJSONContent";
|
|
128
214
|
let pass;
|
|
129
215
|
let actual;
|
|
130
216
|
let errorReason = null;
|
|
131
217
|
const { timeout = 1e4 } = options;
|
|
132
|
-
const poll =
|
|
218
|
+
const poll = import_test2.expect.poll(
|
|
133
219
|
async () => {
|
|
134
220
|
try {
|
|
135
221
|
actual = await clipboard.readJSON();
|
|
@@ -166,22 +252,27 @@ async function toHaveJSONContent(clipboard, expected, options = {}) {
|
|
|
166
252
|
}
|
|
167
253
|
|
|
168
254
|
// src/matchers/toHaveTextContent.ts
|
|
169
|
-
var
|
|
255
|
+
var import_test3 = require("@playwright/test");
|
|
170
256
|
async function toHaveTextContent(clipboard, expected, options = {}) {
|
|
171
257
|
const name = "toHaveTextContent";
|
|
172
258
|
let pass;
|
|
173
259
|
let actual;
|
|
260
|
+
let normalizedActual;
|
|
174
261
|
let errorReason = null;
|
|
175
|
-
const { timeout = 1e4 } = options;
|
|
176
|
-
const
|
|
262
|
+
const { timeout = 1e4, ignoreCase = false, trim = false } = options;
|
|
263
|
+
const normalizedExpected = normalizeText(expected, { ignoreCase, trim });
|
|
264
|
+
const poll = import_test3.expect.poll(
|
|
177
265
|
async () => {
|
|
178
266
|
try {
|
|
179
267
|
actual = await clipboard.read();
|
|
268
|
+
normalizedActual = actual;
|
|
269
|
+
normalizedActual = normalizeText(normalizedActual, { ignoreCase, trim });
|
|
180
270
|
errorReason = null;
|
|
181
|
-
return
|
|
271
|
+
return normalizedActual;
|
|
182
272
|
} catch (error) {
|
|
183
273
|
errorReason = error instanceof Error ? error : new Error(String(error));
|
|
184
274
|
actual = void 0;
|
|
275
|
+
normalizedActual = void 0;
|
|
185
276
|
throw errorReason;
|
|
186
277
|
}
|
|
187
278
|
},
|
|
@@ -189,7 +280,11 @@ async function toHaveTextContent(clipboard, expected, options = {}) {
|
|
|
189
280
|
);
|
|
190
281
|
try {
|
|
191
282
|
const expectation = this.isNot ? poll.not : poll;
|
|
192
|
-
|
|
283
|
+
if (expected instanceof RegExp) {
|
|
284
|
+
await expectation.toMatch(normalizedExpected);
|
|
285
|
+
} else {
|
|
286
|
+
await expectation.toEqual(normalizedExpected);
|
|
287
|
+
}
|
|
193
288
|
pass = true;
|
|
194
289
|
} catch {
|
|
195
290
|
pass = false;
|
|
@@ -205,38 +300,64 @@ async function toHaveTextContent(clipboard, expected, options = {}) {
|
|
|
205
300
|
return matcherReturn;
|
|
206
301
|
}
|
|
207
302
|
|
|
208
|
-
// src/matchers/toHaveData.ts
|
|
209
|
-
async function toHaveData(clipboard, expected, options = {}) {
|
|
210
|
-
const name = "toHaveData";
|
|
211
|
-
let matcherReturn = null;
|
|
212
|
-
if (typeof expected === "string") {
|
|
213
|
-
matcherReturn = await toHaveTextContent.call(this, clipboard, expected, options);
|
|
214
|
-
} else {
|
|
215
|
-
matcherReturn = await toHaveJSONContent.call(this, clipboard, expected, options);
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
...matcherReturn,
|
|
219
|
-
name,
|
|
220
|
-
message: () => {
|
|
221
|
-
const originalMessage = matcherReturn.message();
|
|
222
|
-
return originalMessage.replace("toHaveText", name).replace("toHaveJSON", name);
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
303
|
// src/matchers/clipboardMatchers.ts
|
|
228
304
|
var clipboardMatchers = {
|
|
229
|
-
|
|
305
|
+
toBeBlank,
|
|
230
306
|
toHaveJSONContent,
|
|
231
|
-
|
|
307
|
+
toHaveTextContent
|
|
232
308
|
};
|
|
233
309
|
|
|
234
|
-
// src/
|
|
235
|
-
var test =
|
|
236
|
-
var
|
|
310
|
+
// src/baseFixtures.ts
|
|
311
|
+
var test = import_test4.test.extend(clipboardFixtures);
|
|
312
|
+
var expect4 = import_test4.expect.extend({ ...clipboardMatchers });
|
|
313
|
+
|
|
314
|
+
// src/constants.ts
|
|
315
|
+
var firefoxClipboardPrefs = {
|
|
316
|
+
"dom.events.testing.asyncClipboard": true,
|
|
317
|
+
"dom.events.asyncClipboard.readText": true,
|
|
318
|
+
"dom.events.asyncClipboard.writeText": true,
|
|
319
|
+
"permissions.default.clipboard-read": 1,
|
|
320
|
+
"permissions.default.clipboard-write": 1
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// src/patterns.ts
|
|
324
|
+
var PATTERNS = {
|
|
325
|
+
/**
|
|
326
|
+
* UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
|
|
327
|
+
*/
|
|
328
|
+
UUID: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
329
|
+
/**
|
|
330
|
+
* Email addresses (example: user@example.com).
|
|
331
|
+
*/
|
|
332
|
+
EMAIL: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
333
|
+
/**
|
|
334
|
+
* JWT tokens (example: header.payload.signature).
|
|
335
|
+
*/
|
|
336
|
+
JWT: /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/,
|
|
337
|
+
/**
|
|
338
|
+
* Authorization Bearer tokens (example: Bearer <token>).
|
|
339
|
+
*/
|
|
340
|
+
BEARER: /^Bearer\s+[a-zA-Z0-9._~+/-]+=*$/i,
|
|
341
|
+
/**
|
|
342
|
+
* HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
|
|
343
|
+
*/
|
|
344
|
+
HEX_COLOR: /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,
|
|
345
|
+
/**
|
|
346
|
+
* IP (IPv4, IPv6 or any).
|
|
347
|
+
*/
|
|
348
|
+
IP: {
|
|
349
|
+
/** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
|
|
350
|
+
V4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
351
|
+
/** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
|
|
352
|
+
V6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,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1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))$/
|
|
355
|
+
}
|
|
356
|
+
};
|
|
237
357
|
// Annotate the CommonJS export names for ESM import in node:
|
|
238
358
|
0 && (module.exports = {
|
|
239
359
|
ClipboardHandler,
|
|
360
|
+
PATTERNS,
|
|
240
361
|
clipboardFixture,
|
|
241
362
|
clipboardFixtures,
|
|
242
363
|
clipboardMatchers,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/constants.ts","../src/utils/clipboardHandler.ts","../src/fixtures/clipboardFixture.ts","../src/fixtures/contextFixture.ts","../src/fixtures/index.ts","../src/fixtures.ts","../src/matchers/toHaveJSONContent.ts","../src/utils/matcherUtils.ts","../src/matchers/toHaveTextContent.ts","../src/matchers/toHaveData.ts","../src/matchers/clipboardMatchers.ts"],"sourcesContent":["export { firefoxClipboardPrefs } from './constants.js';\nexport { clipboardFixture, clipboardFixtures, contextFixture } from './fixtures/index.js';\nexport { expect, test } from './fixtures.js';\nexport { clipboardMatchers } from './matchers/index.js';\nexport { ClipboardHandler } from './utils/index.js';\n","export const firefoxClipboardPrefs = {\n 'dom.events.testing.asyncClipboard': true,\n 'dom.events.asyncClipboard.readText': true,\n 'dom.events.asyncClipboard.writeText': true,\n 'permissions.default.clipboard-read': 1,\n 'permissions.default.clipboard-write': 1,\n};\n","/**\n * Playwright-compatible Clipboard utilities.\n *\n * Core functions for interacting with the browser clipboard within Playwright tests.\n * Provides wrappers for reading plain text and JSON.\n *\n * @remarks\n * These utilities require 'clipboard-read' and 'clipboard-write' permissions\n * to be granted in the browser context.\n */\n\nimport type { Page } from '@playwright/test';\n\nexport class ClipboardHandler {\n constructor(private readonly page: Page) {}\n\n /**\n * Reads the current text content from the browser clipboard.\n * If the content is a JSON-encoded string (e.g., has extra quotes),\n * it will be returned as is. Use readJSON for automatic parsing.\n *\n * @returns A promise that resolves to the clipboard string content.\n */\n async read(): Promise<string> {\n return await this.page.evaluate(() => navigator.clipboard.readText());\n }\n\n /**\n * Reads the clipboard content and parses it as JSON.\n * If the content is a string literal (e.g., '\"value\"'), it returns the unwrapped string ('value').\n *\n * @template T - The expected type of the parsed JSON object.\n * @returns A promise that resolves to the parsed JSON object of type T.\n * @throws {Error} If the clipboard content is not a valid JSON string.\n */\n async readJSON<T = unknown>(): Promise<T> {\n const text = await this.read();\n try {\n return JSON.parse(text);\n } catch {\n throw new Error(`Clipboard content is not a valid JSON: ${JSON.stringify(text)}`);\n }\n }\n}\n","import type { Page, TestFixture } from '@playwright/test';\nimport type { BrowserName } from '../types.js';\nimport { ClipboardHandler } from '../utils/index.js';\n\n/**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\nexport const clipboardFixture: TestFixture<\n ClipboardHandler,\n { page: Page; browserName: BrowserName }\n> = async ({ page, browserName }, use) => {\n if (browserName === 'webkit') {\n throw new Error(\n `[playwright-clipboard] Browser '${browserName}' is not supported. ` +\n 'Clipboard API testing is currently supported only in Chromium-based and Firefox browsers.\\n' +\n `Add test.skip(browserName === 'webkit', 'Clipboard API is only supported in Chromium and Firefox'); to your test body.`,\n );\n }\n\n const handler = new ClipboardHandler(page);\n await use(handler);\n};\n","import type { BrowserContext, TestFixture } from '@playwright/test';\nimport type { BrowserName } from '../types.js';\n\n/**\n * A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.\n */\nexport const contextFixture: TestFixture<\n BrowserContext,\n { context: BrowserContext; browserName: BrowserName }\n> = async ({ context, browserName }, use) => {\n if (browserName === 'chromium') {\n await context.grantPermissions(['clipboard-read', 'clipboard-write']);\n }\n\n await use(context);\n};\n","import { clipboardFixture } from './clipboardFixture.js';\nimport { contextFixture } from './contextFixture.js';\n\n/**\n * A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.\n * These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.\n */\nexport const clipboardFixtures = {\n context: contextFixture,\n clipboard: clipboardFixture,\n};\n\nexport { clipboardFixture, contextFixture };\n","import { expect as baseExpect, test as baseTest } from '@playwright/test';\nimport { clipboardFixtures } from './fixtures/index.js';\nimport { clipboardMatchers } from './matchers/index.js';\nimport type { ClipboardHandler } from './utils/index.js';\n\nexport const test = baseTest.extend<{\n clipboard: ClipboardHandler;\n}>(clipboardFixtures);\n\nexport const expect = baseExpect.extend({ ...clipboardMatchers });\n","import type { ExpectMatcherState, MatcherReturnType } from '@playwright/test';\nimport { expect } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils/clipboardHandler.js';\nimport { getErrorMessage } from '../utils/matcherUtils.js';\nimport type { MatcherOptions } from './types.js';\n\n/**\n * Asserts that the clipboard content matches the expected JSON value.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The expected JSON value.\n * @param options Matcher options.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveJSONContent(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: unknown,\n options: MatcherOptions = {},\n) {\n const name = 'toHaveJSONContent';\n let pass: boolean;\n let actual: unknown;\n let errorReason: Error | null = null;\n\n const { timeout = 10_000 } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.readJSON();\n errorReason = null;\n return actual;\n } catch (error) {\n errorReason = error instanceof Error ? error : new Error(String(error));\n\n try {\n actual = await clipboard.read();\n } catch {\n actual = undefined;\n }\n\n throw errorReason;\n }\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual, errorReason),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import type { ExpectMatcherState } from '@playwright/test';\n\n/**\n * Generates an error message for a custom matcher.\n *\n * @this ExpectMatcherState\n * @param name The name of the matcher.\n * @param expected The expected value.\n * @param actual The actual value.\n * @param error An optional error object.\n * @param errorMessage An optional error message string.\n * @returns A function that returns the error message string.\n */\nexport function getErrorMessage(\n this: ExpectMatcherState,\n name: string,\n expected: unknown,\n actual: unknown,\n error?: Error | null,\n errorMessage?: string | undefined | null,\n): () => string {\n const message = `${this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot })}\\n\\n`;\n\n if (error) {\n return () => `${message}An unexpected error occurred:\\n${error.message}`;\n }\n\n if (errorMessage) {\n return () => `${message}${errorMessage}`;\n }\n\n return () =>\n message +\n `Expected: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(actual)}`;\n}\n","import { type ExpectMatcherState, expect, type MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils/clipboardHandler.js';\nimport { getErrorMessage } from '../utils/matcherUtils.js';\nimport type { MatcherOptions } from './types.js';\n\n/**\n * Asserts that the clipboard content matches the expected text value.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The expected text value.\n * @param options Matcher options.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveTextContent(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: string,\n options: MatcherOptions = {},\n) {\n const name = 'toHaveTextContent';\n let pass: boolean;\n let actual: unknown;\n let errorReason: Error | null = null;\n\n const { timeout = 10_000 } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.read();\n errorReason = null;\n return actual;\n } catch (error) {\n errorReason = error instanceof Error ? error : new Error(String(error));\n actual = undefined;\n\n throw errorReason;\n }\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual, errorReason),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import type { ExpectMatcherState, MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils/clipboardHandler.js';\nimport { toHaveJSONContent } from './toHaveJSONContent.js';\nimport { toHaveTextContent } from './toHaveTextContent.js';\nimport type { MatcherOptions } from './types.js';\n\n/**\n * Asserts that the clipboard content matches the expected value.\n * Uses smart polling to wait for the clipboard to be updated.\n * If the `expected` value is an object, it attempts to parse the clipboard\n * content as JSON before comparing.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The string or object to compare against the clipboard content.\n * @param options Optional settings for the matcher, such as timeout.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveData(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: unknown,\n options: MatcherOptions = {},\n) {\n const name = 'toHaveData';\n let matcherReturn: MatcherReturnType | null = null;\n\n if (typeof expected === 'string') {\n matcherReturn = await toHaveTextContent.call(this, clipboard, expected, options);\n } else {\n matcherReturn = await toHaveJSONContent.call(this, clipboard, expected, options);\n }\n\n return {\n ...matcherReturn,\n name,\n message: () => {\n const originalMessage = matcherReturn.message();\n return originalMessage.replace('toHaveText', name).replace('toHaveJSON', name);\n },\n };\n}\n","import { toHaveData } from './toHaveData.js';\nimport { toHaveJSONContent } from './toHaveJSONContent.js';\nimport { toHaveTextContent } from './toHaveTextContent.js';\n\n/**\n * Export an object containing all the custom clipboard matchers for Playwright.\n */\nexport const clipboardMatchers = {\n toHaveTextContent,\n toHaveJSONContent,\n toHaveData,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,wBAAwB;AAAA,EACnC,qCAAqC;A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;;ALNO,IAAM,OAAO,aAAAC,KAAS,OAE1B,iBAAiB;AAEb,IAAMC,UAAS,aAAAC,OAAW,OAAO,EAAE,GAAG,kBAAkB,CAAC;","names":["expect","import_test","import_test","baseTest","expect","baseExpect"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/baseFixtures.ts","../src/utils/clipboardHandler.ts","../src/fixtures/clipboardFixture.ts","../src/fixtures/contextFixture.ts","../src/fixtures/index.ts","../src/matchers/toBeBlank.ts","../src/utils/matcherUtils.ts","../src/matchers/toHaveJSONContent.ts","../src/matchers/toHaveTextContent.ts","../src/matchers/clipboardMatchers.ts","../src/constants.ts","../src/patterns.ts"],"sourcesContent":["export { expect, test } from './baseFixtures';\nexport { firefoxClipboardPrefs } from './constants';\nexport { clipboardFixture, clipboardFixtures, contextFixture } from './fixtures/index';\nexport { clipboardMatchers } from './matchers/index';\nexport { PATTERNS } from './patterns';\nexport { ClipboardHandler } from './utils/index';\n","import { expect as baseExpect, test as baseTest } from '@playwright/test';\nimport { clipboardFixtures } from './fixtures';\nimport { clipboardMatchers } from './matchers';\nimport type { ClipboardHandler } from './utils';\n\nexport const test = baseTest.extend<{\n clipboard: ClipboardHandler;\n}>(clipboardFixtures);\n\nexport const expect = baseExpect.extend({ ...clipboardMatchers });\n","/**\n * Playwright-compatible Clipboard utilities.\n *\n * Core functions for interacting with the browser clipboard within Playwright tests.\n * Provides wrappers for reading plain text and JSON.\n *\n * @remarks\n * These utilities require 'clipboard-read' and 'clipboard-write' permissions\n * to be granted in the browser context.\n */\n\nimport type { Page } from '@playwright/test';\n\nexport class ClipboardHandler {\n constructor(private readonly page: Page) {}\n\n /**\n * Reads the current text content from the browser clipboard.\n * If the content is a JSON-encoded string (e.g., has extra quotes),\n * it will be returned as is. Use readJSON for automatic parsing.\n *\n * @returns A promise that resolves to the clipboard string content.\n */\n async read(): Promise<string> {\n return await this.page.evaluate(() => navigator.clipboard.readText());\n }\n\n /**\n * Reads the clipboard content and parses it as JSON.\n * If the content is a string literal (e.g., '\"value\"'), it returns the unwrapped string ('value').\n *\n * @template T - The expected type of the parsed JSON object.\n * @returns A promise that resolves to the parsed JSON object of type T.\n * @throws {Error} If the clipboard content is not a valid JSON string.\n */\n async readJSON<T = unknown>(): Promise<T> {\n const text = await this.read();\n try {\n return JSON.parse(text);\n } catch {\n throw new Error(\n `[playwright-clipboard] Clipboard content is not a valid JSON: ${JSON.stringify(text)}`,\n );\n }\n }\n\n /**\n * Writes the provided string data to the browser clipboard.\n * @param data The data to write to the clipboard.\n */\n async write(data: string): Promise<void> {\n await this.page.evaluate((value) => navigator.clipboard.writeText(value), data);\n }\n\n /**\n * Writes the provided data to the browser clipboard as a JSON string.\n * @param data The data to write to the clipboard. It will be stringified as JSON.\n */\n async writeJSON<T = unknown>(data: T): Promise<void> {\n const errorMessage = '[playwright-clipboard] Provided data cannot be stringified to valid JSON';\n let jsonString: string | undefined;\n\n try {\n jsonString = JSON.stringify(data);\n } catch (error) {\n const message = error instanceof Error ? error : String(error);\n throw new Error(`${errorMessage}: ${message}`);\n }\n\n if (jsonString === undefined) {\n throw new Error(`${errorMessage} (received undefined).`);\n }\n\n await this.write(jsonString);\n }\n\n /**\n * Clears the browser clipboard by writing an empty string to it.\n * This effectively removes any existing content from the clipboard.\n */\n async clear(): Promise<void> {\n await this.write('');\n }\n}\n","import type { Page, TestFixture } from '@playwright/test';\nimport { ClipboardHandler } from '../utils';\nimport type { BrowserName } from './types';\n\n/**\n * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.\n * It allows reading from the clipboard during tests.\n */\nexport const clipboardFixture: TestFixture<\n ClipboardHandler,\n { page: Page; browserName: BrowserName }\n> = async ({ page, browserName }, use) => {\n if (browserName === 'webkit') {\n throw new Error(\n `[playwright-clipboard] Browser '${browserName}' is not supported. ` +\n 'Clipboard API testing is currently supported only in Chromium-based and Firefox browsers.\\n' +\n `Add test.skip(browserName === 'webkit', 'Clipboard API is only supported in Chromium and Firefox'); to your test body.`,\n );\n }\n\n const handler = new ClipboardHandler(page);\n await use(handler);\n};\n","import type { BrowserContext, TestFixture } from '@playwright/test';\nimport type { BrowserName } from './types';\n\n/**\n * A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.\n */\nexport const contextFixture: TestFixture<\n BrowserContext,\n { context: BrowserContext; browserName: BrowserName }\n> = async ({ context, browserName }, use) => {\n if (browserName === 'chromium') {\n await context.grantPermissions(['clipboard-read', 'clipboard-write']);\n }\n\n await use(context);\n};\n","import { clipboardFixture } from './clipboardFixture';\nimport { contextFixture } from './contextFixture';\n\n/**\n * A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.\n * These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.\n */\nexport const clipboardFixtures = {\n context: contextFixture,\n clipboard: clipboardFixture,\n};\n\nexport { clipboardFixture, contextFixture };\n","import { type ExpectMatcherState, expect, type MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils';\nimport { getErrorMessage, normalizeText } from '../utils/matcherUtils';\nimport type { TimeoutMatcherOptions, TrimMatcherOptions } from './types';\n\n/**\n * Asserts that the clipboard content is blank (empty string).\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param options Matcher options.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toBeBlank(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n options: TimeoutMatcherOptions & TrimMatcherOptions = {},\n) {\n const name = 'toBeBlank';\n let pass: boolean;\n let actual: string | undefined;\n let normalizedActual: string | undefined;\n const expected: string = '';\n let errorReason: Error | null = null;\n\n const { timeout = 10_000, trim = false } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.read();\n normalizedActual = actual;\n normalizedActual = normalizeText(normalizedActual, { trim });\n errorReason = null;\n\n return normalizedActual;\n } catch (error) {\n errorReason = error instanceof Error ? error : new Error(String(error));\n actual = undefined;\n normalizedActual = undefined;\n\n throw errorReason;\n }\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual, errorReason),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import type { ExpectMatcherState } from '@playwright/test';\n\n/**\n * Generates an error message for a custom matcher.\n *\n * @this ExpectMatcherState\n * @param name The name of the matcher.\n * @param expected The expected value.\n * @param actual The actual value.\n * @param error An optional error object.\n * @param errorMessage An optional error message string.\n * @returns A function that returns the error message string.\n */\nexport function getErrorMessage(\n this: ExpectMatcherState,\n name: string,\n expected: unknown,\n actual: unknown,\n error?: Error | null,\n errorMessage?: string | undefined | null,\n): () => string {\n const message = `${this.utils.matcherHint(name, undefined, undefined, { isNot: this.isNot })}\\n\\n`;\n\n if (error) {\n return () => `${message}An unexpected error occurred:\\n${error.message}`;\n }\n\n if (errorMessage) {\n return () => `${message}${errorMessage}`;\n }\n\n return () =>\n message +\n `Expected: ${this.isNot ? 'not ' : ''}${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(actual)}`;\n}\n\nexport function normalizeText<T extends string | RegExp>(\n data: T,\n options: { ignoreCase?: boolean; trim?: boolean } = {},\n): T {\n const { ignoreCase, trim } = options;\n\n if (typeof data === 'string') {\n let result: string = data;\n\n if (trim) result = result.trim();\n\n if (ignoreCase) result = result.toLowerCase();\n\n return result as T;\n }\n\n if (data instanceof RegExp) {\n const flags = data.flags.replace(/[gy]/g, '');\n const clearFlags = ignoreCase && !flags.includes('i') ? `${flags}i` : flags;\n\n return new RegExp(data.source, clearFlags) as T;\n }\n\n return data;\n}\n","import type { ExpectMatcherState, MatcherReturnType } from '@playwright/test';\nimport { expect } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils';\nimport { getErrorMessage } from '../utils/matcherUtils';\nimport type { TimeoutMatcherOptions } from './types';\n\n/**\n * Asserts that the clipboard content matches the expected JSON value.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The expected JSON value.\n * @param options Matcher options.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveJSONContent(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: unknown,\n options: TimeoutMatcherOptions = {},\n) {\n const name = 'toHaveJSONContent';\n let pass: boolean;\n let actual: unknown;\n let errorReason: Error | null = null;\n\n const { timeout = 10_000 } = options;\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.readJSON();\n errorReason = null;\n return actual;\n } catch (error) {\n errorReason = error instanceof Error ? error : new Error(String(error));\n\n try {\n actual = await clipboard.read();\n } catch {\n actual = undefined;\n }\n\n throw errorReason;\n }\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n await expectation.toEqual(expected);\n pass = true;\n } catch {\n pass = false;\n }\n\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual, errorReason),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import { type ExpectMatcherState, expect, type MatcherReturnType } from '@playwright/test';\nimport type { ClipboardHandler } from '../utils';\nimport { getErrorMessage, normalizeText } from '../utils/matcherUtils';\nimport type { IgnoreCaseMatcherOptions, TimeoutMatcherOptions, TrimMatcherOptions } from './types';\n\n/**\n * Asserts that the clipboard content matches the expected text value.\n *\n * @this ExpectMatcherState\n * @param clipboard The Clipboard utility instance.\n * @param expected The expected text value.\n * @param options Matcher options.\n * @returns A Promise that resolves to a MatcherReturnType object.\n */\nexport async function toHaveTextContent(\n this: ExpectMatcherState,\n clipboard: ClipboardHandler,\n expected: string | RegExp,\n options: TimeoutMatcherOptions & IgnoreCaseMatcherOptions & TrimMatcherOptions = {},\n) {\n const name = 'toHaveTextContent';\n let pass: boolean;\n let actual: string | undefined;\n let normalizedActual: string | undefined;\n let errorReason: Error | null = null;\n\n const { timeout = 10_000, ignoreCase = false, trim = false } = options;\n\n const normalizedExpected = normalizeText(expected, { ignoreCase, trim });\n\n const poll = expect.poll(\n async () => {\n try {\n actual = await clipboard.read();\n\n normalizedActual = actual;\n normalizedActual = normalizeText(normalizedActual, { ignoreCase, trim });\n errorReason = null;\n\n return normalizedActual;\n } catch (error) {\n errorReason = error instanceof Error ? error : new Error(String(error));\n actual = undefined;\n normalizedActual = undefined;\n\n throw errorReason;\n }\n },\n { timeout },\n );\n\n try {\n const expectation = this.isNot ? poll.not : poll;\n\n if (expected instanceof RegExp) {\n await expectation.toMatch(normalizedExpected as RegExp);\n } else {\n await expectation.toEqual(normalizedExpected);\n }\n\n pass = true;\n } catch {\n pass = false;\n }\n\n if (this.isNot) pass = !pass;\n\n const matcherReturn: MatcherReturnType = {\n message: getErrorMessage.call(this, name, expected, actual, errorReason),\n pass,\n name,\n expected,\n actual,\n };\n\n return matcherReturn;\n}\n","import { toBeBlank } from './toBeBlank';\nimport { toHaveJSONContent } from './toHaveJSONContent';\nimport { toHaveTextContent } from './toHaveTextContent';\n\n/**\n * Export an object containing all the custom clipboard matchers for Playwright.\n */\nexport const clipboardMatchers = {\n toBeBlank,\n toHaveJSONContent,\n toHaveTextContent,\n};\n","export const firefoxClipboardPrefs = {\n 'dom.events.testing.asyncClipboard': true,\n 'dom.events.asyncClipboard.readText': true,\n 'dom.events.asyncClipboard.writeText': true,\n 'permissions.default.clipboard-read': 1,\n 'permissions.default.clipboard-write': 1,\n};\n","/**\n * This module contains regular expression patterns for various common formats.\n * These patterns can be used for validation purposes in applications.\n */\nexport const PATTERNS = {\n /**\n * UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).\n */\n UUID: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n\n /**\n * Email addresses (example: user@example.com).\n */\n EMAIL: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/,\n\n /**\n * JWT tokens (example: header.payload.signature).\n */\n JWT: /^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$/,\n\n /**\n * Authorization Bearer tokens (example: Bearer <token>).\n */\n BEARER: /^Bearer\\s+[a-zA-Z0-9._~+/-]+=*$/i,\n\n /**\n * HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).\n */\n HEX_COLOR: /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,\n\n /**\n * IP (IPv4, IPv6 or any).\n */\n IP: {\n /** IPv4 (example: 192.168.1.1 or 127.0.0.1) */\n V4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,\n\n /** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */\n V6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2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