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/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
+
import { Page, ExpectMatcherState, MatcherReturnType, TestFixture, BrowserContext } from '@playwright/test';
|
|
1
2
|
import * as playwright_test from 'playwright/test';
|
|
2
3
|
import * as playwright_core from 'playwright-core';
|
|
3
|
-
import * as _playwright_test from '@playwright/test';
|
|
4
|
-
import { Page, TestFixture, BrowserContext, ExpectMatcherState, MatcherReturnType } from '@playwright/test';
|
|
5
|
-
|
|
6
|
-
declare const firefoxClipboardPrefs: {
|
|
7
|
-
'dom.events.testing.asyncClipboard': boolean;
|
|
8
|
-
'dom.events.asyncClipboard.readText': boolean;
|
|
9
|
-
'dom.events.asyncClipboard.writeText': boolean;
|
|
10
|
-
'permissions.default.clipboard-read': number;
|
|
11
|
-
'permissions.default.clipboard-write': number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
15
4
|
|
|
16
5
|
/**
|
|
17
6
|
* Playwright-compatible Clipboard utilities.
|
|
@@ -44,112 +33,84 @@ declare class ClipboardHandler {
|
|
|
44
33
|
* @throws {Error} If the clipboard content is not a valid JSON string.
|
|
45
34
|
*/
|
|
46
35
|
readJSON<T = unknown>(): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Writes the provided string data to the browser clipboard.
|
|
38
|
+
* @param data The data to write to the clipboard.
|
|
39
|
+
*/
|
|
40
|
+
write(data: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Writes the provided data to the browser clipboard as a JSON string.
|
|
43
|
+
* @param data The data to write to the clipboard. It will be stringified as JSON.
|
|
44
|
+
*/
|
|
45
|
+
writeJSON<T = unknown>(data: T): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Clears the browser clipboard by writing an empty string to it.
|
|
48
|
+
* This effectively removes any existing content from the clipboard.
|
|
49
|
+
*/
|
|
50
|
+
clear(): Promise<void>;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
* A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
|
|
51
|
-
* It allows reading from the clipboard during tests.
|
|
52
|
-
*/
|
|
53
|
-
declare const clipboardFixture: TestFixture<ClipboardHandler, {
|
|
54
|
-
page: Page;
|
|
55
|
-
browserName: BrowserName;
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
|
|
60
|
-
*/
|
|
61
|
-
declare const contextFixture: TestFixture<BrowserContext, {
|
|
62
|
-
context: BrowserContext;
|
|
63
|
-
browserName: BrowserName;
|
|
64
|
-
}>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
|
|
68
|
-
* These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
|
|
69
|
-
*/
|
|
70
|
-
declare const clipboardFixtures: {
|
|
71
|
-
context: playwright_test.TestFixture<playwright_core.BrowserContext, {
|
|
72
|
-
context: playwright_core.BrowserContext;
|
|
73
|
-
browserName: BrowserName;
|
|
74
|
-
}>;
|
|
75
|
-
clipboard: playwright_test.TestFixture<ClipboardHandler, {
|
|
76
|
-
page: playwright_core.Page;
|
|
77
|
-
browserName: BrowserName;
|
|
78
|
-
}>;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
type MatcherOptions = {
|
|
53
|
+
type TimeoutMatcherOptions = {
|
|
82
54
|
timeout?: number;
|
|
83
55
|
};
|
|
56
|
+
type IgnoreCaseMatcherOptions = {
|
|
57
|
+
ignoreCase?: boolean;
|
|
58
|
+
};
|
|
59
|
+
type TrimMatcherOptions = {
|
|
60
|
+
trim?: boolean;
|
|
61
|
+
};
|
|
84
62
|
declare global {
|
|
85
63
|
namespace PlaywrightTest {
|
|
86
64
|
interface Matchers<R> {
|
|
87
65
|
/**
|
|
88
|
-
* Asserts that the clipboard content
|
|
66
|
+
* Asserts that the clipboard content is empty.
|
|
89
67
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
90
68
|
*
|
|
91
|
-
* @param expected The string to compare against the clipboard content.
|
|
92
69
|
* @param options Matcher options.
|
|
93
70
|
* @returns A Promise that resolves when the assertion completes.
|
|
94
71
|
*
|
|
95
72
|
* @example
|
|
96
|
-
* await expect(clipboard).
|
|
73
|
+
* await expect(clipboard).toBeBlank();
|
|
97
74
|
*/
|
|
98
|
-
|
|
75
|
+
toBeBlank(options?: TimeoutMatcherOptions & TrimMatcherOptions): Promise<R>;
|
|
99
76
|
/**
|
|
100
|
-
* Asserts that the clipboard content matches the expected
|
|
77
|
+
* Asserts that the clipboard content matches the expected text.
|
|
101
78
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
102
79
|
*
|
|
103
|
-
* @param expected The
|
|
80
|
+
* @param expected The string or regular expression to compare against the clipboard content.
|
|
104
81
|
* @param options Matcher options.
|
|
105
82
|
* @returns A Promise that resolves when the assertion completes.
|
|
106
83
|
*
|
|
107
84
|
* @example
|
|
108
|
-
* await expect(clipboard).
|
|
85
|
+
* await expect(clipboard).toHaveTextContent('Copied value');
|
|
109
86
|
*/
|
|
110
|
-
|
|
87
|
+
toHaveTextContent(expected: string | RegExp, options?: TimeoutMatcherOptions & IgnoreCaseMatcherOptions & TrimMatcherOptions): Promise<R>;
|
|
111
88
|
/**
|
|
112
|
-
* Asserts that the clipboard content matches the expected value.
|
|
89
|
+
* Asserts that the clipboard content matches the expected JSON value.
|
|
113
90
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
114
|
-
* If the `expected` value is an object, it attempts to parse the clipboard
|
|
115
|
-
* content as JSON before comparing.
|
|
116
|
-
*
|
|
117
|
-
* @deprecated Use `toHaveText` or `toHaveJSON` instead. This matcher will be removed in future versions.
|
|
118
91
|
*
|
|
119
|
-
* @param expected The
|
|
120
|
-
* @param options
|
|
92
|
+
* @param expected The JSON value to compare against the clipboard content.
|
|
93
|
+
* @param options Matcher options.
|
|
121
94
|
* @returns A Promise that resolves when the assertion completes.
|
|
122
95
|
*
|
|
123
96
|
* @example
|
|
124
|
-
* await expect(clipboard).
|
|
125
|
-
* await expect(clipboard).toHaveData({ id: 123, status: 'success' });
|
|
97
|
+
* await expect(clipboard).toHaveJSONContent({ id: 123, status: 'success' });
|
|
126
98
|
*/
|
|
127
|
-
|
|
99
|
+
toHaveJSONContent(expected: unknown, options?: TimeoutMatcherOptions): Promise<R>;
|
|
128
100
|
}
|
|
129
101
|
}
|
|
130
102
|
}
|
|
131
103
|
|
|
132
104
|
/**
|
|
133
|
-
* Asserts that the clipboard content matches the expected value.
|
|
134
|
-
* Uses smart polling to wait for the clipboard to be updated.
|
|
135
|
-
* If the `expected` value is an object, it attempts to parse the clipboard
|
|
136
|
-
* content as JSON before comparing.
|
|
105
|
+
* Asserts that the clipboard content matches the expected text value.
|
|
137
106
|
*
|
|
138
107
|
* @this ExpectMatcherState
|
|
139
108
|
* @param clipboard The Clipboard utility instance.
|
|
140
|
-
* @param expected The
|
|
141
|
-
* @param options
|
|
109
|
+
* @param expected The expected text value.
|
|
110
|
+
* @param options Matcher options.
|
|
142
111
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
143
112
|
*/
|
|
144
|
-
declare function
|
|
145
|
-
name: string;
|
|
146
|
-
message: () => string;
|
|
147
|
-
pass: boolean;
|
|
148
|
-
expected?: unknown;
|
|
149
|
-
actual?: any;
|
|
150
|
-
log?: string[];
|
|
151
|
-
timeout?: number;
|
|
152
|
-
}>;
|
|
113
|
+
declare function toHaveTextContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: string | RegExp, options?: TimeoutMatcherOptions & IgnoreCaseMatcherOptions & TrimMatcherOptions): Promise<MatcherReturnType>;
|
|
153
114
|
|
|
154
115
|
/**
|
|
155
116
|
* Asserts that the clipboard content matches the expected JSON value.
|
|
@@ -160,35 +121,114 @@ declare function toHaveData(this: ExpectMatcherState, clipboard: ClipboardHandle
|
|
|
160
121
|
* @param options Matcher options.
|
|
161
122
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
162
123
|
*/
|
|
163
|
-
declare function toHaveJSONContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?:
|
|
124
|
+
declare function toHaveJSONContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?: TimeoutMatcherOptions): Promise<MatcherReturnType>;
|
|
164
125
|
|
|
165
126
|
/**
|
|
166
|
-
* Asserts that the clipboard content
|
|
127
|
+
* Asserts that the clipboard content is blank (empty string).
|
|
167
128
|
*
|
|
168
129
|
* @this ExpectMatcherState
|
|
169
130
|
* @param clipboard The Clipboard utility instance.
|
|
170
|
-
* @param expected The expected text value.
|
|
171
131
|
* @param options Matcher options.
|
|
172
132
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
173
133
|
*/
|
|
174
|
-
declare function
|
|
134
|
+
declare function toBeBlank(this: ExpectMatcherState, clipboard: ClipboardHandler, options?: TimeoutMatcherOptions & TrimMatcherOptions): Promise<MatcherReturnType>;
|
|
175
135
|
|
|
176
|
-
declare const test:
|
|
136
|
+
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
177
137
|
clipboard: ClipboardHandler;
|
|
178
|
-
},
|
|
179
|
-
declare const expect:
|
|
180
|
-
|
|
138
|
+
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
139
|
+
declare const expect: playwright_test.Expect<{
|
|
140
|
+
toBeBlank: typeof toBeBlank;
|
|
181
141
|
toHaveJSONContent: typeof toHaveJSONContent;
|
|
182
|
-
|
|
142
|
+
toHaveTextContent: typeof toHaveTextContent;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
declare const firefoxClipboardPrefs: {
|
|
146
|
+
'dom.events.testing.asyncClipboard': boolean;
|
|
147
|
+
'dom.events.asyncClipboard.readText': boolean;
|
|
148
|
+
'dom.events.asyncClipboard.writeText': boolean;
|
|
149
|
+
'permissions.default.clipboard-read': number;
|
|
150
|
+
'permissions.default.clipboard-write': number;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
|
|
157
|
+
* It allows reading from the clipboard during tests.
|
|
158
|
+
*/
|
|
159
|
+
declare const clipboardFixture: TestFixture<ClipboardHandler, {
|
|
160
|
+
page: Page;
|
|
161
|
+
browserName: BrowserName;
|
|
162
|
+
}>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
|
|
166
|
+
*/
|
|
167
|
+
declare const contextFixture: TestFixture<BrowserContext, {
|
|
168
|
+
context: BrowserContext;
|
|
169
|
+
browserName: BrowserName;
|
|
183
170
|
}>;
|
|
184
171
|
|
|
172
|
+
/**
|
|
173
|
+
* A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
|
|
174
|
+
* These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
|
|
175
|
+
*/
|
|
176
|
+
declare const clipboardFixtures: {
|
|
177
|
+
context: playwright_test.TestFixture<playwright_core.BrowserContext, {
|
|
178
|
+
context: playwright_core.BrowserContext;
|
|
179
|
+
browserName: BrowserName;
|
|
180
|
+
}>;
|
|
181
|
+
clipboard: playwright_test.TestFixture<ClipboardHandler, {
|
|
182
|
+
page: playwright_core.Page;
|
|
183
|
+
browserName: BrowserName;
|
|
184
|
+
}>;
|
|
185
|
+
};
|
|
186
|
+
|
|
185
187
|
/**
|
|
186
188
|
* Export an object containing all the custom clipboard matchers for Playwright.
|
|
187
189
|
*/
|
|
188
190
|
declare const clipboardMatchers: {
|
|
189
|
-
|
|
191
|
+
toBeBlank: typeof toBeBlank;
|
|
190
192
|
toHaveJSONContent: typeof toHaveJSONContent;
|
|
191
|
-
|
|
193
|
+
toHaveTextContent: typeof toHaveTextContent;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* This module contains regular expression patterns for various common formats.
|
|
198
|
+
* These patterns can be used for validation purposes in applications.
|
|
199
|
+
*/
|
|
200
|
+
declare const PATTERNS: {
|
|
201
|
+
/**
|
|
202
|
+
* UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
|
|
203
|
+
*/
|
|
204
|
+
readonly UUID: RegExp;
|
|
205
|
+
/**
|
|
206
|
+
* Email addresses (example: user@example.com).
|
|
207
|
+
*/
|
|
208
|
+
readonly EMAIL: RegExp;
|
|
209
|
+
/**
|
|
210
|
+
* JWT tokens (example: header.payload.signature).
|
|
211
|
+
*/
|
|
212
|
+
readonly JWT: RegExp;
|
|
213
|
+
/**
|
|
214
|
+
* Authorization Bearer tokens (example: Bearer <token>).
|
|
215
|
+
*/
|
|
216
|
+
readonly BEARER: RegExp;
|
|
217
|
+
/**
|
|
218
|
+
* HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
|
|
219
|
+
*/
|
|
220
|
+
readonly HEX_COLOR: RegExp;
|
|
221
|
+
/**
|
|
222
|
+
* IP (IPv4, IPv6 or any).
|
|
223
|
+
*/
|
|
224
|
+
readonly IP: {
|
|
225
|
+
/** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
|
|
226
|
+
readonly V4: RegExp;
|
|
227
|
+
/** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
|
|
228
|
+
readonly V6: RegExp;
|
|
229
|
+
/** Any IP address (IPv4 or IPv6) */
|
|
230
|
+
readonly ANY: RegExp;
|
|
231
|
+
};
|
|
192
232
|
};
|
|
193
233
|
|
|
194
|
-
export { ClipboardHandler, clipboardFixture, clipboardFixtures, clipboardMatchers, contextFixture, expect, firefoxClipboardPrefs, test };
|
|
234
|
+
export { ClipboardHandler, PATTERNS, clipboardFixture, clipboardFixtures, clipboardMatchers, contextFixture, expect, firefoxClipboardPrefs, test };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
+
import { Page, ExpectMatcherState, MatcherReturnType, TestFixture, BrowserContext } from '@playwright/test';
|
|
1
2
|
import * as playwright_test from 'playwright/test';
|
|
2
3
|
import * as playwright_core from 'playwright-core';
|
|
3
|
-
import * as _playwright_test from '@playwright/test';
|
|
4
|
-
import { Page, TestFixture, BrowserContext, ExpectMatcherState, MatcherReturnType } from '@playwright/test';
|
|
5
|
-
|
|
6
|
-
declare const firefoxClipboardPrefs: {
|
|
7
|
-
'dom.events.testing.asyncClipboard': boolean;
|
|
8
|
-
'dom.events.asyncClipboard.readText': boolean;
|
|
9
|
-
'dom.events.asyncClipboard.writeText': boolean;
|
|
10
|
-
'permissions.default.clipboard-read': number;
|
|
11
|
-
'permissions.default.clipboard-write': number;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
15
4
|
|
|
16
5
|
/**
|
|
17
6
|
* Playwright-compatible Clipboard utilities.
|
|
@@ -44,112 +33,84 @@ declare class ClipboardHandler {
|
|
|
44
33
|
* @throws {Error} If the clipboard content is not a valid JSON string.
|
|
45
34
|
*/
|
|
46
35
|
readJSON<T = unknown>(): Promise<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Writes the provided string data to the browser clipboard.
|
|
38
|
+
* @param data The data to write to the clipboard.
|
|
39
|
+
*/
|
|
40
|
+
write(data: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Writes the provided data to the browser clipboard as a JSON string.
|
|
43
|
+
* @param data The data to write to the clipboard. It will be stringified as JSON.
|
|
44
|
+
*/
|
|
45
|
+
writeJSON<T = unknown>(data: T): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Clears the browser clipboard by writing an empty string to it.
|
|
48
|
+
* This effectively removes any existing content from the clipboard.
|
|
49
|
+
*/
|
|
50
|
+
clear(): Promise<void>;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
* A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
|
|
51
|
-
* It allows reading from the clipboard during tests.
|
|
52
|
-
*/
|
|
53
|
-
declare const clipboardFixture: TestFixture<ClipboardHandler, {
|
|
54
|
-
page: Page;
|
|
55
|
-
browserName: BrowserName;
|
|
56
|
-
}>;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
|
|
60
|
-
*/
|
|
61
|
-
declare const contextFixture: TestFixture<BrowserContext, {
|
|
62
|
-
context: BrowserContext;
|
|
63
|
-
browserName: BrowserName;
|
|
64
|
-
}>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
|
|
68
|
-
* These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
|
|
69
|
-
*/
|
|
70
|
-
declare const clipboardFixtures: {
|
|
71
|
-
context: playwright_test.TestFixture<playwright_core.BrowserContext, {
|
|
72
|
-
context: playwright_core.BrowserContext;
|
|
73
|
-
browserName: BrowserName;
|
|
74
|
-
}>;
|
|
75
|
-
clipboard: playwright_test.TestFixture<ClipboardHandler, {
|
|
76
|
-
page: playwright_core.Page;
|
|
77
|
-
browserName: BrowserName;
|
|
78
|
-
}>;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
type MatcherOptions = {
|
|
53
|
+
type TimeoutMatcherOptions = {
|
|
82
54
|
timeout?: number;
|
|
83
55
|
};
|
|
56
|
+
type IgnoreCaseMatcherOptions = {
|
|
57
|
+
ignoreCase?: boolean;
|
|
58
|
+
};
|
|
59
|
+
type TrimMatcherOptions = {
|
|
60
|
+
trim?: boolean;
|
|
61
|
+
};
|
|
84
62
|
declare global {
|
|
85
63
|
namespace PlaywrightTest {
|
|
86
64
|
interface Matchers<R> {
|
|
87
65
|
/**
|
|
88
|
-
* Asserts that the clipboard content
|
|
66
|
+
* Asserts that the clipboard content is empty.
|
|
89
67
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
90
68
|
*
|
|
91
|
-
* @param expected The string to compare against the clipboard content.
|
|
92
69
|
* @param options Matcher options.
|
|
93
70
|
* @returns A Promise that resolves when the assertion completes.
|
|
94
71
|
*
|
|
95
72
|
* @example
|
|
96
|
-
* await expect(clipboard).
|
|
73
|
+
* await expect(clipboard).toBeBlank();
|
|
97
74
|
*/
|
|
98
|
-
|
|
75
|
+
toBeBlank(options?: TimeoutMatcherOptions & TrimMatcherOptions): Promise<R>;
|
|
99
76
|
/**
|
|
100
|
-
* Asserts that the clipboard content matches the expected
|
|
77
|
+
* Asserts that the clipboard content matches the expected text.
|
|
101
78
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
102
79
|
*
|
|
103
|
-
* @param expected The
|
|
80
|
+
* @param expected The string or regular expression to compare against the clipboard content.
|
|
104
81
|
* @param options Matcher options.
|
|
105
82
|
* @returns A Promise that resolves when the assertion completes.
|
|
106
83
|
*
|
|
107
84
|
* @example
|
|
108
|
-
* await expect(clipboard).
|
|
85
|
+
* await expect(clipboard).toHaveTextContent('Copied value');
|
|
109
86
|
*/
|
|
110
|
-
|
|
87
|
+
toHaveTextContent(expected: string | RegExp, options?: TimeoutMatcherOptions & IgnoreCaseMatcherOptions & TrimMatcherOptions): Promise<R>;
|
|
111
88
|
/**
|
|
112
|
-
* Asserts that the clipboard content matches the expected value.
|
|
89
|
+
* Asserts that the clipboard content matches the expected JSON value.
|
|
113
90
|
* Uses smart polling to wait for the clipboard to be updated.
|
|
114
|
-
* If the `expected` value is an object, it attempts to parse the clipboard
|
|
115
|
-
* content as JSON before comparing.
|
|
116
|
-
*
|
|
117
|
-
* @deprecated Use `toHaveText` or `toHaveJSON` instead. This matcher will be removed in future versions.
|
|
118
91
|
*
|
|
119
|
-
* @param expected The
|
|
120
|
-
* @param options
|
|
92
|
+
* @param expected The JSON value to compare against the clipboard content.
|
|
93
|
+
* @param options Matcher options.
|
|
121
94
|
* @returns A Promise that resolves when the assertion completes.
|
|
122
95
|
*
|
|
123
96
|
* @example
|
|
124
|
-
* await expect(clipboard).
|
|
125
|
-
* await expect(clipboard).toHaveData({ id: 123, status: 'success' });
|
|
97
|
+
* await expect(clipboard).toHaveJSONContent({ id: 123, status: 'success' });
|
|
126
98
|
*/
|
|
127
|
-
|
|
99
|
+
toHaveJSONContent(expected: unknown, options?: TimeoutMatcherOptions): Promise<R>;
|
|
128
100
|
}
|
|
129
101
|
}
|
|
130
102
|
}
|
|
131
103
|
|
|
132
104
|
/**
|
|
133
|
-
* Asserts that the clipboard content matches the expected value.
|
|
134
|
-
* Uses smart polling to wait for the clipboard to be updated.
|
|
135
|
-
* If the `expected` value is an object, it attempts to parse the clipboard
|
|
136
|
-
* content as JSON before comparing.
|
|
105
|
+
* Asserts that the clipboard content matches the expected text value.
|
|
137
106
|
*
|
|
138
107
|
* @this ExpectMatcherState
|
|
139
108
|
* @param clipboard The Clipboard utility instance.
|
|
140
|
-
* @param expected The
|
|
141
|
-
* @param options
|
|
109
|
+
* @param expected The expected text value.
|
|
110
|
+
* @param options Matcher options.
|
|
142
111
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
143
112
|
*/
|
|
144
|
-
declare function
|
|
145
|
-
name: string;
|
|
146
|
-
message: () => string;
|
|
147
|
-
pass: boolean;
|
|
148
|
-
expected?: unknown;
|
|
149
|
-
actual?: any;
|
|
150
|
-
log?: string[];
|
|
151
|
-
timeout?: number;
|
|
152
|
-
}>;
|
|
113
|
+
declare function toHaveTextContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: string | RegExp, options?: TimeoutMatcherOptions & IgnoreCaseMatcherOptions & TrimMatcherOptions): Promise<MatcherReturnType>;
|
|
153
114
|
|
|
154
115
|
/**
|
|
155
116
|
* Asserts that the clipboard content matches the expected JSON value.
|
|
@@ -160,35 +121,114 @@ declare function toHaveData(this: ExpectMatcherState, clipboard: ClipboardHandle
|
|
|
160
121
|
* @param options Matcher options.
|
|
161
122
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
162
123
|
*/
|
|
163
|
-
declare function toHaveJSONContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?:
|
|
124
|
+
declare function toHaveJSONContent(this: ExpectMatcherState, clipboard: ClipboardHandler, expected: unknown, options?: TimeoutMatcherOptions): Promise<MatcherReturnType>;
|
|
164
125
|
|
|
165
126
|
/**
|
|
166
|
-
* Asserts that the clipboard content
|
|
127
|
+
* Asserts that the clipboard content is blank (empty string).
|
|
167
128
|
*
|
|
168
129
|
* @this ExpectMatcherState
|
|
169
130
|
* @param clipboard The Clipboard utility instance.
|
|
170
|
-
* @param expected The expected text value.
|
|
171
131
|
* @param options Matcher options.
|
|
172
132
|
* @returns A Promise that resolves to a MatcherReturnType object.
|
|
173
133
|
*/
|
|
174
|
-
declare function
|
|
134
|
+
declare function toBeBlank(this: ExpectMatcherState, clipboard: ClipboardHandler, options?: TimeoutMatcherOptions & TrimMatcherOptions): Promise<MatcherReturnType>;
|
|
175
135
|
|
|
176
|
-
declare const test:
|
|
136
|
+
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & {
|
|
177
137
|
clipboard: ClipboardHandler;
|
|
178
|
-
},
|
|
179
|
-
declare const expect:
|
|
180
|
-
|
|
138
|
+
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
139
|
+
declare const expect: playwright_test.Expect<{
|
|
140
|
+
toBeBlank: typeof toBeBlank;
|
|
181
141
|
toHaveJSONContent: typeof toHaveJSONContent;
|
|
182
|
-
|
|
142
|
+
toHaveTextContent: typeof toHaveTextContent;
|
|
143
|
+
}>;
|
|
144
|
+
|
|
145
|
+
declare const firefoxClipboardPrefs: {
|
|
146
|
+
'dom.events.testing.asyncClipboard': boolean;
|
|
147
|
+
'dom.events.asyncClipboard.readText': boolean;
|
|
148
|
+
'dom.events.asyncClipboard.writeText': boolean;
|
|
149
|
+
'permissions.default.clipboard-read': number;
|
|
150
|
+
'permissions.default.clipboard-write': number;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
|
|
157
|
+
* It allows reading from the clipboard during tests.
|
|
158
|
+
*/
|
|
159
|
+
declare const clipboardFixture: TestFixture<ClipboardHandler, {
|
|
160
|
+
page: Page;
|
|
161
|
+
browserName: BrowserName;
|
|
162
|
+
}>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
|
|
166
|
+
*/
|
|
167
|
+
declare const contextFixture: TestFixture<BrowserContext, {
|
|
168
|
+
context: BrowserContext;
|
|
169
|
+
browserName: BrowserName;
|
|
183
170
|
}>;
|
|
184
171
|
|
|
172
|
+
/**
|
|
173
|
+
* A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
|
|
174
|
+
* These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
|
|
175
|
+
*/
|
|
176
|
+
declare const clipboardFixtures: {
|
|
177
|
+
context: playwright_test.TestFixture<playwright_core.BrowserContext, {
|
|
178
|
+
context: playwright_core.BrowserContext;
|
|
179
|
+
browserName: BrowserName;
|
|
180
|
+
}>;
|
|
181
|
+
clipboard: playwright_test.TestFixture<ClipboardHandler, {
|
|
182
|
+
page: playwright_core.Page;
|
|
183
|
+
browserName: BrowserName;
|
|
184
|
+
}>;
|
|
185
|
+
};
|
|
186
|
+
|
|
185
187
|
/**
|
|
186
188
|
* Export an object containing all the custom clipboard matchers for Playwright.
|
|
187
189
|
*/
|
|
188
190
|
declare const clipboardMatchers: {
|
|
189
|
-
|
|
191
|
+
toBeBlank: typeof toBeBlank;
|
|
190
192
|
toHaveJSONContent: typeof toHaveJSONContent;
|
|
191
|
-
|
|
193
|
+
toHaveTextContent: typeof toHaveTextContent;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* This module contains regular expression patterns for various common formats.
|
|
198
|
+
* These patterns can be used for validation purposes in applications.
|
|
199
|
+
*/
|
|
200
|
+
declare const PATTERNS: {
|
|
201
|
+
/**
|
|
202
|
+
* UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
|
|
203
|
+
*/
|
|
204
|
+
readonly UUID: RegExp;
|
|
205
|
+
/**
|
|
206
|
+
* Email addresses (example: user@example.com).
|
|
207
|
+
*/
|
|
208
|
+
readonly EMAIL: RegExp;
|
|
209
|
+
/**
|
|
210
|
+
* JWT tokens (example: header.payload.signature).
|
|
211
|
+
*/
|
|
212
|
+
readonly JWT: RegExp;
|
|
213
|
+
/**
|
|
214
|
+
* Authorization Bearer tokens (example: Bearer <token>).
|
|
215
|
+
*/
|
|
216
|
+
readonly BEARER: RegExp;
|
|
217
|
+
/**
|
|
218
|
+
* HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
|
|
219
|
+
*/
|
|
220
|
+
readonly HEX_COLOR: RegExp;
|
|
221
|
+
/**
|
|
222
|
+
* IP (IPv4, IPv6 or any).
|
|
223
|
+
*/
|
|
224
|
+
readonly IP: {
|
|
225
|
+
/** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
|
|
226
|
+
readonly V4: RegExp;
|
|
227
|
+
/** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
|
|
228
|
+
readonly V6: RegExp;
|
|
229
|
+
/** Any IP address (IPv4 or IPv6) */
|
|
230
|
+
readonly ANY: RegExp;
|
|
231
|
+
};
|
|
192
232
|
};
|
|
193
233
|
|
|
194
|
-
export { ClipboardHandler, clipboardFixture, clipboardFixtures, clipboardMatchers, contextFixture, expect, firefoxClipboardPrefs, test };
|
|
234
|
+
export { ClipboardHandler, PATTERNS, clipboardFixture, clipboardFixtures, clipboardMatchers, contextFixture, expect, firefoxClipboardPrefs, test };
|