playwright-clipboard-testing 0.7.0 → 0.9.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.
Files changed (69) hide show
  1. package/README.md +9 -9
  2. package/dist/baseFixtures.d.ts +8 -0
  3. package/dist/baseFixtures.d.ts.map +1 -0
  4. package/dist/constants/constants.d.ts +8 -0
  5. package/dist/constants/constants.d.ts.map +1 -0
  6. package/dist/constants/index.cjs.map +1 -1
  7. package/dist/constants/index.d.cts +4 -51
  8. package/dist/constants/index.d.ts +4 -51
  9. package/dist/constants/index.d.ts.map +1 -0
  10. package/dist/constants/patterns.d.ts +42 -0
  11. package/dist/constants/patterns.d.ts.map +1 -0
  12. package/dist/fixtures/clipboardFixture.d.ts +12 -0
  13. package/dist/fixtures/clipboardFixture.d.ts.map +1 -0
  14. package/dist/fixtures/contextFixture.d.ts +10 -0
  15. package/dist/fixtures/contextFixture.d.ts.map +1 -0
  16. package/dist/fixtures/index.cjs +46 -13
  17. package/dist/fixtures/index.cjs.map +1 -1
  18. package/dist/fixtures/index.d.cts +13 -33
  19. package/dist/fixtures/index.d.ts +13 -33
  20. package/dist/fixtures/index.d.ts.map +1 -0
  21. package/dist/fixtures/index.js +46 -13
  22. package/dist/fixtures/index.js.map +1 -1
  23. package/dist/fixtures/types.d.ts +2 -0
  24. package/dist/fixtures/types.d.ts.map +1 -0
  25. package/dist/index.cjs +68 -38
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +2 -17
  28. package/dist/index.d.ts +2 -17
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +56 -26
  31. package/dist/index.js.map +1 -1
  32. package/dist/matchers/clipboardMatchers.d.ts +13 -0
  33. package/dist/matchers/clipboardMatchers.d.ts.map +1 -0
  34. package/dist/matchers/index.cjs +8 -11
  35. package/dist/matchers/index.cjs.map +1 -1
  36. package/dist/matchers/index.d.cts +3 -15
  37. package/dist/matchers/index.d.ts +3 -15
  38. package/dist/matchers/index.d.ts.map +1 -0
  39. package/dist/matchers/index.js +8 -11
  40. package/dist/matchers/index.js.map +1 -1
  41. package/dist/matchers/toBeBlank.d.ts +13 -0
  42. package/dist/matchers/toBeBlank.d.ts.map +1 -0
  43. package/dist/matchers/toHaveContentLength.d.ts +14 -0
  44. package/dist/matchers/toHaveContentLength.d.ts.map +1 -0
  45. package/dist/matchers/toHaveJSONContent.d.ts +14 -0
  46. package/dist/matchers/toHaveJSONContent.d.ts.map +1 -0
  47. package/dist/matchers/toHaveTextContent.d.ts +14 -0
  48. package/dist/matchers/toHaveTextContent.d.ts.map +1 -0
  49. package/dist/matchers/toMatchJSONContent.d.ts +14 -0
  50. package/dist/matchers/toMatchJSONContent.d.ts.map +1 -0
  51. package/dist/{toBeBlank-wAm_5G4T.d.ts → matchers/types.d.ts} +4 -62
  52. package/dist/matchers/types.d.ts.map +1 -0
  53. package/dist/{clipboardHandler-CFIUvkc0.d.cts → utils/clipboard/clipboardHandler.d.ts} +5 -6
  54. package/dist/utils/clipboard/clipboardHandler.d.ts.map +1 -0
  55. package/dist/utils/clipboard/runInStep.d.ts +2 -0
  56. package/dist/utils/clipboard/runInStep.d.ts.map +1 -0
  57. package/dist/utils/index.d.ts +3 -0
  58. package/dist/utils/index.d.ts.map +1 -0
  59. package/dist/utils/matchers/getErrorMessage.d.ts +14 -0
  60. package/dist/utils/matchers/getErrorMessage.d.ts.map +1 -0
  61. package/dist/utils/matchers/normalizeText.d.ts +11 -0
  62. package/dist/utils/matchers/normalizeText.d.ts.map +1 -0
  63. package/dist/utils/tests/createFakeClipboard.d.ts +6 -0
  64. package/dist/utils/tests/createFakeClipboard.d.ts.map +1 -0
  65. package/dist/utils/tests/createMatcherState.d.ts +3 -0
  66. package/dist/utils/tests/createMatcherState.d.ts.map +1 -0
  67. package/package.json +16 -2
  68. package/dist/clipboardHandler-CFIUvkc0.d.ts +0 -51
  69. package/dist/toBeBlank-uFClUdzK.d.cts +0 -133
package/README.md CHANGED
@@ -111,12 +111,12 @@ export const expect = baseExpect.extend(clipboardMatchers);
111
111
 
112
112
  The package provides dedicated subpath exports to import specific utilities when extending Playwright:
113
113
 
114
- | Import Path | Exports | Description |
115
- |:-----------------------------------------|:------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------|
116
- | `playwright-clipboard-testing` | `test`, `expect` | Ready-to-use Playwright `test` runner and `expect` assertion function with built-in clipboard support. |
117
- | `playwright-clipboard-testing/constants` | `firefoxClipboardPrefs`, `PATTERNS` | Firefox browser preferences for clipboard permissions and regex patterns for clipboard assertions. |
118
- | `playwright-clipboard-testing/fixtures` | `clipboardFixtures`, `clipboardFixture`, `contextFixture`, `ClipboardHandler` | Playwright test fixtures and `ClipboardHandler` class for extending custom test setups. |
119
- | `playwright-clipboard-testing/matchers` | `clipboardMatchers` | Custom Playwright matchers for extending custom `expect`. |
114
+ | Import Path | Exports | Description |
115
+ |:-----------------------------------------|:---------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------|
116
+ | `playwright-clipboard-testing` | `test`, `expect` | Ready-to-use Playwright `test` runner and `expect` assertion function with built-in clipboard support. |
117
+ | `playwright-clipboard-testing/constants` | `firefoxClipboardPrefs`, `PATTERNS` | Firefox browser preferences for clipboard permissions and regex patterns for clipboard assertions. |
118
+ | `playwright-clipboard-testing/fixtures` | `clipboardFixtures`, `clipboardFixture`, `contextFixture`, `ClipboardHandler`, `BrowserName` | Playwright test fixtures, `ClipboardHandler` class, and type definitions for extending custom test setups. |
119
+ | `playwright-clipboard-testing/matchers` | `clipboardMatchers`, `ClipboardMatchers` | Custom Playwright matchers for extending custom `expect`. |
120
120
 
121
121
  ## API
122
122
 
@@ -187,7 +187,7 @@ await expect(clipboard).toHaveTextContent('Hello, World!');
187
187
  await expect(clipboard).toHaveTextContent(/Hello, World!/i);
188
188
  ```
189
189
  ```ts
190
- // assert that the clipboard is not containing the expected text with a custom timeout
190
+ // assert that the clipboard does not contain the expected text with a custom timeout
191
191
  await expect(clipboard).not.toHaveTextContent('Async copied value', { timeout: 5000 });
192
192
  ```
193
193
 
@@ -201,7 +201,7 @@ Asserts that the clipboard content matches the expected JSON value. Uses Playwri
201
201
  await expect(clipboard).toHaveJSONContent({ message: 'Hello, World!' });
202
202
  ```
203
203
  ```ts
204
- // assert that the clipboard is not containing the expected JSON data with a custom timeout
204
+ // assert that the clipboard does not contain the expected JSON data with a custom timeout
205
205
  await expect(clipboard).not.toHaveJSONContent({ message: 'Async copied value' }, { timeout: 5000 });
206
206
  ```
207
207
 
@@ -215,7 +215,7 @@ Asserts that the expected JSON object is a subset of the clipboard content. Uses
215
215
  await expect(clipboard).toMatchJSONContent({ status: 'success' });
216
216
  ```
217
217
  ```ts
218
- // assert that the clipboard is not containing a subset of the expected JSON data with a custom timeout
218
+ // assert that the clipboard does not contain a subset of the expected JSON data with a custom timeout
219
219
  await expect(clipboard).not.toMatchJSONContent({ status: 'failed' }, { timeout: 5000 });
220
220
  ```
221
221
 
@@ -0,0 +1,8 @@
1
+ import type { ClipboardHandler } from './utils';
2
+ export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & {
3
+ clipboard: ClipboardHandler;
4
+ }, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions>;
5
+ export declare const expect: import("playwright/test").Expect<{
6
+ [x: string]: (this: import("playwright/test").ExpectMatcherState, clipboard: ClipboardHandler, ...args: any[]) => Promise<import("playwright/test").MatcherReturnType>;
7
+ }>;
8
+ //# sourceMappingURL=baseFixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseFixtures.d.ts","sourceRoot":"","sources":["../src/baseFixtures.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,IAAI;eACJ,gBAAgB;sGACR,CAAC;AAEtB,eAAO,MAAM,MAAM;;EAA8C,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const firefoxClipboardPrefs: {
2
+ 'dom.events.testing.asyncClipboard': boolean;
3
+ 'dom.events.asyncClipboard.readText': boolean;
4
+ 'dom.events.asyncClipboard.writeText': boolean;
5
+ 'permissions.default.clipboard-read': number;
6
+ 'permissions.default.clipboard-write': number;
7
+ };
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB;;;;;;CAMjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/index.ts","../../src/constants/constants.ts","../../src/constants/patterns.ts"],"sourcesContent":["import { firefoxClipboardPrefs } from './constants.ts';\nimport { PATTERNS } from './patterns.ts';\n\nexport { firefoxClipboardPrefs, PATTERNS };\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 * Phone numbers in E.164 format (example: +1234567890).\n */\n PHONE: /^\\+[1-9]\\d{1,14}$/,\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[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]))$/,\n\n /** Any IP address (IPv4 or IPv6) */\n ANY: /^(?:(?:(?:25[0-5]|2[0-4][0-9]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AAAA;AAAA;AAAA;AAAA,EAKR,WAAW;AAAA;AAAA;AAAA;AAAA,EAKX,IAAI;AAAA;AAAA,IAEF,IAAI;AAAA;AAAA,IAGJ,IAAI;AAAA;AAAA,IAGJ,KAAK;AAAA,EACP;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/constants/index.ts","../../src/constants/constants.ts","../../src/constants/patterns.ts"],"sourcesContent":["import { firefoxClipboardPrefs } from './constants';\nimport { PATTERNS } from './patterns';\n\nexport { firefoxClipboardPrefs, PATTERNS };\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 * Phone numbers in E.164 format (example: +1234567890).\n */\n PHONE: /^\\+[1-9]\\d{1,14}$/,\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[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]))$/,\n\n /** Any IP address (IPv4 or IPv6) */\n ANY: /^(?:(?:(?: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]?)|(?:([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-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ardPrefs: {
2
- 'dom.events.testing.asyncClipboard': boolean;
3
- 'dom.events.asyncClipboard.readText': boolean;
4
- 'dom.events.asyncClipboard.writeText': boolean;
5
- 'permissions.default.clipboard-read': number;
6
- 'permissions.default.clipboard-write': number;
7
- };
8
-
9
- /**
10
- * This module contains regular expression patterns for various common formats.
11
- * These patterns can be used for validation purposes in applications.
12
- */
13
- declare const PATTERNS: {
14
- /**
15
- * UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
16
- */
17
- readonly UUID: RegExp;
18
- /**
19
- * Email addresses (example: user@example.com).
20
- */
21
- readonly EMAIL: RegExp;
22
- /**
23
- * Phone numbers in E.164 format (example: +1234567890).
24
- */
25
- readonly PHONE: RegExp;
26
- /**
27
- * JWT tokens (example: header.payload.signature).
28
- */
29
- readonly JWT: RegExp;
30
- /**
31
- * Authorization Bearer tokens (example: Bearer <token>).
32
- */
33
- readonly BEARER: RegExp;
34
- /**
35
- * HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
36
- */
37
- readonly HEX_COLOR: RegExp;
38
- /**
39
- * IP (IPv4, IPv6 or any).
40
- */
41
- readonly IP: {
42
- /** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
43
- readonly V4: RegExp;
44
- /** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
45
- readonly V6: RegExp;
46
- /** Any IP address (IPv4 or IPv6) */
47
- readonly ANY: RegExp;
48
- };
49
- };
50
-
51
- export { PATTERNS, firefoxClipboardPrefs };
1
+ import { firefoxClipboardPrefs } from './constants';
2
+ import { PATTERNS } from './patterns';
3
+ export { firefoxClipboardPrefs, PATTERNS };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,51 +1,4 @@
1
- declare const firefoxClipboardPrefs: {
2
- 'dom.events.testing.asyncClipboard': boolean;
3
- 'dom.events.asyncClipboard.readText': boolean;
4
- 'dom.events.asyncClipboard.writeText': boolean;
5
- 'permissions.default.clipboard-read': number;
6
- 'permissions.default.clipboard-write': number;
7
- };
8
-
9
- /**
10
- * This module contains regular expression patterns for various common formats.
11
- * These patterns can be used for validation purposes in applications.
12
- */
13
- declare const PATTERNS: {
14
- /**
15
- * UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
16
- */
17
- readonly UUID: RegExp;
18
- /**
19
- * Email addresses (example: user@example.com).
20
- */
21
- readonly EMAIL: RegExp;
22
- /**
23
- * Phone numbers in E.164 format (example: +1234567890).
24
- */
25
- readonly PHONE: RegExp;
26
- /**
27
- * JWT tokens (example: header.payload.signature).
28
- */
29
- readonly JWT: RegExp;
30
- /**
31
- * Authorization Bearer tokens (example: Bearer <token>).
32
- */
33
- readonly BEARER: RegExp;
34
- /**
35
- * HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
36
- */
37
- readonly HEX_COLOR: RegExp;
38
- /**
39
- * IP (IPv4, IPv6 or any).
40
- */
41
- readonly IP: {
42
- /** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
43
- readonly V4: RegExp;
44
- /** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
45
- readonly V6: RegExp;
46
- /** Any IP address (IPv4 or IPv6) */
47
- readonly ANY: RegExp;
48
- };
49
- };
50
-
51
- export { PATTERNS, firefoxClipboardPrefs };
1
+ import { firefoxClipboardPrefs } from './constants';
2
+ import { PATTERNS } from './patterns';
3
+ export { firefoxClipboardPrefs, PATTERNS };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * This module contains regular expression patterns for various common formats.
3
+ * These patterns can be used for validation purposes in applications.
4
+ */
5
+ export declare const PATTERNS: {
6
+ /**
7
+ * UUID v1-v5 (example: 123e4567-e89b-12d3-a456-426614174000).
8
+ */
9
+ readonly UUID: RegExp;
10
+ /**
11
+ * Email addresses (example: user@example.com).
12
+ */
13
+ readonly EMAIL: RegExp;
14
+ /**
15
+ * Phone numbers in E.164 format (example: +1234567890).
16
+ */
17
+ readonly PHONE: RegExp;
18
+ /**
19
+ * JWT tokens (example: header.payload.signature).
20
+ */
21
+ readonly JWT: RegExp;
22
+ /**
23
+ * Authorization Bearer tokens (example: Bearer <token>).
24
+ */
25
+ readonly BEARER: RegExp;
26
+ /**
27
+ * HEX-colors (example: #FFF, #FFFFFF, #FFFFFFFF).
28
+ */
29
+ readonly HEX_COLOR: RegExp;
30
+ /**
31
+ * IP (IPv4, IPv6 or any).
32
+ */
33
+ readonly IP: {
34
+ /** IPv4 (example: 192.168.1.1 or 127.0.0.1) */
35
+ readonly V4: RegExp;
36
+ /** IPv6 (example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334) */
37
+ readonly V6: RegExp;
38
+ /** Any IP address (IPv4 or IPv6) */
39
+ readonly ANY: RegExp;
40
+ };
41
+ };
42
+ //# sourceMappingURL=patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/constants/patterns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,QAAQ;IACnB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;QAED,+CAA+C;;QAG/C,8DAA8D;;QAG9D,oCAAoC;;;CAG9B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Page, TestFixture } from '@playwright/test';
2
+ import { ClipboardHandler } from '../utils';
3
+ import type { BrowserName } from './types';
4
+ /**
5
+ * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
6
+ * It allows reading from the clipboard during tests.
7
+ */
8
+ export declare const clipboardFixture: TestFixture<ClipboardHandler, {
9
+ page: Page;
10
+ browserName: BrowserName;
11
+ }>;
12
+ //# sourceMappingURL=clipboardFixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboardFixture.d.ts","sourceRoot":"","sources":["../../src/fixtures/clipboardFixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAAW,CACxC,gBAAgB,EAChB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,CAYzC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { BrowserContext, TestFixture } from '@playwright/test';
2
+ import type { BrowserName } from './types';
3
+ /**
4
+ * A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
5
+ */
6
+ export declare const contextFixture: TestFixture<BrowserContext, {
7
+ context: BrowserContext;
8
+ browserName: BrowserName;
9
+ }>;
10
+ //# sourceMappingURL=contextFixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contextFixture.d.ts","sourceRoot":"","sources":["../../src/fixtures/contextFixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CACtC,cAAc,EACd;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,CAOtD,CAAC"}
@@ -27,12 +27,35 @@ __export(fixtures_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(fixtures_exports);
29
29
 
30
- // src/utils/clipboardHandler.ts
30
+ // src/utils/clipboard/runInStep.ts
31
+ var import_test = require("@playwright/test");
32
+ var isTestRunning = () => {
33
+ try {
34
+ return !!import_test.test.info();
35
+ } catch {
36
+ return false;
37
+ }
38
+ };
39
+ var runInStep = async (stepName, fn) => {
40
+ if (isTestRunning()) {
41
+ return await import_test.test.step(stepName, fn, { box: true });
42
+ } else {
43
+ return await fn();
44
+ }
45
+ };
46
+
47
+ // src/utils/clipboard/clipboardHandler.ts
31
48
  var ClipboardHandler = class {
32
49
  constructor(page) {
33
50
  this.page = page;
34
51
  }
35
52
  page;
53
+ async _write(data) {
54
+ await this.page.evaluate((value) => navigator.clipboard.writeText(value), data);
55
+ }
56
+ async _read() {
57
+ return await this.page.evaluate(() => navigator.clipboard.readText());
58
+ }
36
59
  /**
37
60
  * Reads the current text content from the browser clipboard.
38
61
  * If the content is a JSON-encoded string (e.g., has extra quotes),
@@ -41,7 +64,9 @@ var ClipboardHandler = class {
41
64
  * @returns A promise that resolves to the clipboard string content.
42
65
  */
43
66
  async read() {
44
- return await this.page.evaluate(() => navigator.clipboard.readText());
67
+ return await runInStep('Clipboard "read"', async () => {
68
+ return await this._read();
69
+ });
45
70
  }
46
71
  /**
47
72
  * Reads the clipboard content and parses it as JSON.
@@ -52,21 +77,25 @@ var ClipboardHandler = class {
52
77
  * @throws {Error} If the clipboard content is not a valid JSON string.
53
78
  */
54
79
  async readJSON() {
55
- const text = await this.read();
56
- try {
57
- return JSON.parse(text);
58
- } catch {
59
- throw new Error(
60
- `[playwright-clipboard] Clipboard content is not a valid JSON: ${JSON.stringify(text)}`
61
- );
62
- }
80
+ return await runInStep('Clipboard "readJSON"', async () => {
81
+ const text = await this._read();
82
+ try {
83
+ return JSON.parse(text);
84
+ } catch {
85
+ throw new Error(
86
+ `[playwright-clipboard] Clipboard content is not a valid JSON: ${JSON.stringify(text)}`
87
+ );
88
+ }
89
+ });
63
90
  }
64
91
  /**
65
92
  * Writes the provided string data to the browser clipboard.
66
93
  * @param data The data to write to the clipboard.
67
94
  */
68
95
  async write(data) {
69
- await this.page.evaluate((value) => navigator.clipboard.writeText(value), data);
96
+ await runInStep('Clipboard "write"', async () => {
97
+ await this._write(data);
98
+ });
70
99
  }
71
100
  /**
72
101
  * Writes the provided data to the browser clipboard as a JSON string.
@@ -84,14 +113,18 @@ var ClipboardHandler = class {
84
113
  if (jsonString === void 0) {
85
114
  throw new Error(`${errorMessage} (received undefined).`);
86
115
  }
87
- await this.write(jsonString);
116
+ await runInStep('Clipboard "writeJSON"', async () => {
117
+ await this._write(jsonString);
118
+ });
88
119
  }
89
120
  /**
90
121
  * Clears the browser clipboard by writing an empty string to it.
91
122
  * This effectively removes any existing content from the clipboard.
92
123
  */
93
124
  async clear() {
94
- await this.write("");
125
+ await runInStep('Clipboard "clear"', async () => {
126
+ await this._write("");
127
+ });
95
128
  }
96
129
  };
97
130
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fixtures/index.ts","../../src/utils/clipboardHandler.ts","../../src/fixtures/clipboardFixture.ts","../../src/fixtures/contextFixture.ts"],"sourcesContent":["import { ClipboardHandler } from '../utils';\nimport { clipboardFixture } from './clipboardFixture.ts';\nimport { contextFixture } from './contextFixture.ts';\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 { ClipboardHandler, clipboardFixture, contextFixture };\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.ts';\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.ts';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,MAAY;AAAZ;AAAA,EAAa;AAAA,EAAb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,MAAM,OAAwB;AAC5B,WAAO,MAAM,KAAK,KAAK,SAAS,MAAM,UAAU,UAAU,SAAS,CAAC;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,WAAoC;AACxC,UAAM,OAAO,MAAM,KAAK,KAAK;AAC7B,QAAI;AACF,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB,QAAQ;AACN,YAAM,IAAI;AAAA,QACR,iEAAiE,KAAK,UAAU,IAAI,CAAC;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAM,MAA6B;AACvC,UAAM,KAAK,KAAK,SAAS,CAAC,UAAU,UAAU,UAAU,UAAU,KAAK,GAAG,IAAI;AAAA,EAChF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAuB,MAAwB;AACnD,UAAM,eAAe;AACrB,QAAI;AAEJ,QAAI;AACF,mBAAa,KAAK,UAAU,IAAI;AAAA,IAClC,SAAS,OAAO;AACd,YAAM,UAAU,iBAAiB,QAAQ,QAAQ,OAAO,KAAK;AAC7D,YAAM,IAAI,MAAM,GAAG,YAAY,KAAK,OAAO,EAAE;AAAA,IAC/C;AAEA,QAAI,eAAe,QAAW;AAC5B,YAAM,IAAI,MAAM,GAAG,YAAY,wBAAwB;AAAA,IACzD;AAEA,UAAM,KAAK,MAAM,UAAU;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,QAAuB;AAC3B,UAAM,KAAK,MAAM,EAAE;AAAA,EACrB;AACF;;;AC3EO,IAAM,mBAGT,OAAO,EAAE,MAAM,YAAY,GAAG,QAAQ;AACxC,MAAI,gBAAgB,UAAU;AAC5B,UAAM,IAAI;AAAA,MACR,mCAAmC,WAAW;AAAA;AAAA,IAGhD;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,iBAAiB,IAAI;AACzC,QAAM,IAAI,OAAO;AACnB;;;AChBO,IAAM,iBAGT,OAAO,EAAE,SAAS,YAAY,GAAG,QAAQ;AAC3C,MAAI,gBAAgB,YAAY;AAC9B,UAAM,QAAQ,iBAAiB,CAAC,kBAAkB,iBAAiB,CAAC;AAAA,EACtE;AAEA,QAAM,IAAI,OAAO;AACnB;;;AHPO,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,WAAW;AACb;","names":[]}
1
+ {"version":3,"sources":["../../src/fixtures/index.ts","../../src/utils/clipboard/runInStep.ts","../../src/utils/clipboard/clipboardHandler.ts","../../src/fixtures/clipboardFixture.ts","../../src/fixtures/contextFixture.ts"],"sourcesContent":["import { ClipboardHandler } from '../utils';\nimport { 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 type { BrowserName } from './types';\nexport { ClipboardHandler, clipboardFixture, contextFixture };\n","import { test } from '@playwright/test';\n\nconst isTestRunning = () => {\n try {\n return !!test.info();\n } catch {\n return false;\n }\n};\n\nexport const runInStep = async <T>(stepName: string, fn: () => Promise<T>) => {\n if (isTestRunning()) {\n return await test.step(stepName, fn, { box: true });\n } else {\n return await fn();\n }\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';\nimport { runInStep } from './runInStep';\n\nexport class ClipboardHandler {\n constructor(private readonly page: Page) {}\n\n private async _write(data: string): Promise<void> {\n await this.page.evaluate((value) => navigator.clipboard.writeText(value), data);\n }\n\n private async _read(): Promise<string> {\n return await this.page.evaluate(() => navigator.clipboard.readText());\n }\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 runInStep('Clipboard \"read\"', async () => {\n return await this._read();\n });\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 return await runInStep('Clipboard \"readJSON\"', async () => {\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 /**\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 runInStep('Clipboard \"write\"', async () => {\n await this._write(data);\n });\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 runInStep('Clipboard \"writeJSON\"', async () => {\n await this._write(jsonString);\n });\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 runInStep('Clipboard \"clear\"', async () => {\n await this._write('');\n });\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAqB;AAErB,IAAM,gBAAgB,MAAM;AAC1B,MAAI;AACF,WAAO,CAAC,CAAC,iBAAK,KAAK;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,IAAM,YAAY,OAAU,UAAkB,OAAyB;AAC5E,MAAI,cAAc,GAAG;AACnB,WAAO,MAAM,iBAAK,KAAK,UAAU,IAAI,EAAE,KAAK,KAAK,CAAC;AAAA,EACpD,OAAO;AACL,WAAO,MAAM,GAAG;AAAA,EAClB;AACF;;;ACFO,IAAM,mBAAN,MAAuB;AAAA,EAC5B,YAA6B,MAAY;AAAZ;AAAA,EAAa;AAAA,EAAb;AAAA,EAE7B,MAAc,OAAO,MAA6B;AAChD,UAAM,KAAK,KAAK,SAAS,CAAC,UAAU,UAAU,UAAU,UAAU,KAAK,GAAG,IAAI;AAAA,EAChF;AAAA,EAEA,MAAc,QAAyB;AACrC,WAAO,MAAM,KAAK,KAAK,SAAS,MAAM,UAAU,UAAU,SAAS,CAAC;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,OAAwB;AAC5B,WAAO,MAAM,UAAU,oBAAoB,YAAY;AACrD,aAAO,MAAM,KAAK,MAAM;AAAA,IAC1B,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,WAAoC;AACxC,WAAO,MAAM,UAAU,wBAAwB,YAAY;AACzD,YAAM,OAAO,MAAM,KAAK,MAAM;AAC9B,UAAI;AACF,eAAO,KAAK,MAAM,IAAI;AAAA,MACxB,QAAQ;AACN,cAAM,IAAI;AAAA,UACR,iEAAiE,KA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;;;AJPO,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,WAAW;AACb;","names":[]}
@@ -1,40 +1,20 @@
1
- import * as playwright_test from 'playwright/test';
2
- import * as playwright_core from 'playwright-core';
3
- import { C as ClipboardHandler } from '../clipboardHandler-CFIUvkc0.cjs';
4
- import { TestFixture, Page, BrowserContext } from '@playwright/test';
5
-
6
- type BrowserName = 'chromium' | 'firefox' | 'webkit';
7
-
8
- /**
9
- * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
10
- * It allows reading from the clipboard during tests.
11
- */
12
- declare const clipboardFixture: TestFixture<ClipboardHandler, {
13
- page: Page;
14
- browserName: BrowserName;
15
- }>;
16
-
17
- /**
18
- * A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
19
- */
20
- declare const contextFixture: TestFixture<BrowserContext, {
21
- context: BrowserContext;
22
- browserName: BrowserName;
23
- }>;
24
-
1
+ import { ClipboardHandler } from '../utils';
2
+ import { clipboardFixture } from './clipboardFixture';
3
+ import { contextFixture } from './contextFixture';
25
4
  /**
26
5
  * A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
27
6
  * These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
28
7
  */
29
- declare const clipboardFixtures: {
30
- context: playwright_test.TestFixture<playwright_core.BrowserContext, {
31
- context: playwright_core.BrowserContext;
32
- browserName: BrowserName;
8
+ export declare const clipboardFixtures: {
9
+ context: import("playwright/test").TestFixture<import("playwright-core").BrowserContext, {
10
+ context: import("playwright-core").BrowserContext;
11
+ browserName: import("./types").BrowserName;
33
12
  }>;
34
- clipboard: playwright_test.TestFixture<ClipboardHandler, {
35
- page: playwright_core.Page;
36
- browserName: BrowserName;
13
+ clipboard: import("playwright/test").TestFixture<ClipboardHandler, {
14
+ page: import("playwright-core").Page;
15
+ browserName: import("./types").BrowserName;
37
16
  }>;
38
17
  };
39
-
40
- export { ClipboardHandler, clipboardFixture, clipboardFixtures, contextFixture };
18
+ export type { BrowserName } from './types';
19
+ export { ClipboardHandler, clipboardFixture, contextFixture };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -1,40 +1,20 @@
1
- import * as playwright_test from 'playwright/test';
2
- import * as playwright_core from 'playwright-core';
3
- import { C as ClipboardHandler } from '../clipboardHandler-CFIUvkc0.js';
4
- import { TestFixture, Page, BrowserContext } from '@playwright/test';
5
-
6
- type BrowserName = 'chromium' | 'firefox' | 'webkit';
7
-
8
- /**
9
- * A fixture that provides an instance of the Clipboard utility for interacting with the system clipboard.
10
- * It allows reading from the clipboard during tests.
11
- */
12
- declare const clipboardFixture: TestFixture<ClipboardHandler, {
13
- page: Page;
14
- browserName: BrowserName;
15
- }>;
16
-
17
- /**
18
- * A fixture that provides a BrowserContext with clipboard permissions granted for Chromium browsers.
19
- */
20
- declare const contextFixture: TestFixture<BrowserContext, {
21
- context: BrowserContext;
22
- browserName: BrowserName;
23
- }>;
24
-
1
+ import { ClipboardHandler } from '../utils';
2
+ import { clipboardFixture } from './clipboardFixture';
3
+ import { contextFixture } from './contextFixture';
25
4
  /**
26
5
  * A collection of fixtures related to clipboard testing, including the clipboard fixture and context fixture.
27
6
  * These fixtures can be used in Playwright tests to facilitate clipboard interactions and context management.
28
7
  */
29
- declare const clipboardFixtures: {
30
- context: playwright_test.TestFixture<playwright_core.BrowserContext, {
31
- context: playwright_core.BrowserContext;
32
- browserName: BrowserName;
8
+ export declare const clipboardFixtures: {
9
+ context: import("playwright/test").TestFixture<import("playwright-core").BrowserContext, {
10
+ context: import("playwright-core").BrowserContext;
11
+ browserName: import("./types").BrowserName;
33
12
  }>;
34
- clipboard: playwright_test.TestFixture<ClipboardHandler, {
35
- page: playwright_core.Page;
36
- browserName: BrowserName;
13
+ clipboard: import("playwright/test").TestFixture<ClipboardHandler, {
14
+ page: import("playwright-core").Page;
15
+ browserName: import("./types").BrowserName;
37
16
  }>;
38
17
  };
39
-
40
- export { ClipboardHandler, clipboardFixture, clipboardFixtures, contextFixture };
18
+ export type { BrowserName } from './types';
19
+ export { ClipboardHandler, clipboardFixture, contextFixture };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixtures/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;CAG7B,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,CAAC"}