@wordpress/e2e-test-utils-playwright 1.46.0 → 1.47.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/build/admin/index.js +3 -0
- package/build/admin/index.js.map +1 -1
- package/build/admin/visit-site-editor.js +1 -29
- package/build/admin/visit-site-editor.js.map +1 -1
- package/build/admin/wait-for-site-editor.js +41 -0
- package/build/admin/wait-for-site-editor.js.map +1 -0
- package/build/metrics/index.js +59 -3
- package/build/metrics/index.js.map +1 -1
- package/build/request-utils/index.js +2 -0
- package/build/request-utils/index.js.map +1 -1
- package/build/request-utils/preferences.js +34 -0
- package/build/request-utils/preferences.js.map +1 -1
- package/build-types/admin/index.d.ts +3 -0
- package/build-types/admin/index.d.ts.map +1 -1
- package/build-types/admin/visit-site-editor.d.ts.map +1 -1
- package/build-types/admin/wait-for-site-editor.d.ts +12 -0
- package/build-types/admin/wait-for-site-editor.d.ts.map +1 -0
- package/build-types/metrics/index.d.ts +22 -5
- package/build-types/metrics/index.d.ts.map +1 -1
- package/build-types/request-utils/index.d.ts +3 -1
- package/build-types/request-utils/index.d.ts.map +1 -1
- package/build-types/request-utils/preferences.d.ts +11 -0
- package/build-types/request-utils/preferences.d.ts.map +1 -1
- package/package.json +3 -4
- package/build/admin/create-new-post.cjs +0 -51
- package/build/admin/create-new-post.cjs.map +0 -7
- package/build/admin/edit-post.cjs +0 -40
- package/build/admin/edit-post.cjs.map +0 -7
- package/build/admin/get-page-error.cjs +0 -36
- package/build/admin/get-page-error.cjs.map +0 -7
- package/build/admin/index.cjs +0 -59
- package/build/admin/index.cjs.map +0 -7
- package/build/admin/visit-admin-page.cjs +0 -47
- package/build/admin/visit-admin-page.cjs.map +0 -7
- package/build/admin/visit-site-editor.cjs +0 -90
- package/build/admin/visit-site-editor.cjs.map +0 -7
- package/build/config.cjs +0 -45
- package/build/config.cjs.map +0 -7
- package/build/editor/click-block-options-menu-item.cjs +0 -34
- package/build/editor/click-block-options-menu-item.cjs.map +0 -7
- package/build/editor/click-block-toolbar-button.cjs +0 -38
- package/build/editor/click-block-toolbar-button.cjs.map +0 -7
- package/build/editor/get-blocks.cjs +0 -64
- package/build/editor/get-blocks.cjs.map +0 -7
- package/build/editor/get-edited-post-content.cjs +0 -36
- package/build/editor/get-edited-post-content.cjs.map +0 -7
- package/build/editor/index.cjs +0 -97
- package/build/editor/index.cjs.map +0 -7
- package/build/editor/insert-block.cjs +0 -55
- package/build/editor/insert-block.cjs.map +0 -7
- package/build/editor/open-document-settings-sidebar.cjs +0 -42
- package/build/editor/open-document-settings-sidebar.cjs.map +0 -7
- package/build/editor/preview.cjs +0 -42
- package/build/editor/preview.cjs.map +0 -7
- package/build/editor/publish-post.cjs +0 -47
- package/build/editor/publish-post.cjs.map +0 -7
- package/build/editor/save-draft.cjs +0 -34
- package/build/editor/save-draft.cjs.map +0 -7
- package/build/editor/select-blocks.cjs +0 -51
- package/build/editor/select-blocks.cjs.map +0 -7
- package/build/editor/set-content.cjs +0 -39
- package/build/editor/set-content.cjs.map +0 -7
- package/build/editor/set-is-fixed-toolbar.cjs +0 -36
- package/build/editor/set-is-fixed-toolbar.cjs.map +0 -7
- package/build/editor/set-preferences.cjs +0 -43
- package/build/editor/set-preferences.cjs.map +0 -7
- package/build/editor/show-block-toolbar.cjs +0 -35
- package/build/editor/show-block-toolbar.cjs.map +0 -7
- package/build/editor/site-editor.cjs +0 -51
- package/build/editor/site-editor.cjs.map +0 -7
- package/build/editor/switch-editor-tool.cjs +0 -47
- package/build/editor/switch-editor-tool.cjs.map +0 -7
- package/build/editor/switch-to-legacy-canvas.cjs +0 -39
- package/build/editor/switch-to-legacy-canvas.cjs.map +0 -7
- package/build/editor/transform-block-to.cjs +0 -46
- package/build/editor/transform-block-to.cjs.map +0 -7
- package/build/index.cjs +0 -51
- package/build/index.cjs.map +0 -7
- package/build/lighthouse/index.cjs +0 -96
- package/build/lighthouse/index.cjs.map +0 -7
- package/build/metrics/index.cjs +0 -309
- package/build/metrics/index.cjs.map +0 -7
- package/build/page-utils/drag-files.cjs +0 -143
- package/build/page-utils/drag-files.cjs.map +0 -7
- package/build/page-utils/emulate-network-conditions.cjs +0 -99
- package/build/page-utils/emulate-network-conditions.cjs.map +0 -7
- package/build/page-utils/index.cjs +0 -59
- package/build/page-utils/index.cjs.map +0 -7
- package/build/page-utils/is-current-url.cjs +0 -36
- package/build/page-utils/is-current-url.cjs.map +0 -7
- package/build/page-utils/keycodes.cjs +0 -55
- package/build/page-utils/keycodes.cjs.map +0 -7
- package/build/page-utils/press-keys.cjs +0 -165
- package/build/page-utils/press-keys.cjs.map +0 -7
- package/build/page-utils/set-browser-viewport.cjs +0 -39
- package/build/page-utils/set-browser-viewport.cjs.map +0 -7
- package/build/request-utils/blocks.cjs +0 -51
- package/build/request-utils/blocks.cjs.map +0 -7
- package/build/request-utils/comments.cjs +0 -66
- package/build/request-utils/comments.cjs.map +0 -7
- package/build/request-utils/gutenberg-experiments.cjs +0 -56
- package/build/request-utils/gutenberg-experiments.cjs.map +0 -7
- package/build/request-utils/index.cjs +0 -199
- package/build/request-utils/index.cjs.map +0 -7
- package/build/request-utils/login.cjs +0 -48
- package/build/request-utils/login.cjs.map +0 -7
- package/build/request-utils/media.cjs +0 -83
- package/build/request-utils/media.cjs.map +0 -7
- package/build/request-utils/menus.cjs +0 -128
- package/build/request-utils/menus.cjs.map +0 -7
- package/build/request-utils/pages.cjs +0 -66
- package/build/request-utils/pages.cjs.map +0 -7
- package/build/request-utils/patterns.cjs +0 -44
- package/build/request-utils/patterns.cjs.map +0 -7
- package/build/request-utils/plugins.cjs +0 -81
- package/build/request-utils/plugins.cjs.map +0 -7
- package/build/request-utils/posts.cjs +0 -56
- package/build/request-utils/posts.cjs.map +0 -7
- package/build/request-utils/preferences.cjs +0 -41
- package/build/request-utils/preferences.cjs.map +0 -7
- package/build/request-utils/records.cjs +0 -37
- package/build/request-utils/records.cjs.map +0 -7
- package/build/request-utils/rest.cjs +0 -174
- package/build/request-utils/rest.cjs.map +0 -7
- package/build/request-utils/site-settings.cjs +0 -45
- package/build/request-utils/site-settings.cjs.map +0 -7
- package/build/request-utils/templates.cjs +0 -68
- package/build/request-utils/templates.cjs.map +0 -7
- package/build/request-utils/themes.cjs +0 -92
- package/build/request-utils/themes.cjs.map +0 -7
- package/build/request-utils/users.cjs +0 -83
- package/build/request-utils/users.cjs.map +0 -7
- package/build/request-utils/widgets.cjs +0 -79
- package/build/request-utils/widgets.cjs.map +0 -7
- package/build/test.cjs +0 -136
- package/build/test.cjs.map +0 -7
- package/build/types.cjs +0 -19
- package/build/types.cjs.map +0 -7
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/page-utils/index.ts
|
|
21
|
-
var page_utils_exports = {};
|
|
22
|
-
__export(page_utils_exports, {
|
|
23
|
-
PageUtils: () => PageUtils
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(page_utils_exports);
|
|
26
|
-
var import_drag_files = require("./drag-files.cjs");
|
|
27
|
-
var import_is_current_url = require("./is-current-url.cjs");
|
|
28
|
-
var import_press_keys = require("./press-keys.cjs");
|
|
29
|
-
var import_set_browser_viewport = require("./set-browser-viewport.cjs");
|
|
30
|
-
var import_emulate_network_conditions = require("./emulate-network-conditions.cjs");
|
|
31
|
-
var PageUtils = class {
|
|
32
|
-
browser;
|
|
33
|
-
page;
|
|
34
|
-
context;
|
|
35
|
-
browserName;
|
|
36
|
-
constructor({ page, browserName }) {
|
|
37
|
-
this.page = page;
|
|
38
|
-
this.context = page.context();
|
|
39
|
-
this.browser = this.context.browser();
|
|
40
|
-
this.browserName = browserName;
|
|
41
|
-
}
|
|
42
|
-
/** @borrows dragFiles as this.dragFiles */
|
|
43
|
-
dragFiles = import_drag_files.dragFiles.bind(this);
|
|
44
|
-
/** @borrows isCurrentURL as this.isCurrentURL */
|
|
45
|
-
isCurrentURL = import_is_current_url.isCurrentURL.bind(this);
|
|
46
|
-
/** @borrows pressKeys as this.pressKeys */
|
|
47
|
-
pressKeys = import_press_keys.pressKeys.bind(this);
|
|
48
|
-
/** @borrows setBrowserViewport as this.setBrowserViewport */
|
|
49
|
-
setBrowserViewport = import_set_browser_viewport.setBrowserViewport.bind(this);
|
|
50
|
-
/** @borrows setClipboardData as this.setClipboardData */
|
|
51
|
-
setClipboardData = import_press_keys.setClipboardData.bind(this);
|
|
52
|
-
/** @borrows emulateNetworkConditions as this.emulateNetworkConditions */
|
|
53
|
-
emulateNetworkConditions = import_emulate_network_conditions.emulateNetworkConditions.bind(this);
|
|
54
|
-
};
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
PageUtils
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/page-utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type {\n\tBrowser,\n\tPage,\n\tBrowserContext,\n\tPlaywrightWorkerOptions,\n} from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport { dragFiles } from './drag-files';\nimport { isCurrentURL } from './is-current-url';\nimport { setClipboardData, pressKeys } from './press-keys';\nimport { setBrowserViewport } from './set-browser-viewport';\nimport { emulateNetworkConditions } from './emulate-network-conditions';\n\ntype PageUtilConstructorParams = {\n\tpage: Page;\n\tbrowserName: PlaywrightWorkerOptions[ 'browserName' ];\n};\n\nclass PageUtils {\n\tbrowser: Browser;\n\tpage: Page;\n\tcontext: BrowserContext;\n\tbrowserName: PlaywrightWorkerOptions[ 'browserName' ];\n\n\tconstructor( { page, browserName }: PageUtilConstructorParams ) {\n\t\tthis.page = page;\n\t\tthis.context = page.context();\n\t\tthis.browser = this.context.browser()!;\n\t\tthis.browserName = browserName;\n\t}\n\n\t/** @borrows dragFiles as this.dragFiles */\n\tdragFiles: typeof dragFiles = dragFiles.bind( this );\n\t/** @borrows isCurrentURL as this.isCurrentURL */\n\tisCurrentURL: typeof isCurrentURL = isCurrentURL.bind( this );\n\t/** @borrows pressKeys as this.pressKeys */\n\tpressKeys: typeof pressKeys = pressKeys.bind( this );\n\t/** @borrows setBrowserViewport as this.setBrowserViewport */\n\tsetBrowserViewport: typeof setBrowserViewport =\n\t\tsetBrowserViewport.bind( this );\n\t/** @borrows setClipboardData as this.setClipboardData */\n\tsetClipboardData: typeof setClipboardData = setClipboardData.bind( this );\n\t/** @borrows emulateNetworkConditions as this.emulateNetworkConditions */\n\temulateNetworkConditions: typeof emulateNetworkConditions =\n\t\temulateNetworkConditions.bind( this );\n}\n\nexport { PageUtils };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,wBAA0B;AAC1B,4BAA6B;AAC7B,wBAA4C;AAC5C,kCAAmC;AACnC,wCAAyC;AAOzC,IAAM,YAAN,MAAgB;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YAAa,EAAE,MAAM,YAAY,GAA+B;AAC/D,SAAK,OAAO;AACZ,SAAK,UAAU,KAAK,QAAQ;AAC5B,SAAK,UAAU,KAAK,QAAQ,QAAQ;AACpC,SAAK,cAAc;AAAA,EACpB;AAAA;AAAA,EAGA,YAA8B,4BAAU,KAAM,IAAK;AAAA;AAAA,EAEnD,eAAoC,mCAAa,KAAM,IAAK;AAAA;AAAA,EAE5D,YAA8B,4BAAU,KAAM,IAAK;AAAA;AAAA,EAEnD,qBACC,+CAAmB,KAAM,IAAK;AAAA;AAAA,EAE/B,mBAA4C,mCAAiB,KAAM,IAAK;AAAA;AAAA,EAExE,2BACC,2DAAyB,KAAM,IAAK;AACtC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/page-utils/is-current-url.ts
|
|
21
|
-
var is_current_url_exports = {};
|
|
22
|
-
__export(is_current_url_exports, {
|
|
23
|
-
isCurrentURL: () => isCurrentURL
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(is_current_url_exports);
|
|
26
|
-
var import_config = require("../config.cjs");
|
|
27
|
-
function isCurrentURL(path) {
|
|
28
|
-
const currentURL = new URL(this.page.url());
|
|
29
|
-
const expectedURL = new URL(path, import_config.WP_BASE_URL);
|
|
30
|
-
return expectedURL.pathname === currentURL.pathname;
|
|
31
|
-
}
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
isCurrentURL
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=is-current-url.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/page-utils/is-current-url.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { WP_BASE_URL } from '../config';\nimport type { PageUtils } from './';\n\n/**\n * Checks if current path of the URL matches the provided path.\n *\n * @param this\n * @param path String to be serialized as pathname.\n *\n * @return Boolean represents whether current URL is or not a WordPress path.\n */\nexport function isCurrentURL( this: PageUtils, path: string ) {\n\tconst currentURL = new URL( this.page.url() );\n\tconst expectedURL = new URL( path, WP_BASE_URL );\n\n\treturn expectedURL.pathname === currentURL.pathname;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA4B;AAWrB,SAAS,aAA+B,MAAe;AAC7D,QAAM,aAAa,IAAI,IAAK,KAAK,KAAK,IAAI,CAAE;AAC5C,QAAM,cAAc,IAAI,IAAK,MAAM,yBAAY;AAE/C,SAAO,YAAY,aAAa,WAAW;AAC5C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/page-utils/keycodes.ts
|
|
21
|
-
var keycodes_exports = {};
|
|
22
|
-
__export(keycodes_exports, {
|
|
23
|
-
ALT: () => ALT,
|
|
24
|
-
COMMAND: () => COMMAND,
|
|
25
|
-
CTRL: () => CTRL,
|
|
26
|
-
SHIFT: () => SHIFT,
|
|
27
|
-
modifiers: () => modifiers
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(keycodes_exports);
|
|
30
|
-
var ALT = "alt";
|
|
31
|
-
var CTRL = "ctrl";
|
|
32
|
-
var COMMAND = "meta";
|
|
33
|
-
var SHIFT = "shift";
|
|
34
|
-
var modifiers = {
|
|
35
|
-
primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL],
|
|
36
|
-
primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
|
37
|
-
primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
|
38
|
-
secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
|
39
|
-
access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
|
40
|
-
ctrl: () => [CTRL],
|
|
41
|
-
alt: () => [ALT],
|
|
42
|
-
ctrlShift: () => [CTRL, SHIFT],
|
|
43
|
-
shift: () => [SHIFT],
|
|
44
|
-
shiftAlt: () => [SHIFT, ALT],
|
|
45
|
-
undefined: () => []
|
|
46
|
-
};
|
|
47
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
-
0 && (module.exports = {
|
|
49
|
-
ALT,
|
|
50
|
-
COMMAND,
|
|
51
|
-
CTRL,
|
|
52
|
-
SHIFT,
|
|
53
|
-
modifiers
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=keycodes.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/page-utils/keycodes.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * This filed is partially copied from @wordpress/keycodes to keep the package\n * (internal-)dependencies free.\n */\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n */\nexport const modifiers: Record<\n\tstring,\n\t( _isApple: () => boolean ) => string[]\n> = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,IAAM,MAAM;AAKZ,IAAM,OAAO;AAKb,IAAM,UAAU;AAKhB,IAAM,QAAQ;AAMd,IAAM,YAGT;AAAA,EACH,SAAS,CAAE,aAAgB,SAAS,IAAI,CAAE,OAAQ,IAAI,CAAE,IAAK;AAAA,EAC7D,cAAc,CAAE,aACf,SAAS,IAAI,CAAE,OAAO,OAAQ,IAAI,CAAE,MAAM,KAAM;AAAA,EACjD,YAAY,CAAE,aACb,SAAS,IAAI,CAAE,KAAK,OAAQ,IAAI,CAAE,MAAM,GAAI;AAAA,EAC7C,WAAW,CAAE,aACZ,SAAS,IAAI,CAAE,OAAO,KAAK,OAAQ,IAAI,CAAE,MAAM,OAAO,GAAI;AAAA,EAC3D,QAAQ,CAAE,aAAgB,SAAS,IAAI,CAAE,MAAM,GAAI,IAAI,CAAE,OAAO,GAAI;AAAA,EACpE,MAAM,MAAM,CAAE,IAAK;AAAA,EACnB,KAAK,MAAM,CAAE,GAAI;AAAA,EACjB,WAAW,MAAM,CAAE,MAAM,KAAM;AAAA,EAC/B,OAAO,MAAM,CAAE,KAAM;AAAA,EACrB,UAAU,MAAM,CAAE,OAAO,GAAI;AAAA,EAC7B,WAAW,MAAM,CAAC;AACnB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/page-utils/press-keys.ts
|
|
21
|
-
var press_keys_exports = {};
|
|
22
|
-
__export(press_keys_exports, {
|
|
23
|
-
pressKeys: () => pressKeys,
|
|
24
|
-
setClipboardData: () => setClipboardData
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(press_keys_exports);
|
|
27
|
-
var import_change_case = require("change-case");
|
|
28
|
-
var import_keycodes = require("./keycodes.cjs");
|
|
29
|
-
var clipboardDataHolder = {
|
|
30
|
-
"text/plain": "",
|
|
31
|
-
"text/html": "",
|
|
32
|
-
"rich-text": ""
|
|
33
|
-
};
|
|
34
|
-
function setClipboardData({ plainText = "", html = "" }) {
|
|
35
|
-
clipboardDataHolder = {
|
|
36
|
-
"text/plain": plainText,
|
|
37
|
-
"text/html": html,
|
|
38
|
-
"rich-text": ""
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async function emulateClipboard(page, type) {
|
|
42
|
-
const output = await page.evaluate(
|
|
43
|
-
([_type, _clipboardData]) => {
|
|
44
|
-
const canvasDoc = (
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
document.activeElement?.contentDocument ?? document
|
|
47
|
-
);
|
|
48
|
-
const event = new ClipboardEvent(_type, {
|
|
49
|
-
bubbles: true,
|
|
50
|
-
cancelable: true,
|
|
51
|
-
clipboardData: new DataTransfer()
|
|
52
|
-
});
|
|
53
|
-
if (!event.clipboardData) {
|
|
54
|
-
throw new Error("ClipboardEvent.clipboardData is null");
|
|
55
|
-
}
|
|
56
|
-
if (_type === "paste") {
|
|
57
|
-
event.clipboardData.setData(
|
|
58
|
-
"text/plain",
|
|
59
|
-
_clipboardData["text/plain"]
|
|
60
|
-
);
|
|
61
|
-
event.clipboardData.setData(
|
|
62
|
-
"text/html",
|
|
63
|
-
_clipboardData["text/html"]
|
|
64
|
-
);
|
|
65
|
-
event.clipboardData.setData(
|
|
66
|
-
"rich-text",
|
|
67
|
-
_clipboardData["rich-text"]
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
const selection = canvasDoc.defaultView.getSelection();
|
|
71
|
-
const plainText = selection.toString();
|
|
72
|
-
let html = plainText;
|
|
73
|
-
if (selection.rangeCount) {
|
|
74
|
-
const range = selection.getRangeAt(0);
|
|
75
|
-
const fragment = range.cloneContents();
|
|
76
|
-
html = Array.from(fragment.childNodes).map(
|
|
77
|
-
(node) => node.outerHTML ?? node.nodeValue
|
|
78
|
-
).join("");
|
|
79
|
-
}
|
|
80
|
-
event.clipboardData.setData("text/plain", plainText);
|
|
81
|
-
event.clipboardData.setData("text/html", html);
|
|
82
|
-
}
|
|
83
|
-
canvasDoc.activeElement.dispatchEvent(event);
|
|
84
|
-
if (_type === "paste") {
|
|
85
|
-
return event.defaultPrevented;
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
"text/plain": event.clipboardData.getData("text/plain"),
|
|
89
|
-
"text/html": event.clipboardData.getData("text/html"),
|
|
90
|
-
"rich-text": event.clipboardData.getData("rich-text")
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
[type, clipboardDataHolder]
|
|
94
|
-
);
|
|
95
|
-
if (typeof output === "object") {
|
|
96
|
-
clipboardDataHolder = output;
|
|
97
|
-
}
|
|
98
|
-
if (output === false) {
|
|
99
|
-
await page.keyboard.type(clipboardDataHolder["text/plain"]);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
var isAppleOS = () => process.platform === "darwin";
|
|
103
|
-
var isWebkit = (page) => page.context().browser().browserType().name() === "webkit";
|
|
104
|
-
var browserCache = /* @__PURE__ */ new WeakMap();
|
|
105
|
-
var getHasNaturalTabNavigation = async (page) => {
|
|
106
|
-
if (!isAppleOS() || !isWebkit(page)) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
if (browserCache.has(page.context().browser())) {
|
|
110
|
-
return browserCache.get(page.context().browser());
|
|
111
|
-
}
|
|
112
|
-
const testPage = await page.context().newPage();
|
|
113
|
-
await testPage.setContent(`<button>1</button><button>2</button>`);
|
|
114
|
-
await testPage.getByText("1").focus();
|
|
115
|
-
await testPage.keyboard.press("Tab");
|
|
116
|
-
const featureDetected = await testPage.getByText("2").evaluate((node) => node === document.activeElement);
|
|
117
|
-
browserCache.set(page.context().browser(), featureDetected);
|
|
118
|
-
await testPage.close();
|
|
119
|
-
return featureDetected;
|
|
120
|
-
};
|
|
121
|
-
var modifiers = {
|
|
122
|
-
...import_keycodes.modifiers,
|
|
123
|
-
shiftAlt: (_isApple) => _isApple() ? [import_keycodes.SHIFT, import_keycodes.ALT] : [import_keycodes.SHIFT, import_keycodes.CTRL]
|
|
124
|
-
};
|
|
125
|
-
async function pressKeys(key, { times, ...pressOptions } = {}) {
|
|
126
|
-
const hasNaturalTabNavigation = await getHasNaturalTabNavigation(
|
|
127
|
-
this.page
|
|
128
|
-
);
|
|
129
|
-
let command;
|
|
130
|
-
if (key.toLowerCase() === "primary+c") {
|
|
131
|
-
command = () => emulateClipboard(this.page, "copy");
|
|
132
|
-
} else if (key.toLowerCase() === "primary+x") {
|
|
133
|
-
command = () => emulateClipboard(this.page, "cut");
|
|
134
|
-
} else if (key.toLowerCase() === "primary+v") {
|
|
135
|
-
command = () => emulateClipboard(this.page, "paste");
|
|
136
|
-
} else {
|
|
137
|
-
const keys = key.split("+").flatMap((keyCode) => {
|
|
138
|
-
if (Object.prototype.hasOwnProperty.call(modifiers, keyCode)) {
|
|
139
|
-
return modifiers[keyCode](
|
|
140
|
-
isAppleOS
|
|
141
|
-
).map(
|
|
142
|
-
(modifier) => modifier === import_keycodes.CTRL ? "Control" : (0, import_change_case.capitalCase)(modifier)
|
|
143
|
-
);
|
|
144
|
-
} else if (keyCode === "Tab" && !hasNaturalTabNavigation) {
|
|
145
|
-
return ["Alt", "Tab"];
|
|
146
|
-
}
|
|
147
|
-
return keyCode;
|
|
148
|
-
});
|
|
149
|
-
const normalizedKeys = keys.join("+");
|
|
150
|
-
command = () => this.page.keyboard.press(normalizedKeys);
|
|
151
|
-
}
|
|
152
|
-
times = times ?? 1;
|
|
153
|
-
for (let i = 0; i < times; i += 1) {
|
|
154
|
-
await command();
|
|
155
|
-
if (times > 1 && pressOptions.delay) {
|
|
156
|
-
await this.page.waitForTimeout(pressOptions.delay);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
-
0 && (module.exports = {
|
|
162
|
-
pressKeys,
|
|
163
|
-
setClipboardData
|
|
164
|
-
});
|
|
165
|
-
//# sourceMappingURL=press-keys.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/page-utils/press-keys.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport { capitalCase } from 'change-case';\nimport type { Page } from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport type { PageUtils } from './';\nimport { modifiers as baseModifiers, SHIFT, ALT, CTRL } from './keycodes';\n\nlet clipboardDataHolder: {\n\t'text/plain': string;\n\t'text/html': string;\n\t'rich-text': string;\n} = {\n\t'text/plain': '',\n\t'text/html': '',\n\t'rich-text': '',\n};\n\n/**\n * Sets the clipboard data that can be pasted with\n * `pressKeys( 'primary+v' )`.\n *\n * @param clipboardData\n * @param clipboardData.plainText\n * @param clipboardData.html\n */\nexport function setClipboardData(\n\tthis: PageUtils,\n\t{ plainText = '', html = '' }\n) {\n\tclipboardDataHolder = {\n\t\t'text/plain': plainText,\n\t\t'text/html': html,\n\t\t'rich-text': '',\n\t};\n}\n\nasync function emulateClipboard( page: Page, type: 'copy' | 'cut' | 'paste' ) {\n\tconst output = await page.evaluate(\n\t\t( [ _type, _clipboardData ] ) => {\n\t\t\tconst canvasDoc =\n\t\t\t\t// @ts-ignore\n\t\t\t\tdocument.activeElement?.contentDocument ?? document;\n\t\t\tconst event = new ClipboardEvent( _type, {\n\t\t\t\tbubbles: true,\n\t\t\t\tcancelable: true,\n\t\t\t\tclipboardData: new DataTransfer(),\n\t\t\t} );\n\n\t\t\tif ( ! event.clipboardData ) {\n\t\t\t\tthrow new Error( 'ClipboardEvent.clipboardData is null' );\n\t\t\t}\n\n\t\t\tif ( _type === 'paste' ) {\n\t\t\t\tevent.clipboardData.setData(\n\t\t\t\t\t'text/plain',\n\t\t\t\t\t_clipboardData[ 'text/plain' ]\n\t\t\t\t);\n\t\t\t\tevent.clipboardData.setData(\n\t\t\t\t\t'text/html',\n\t\t\t\t\t_clipboardData[ 'text/html' ]\n\t\t\t\t);\n\t\t\t\tevent.clipboardData.setData(\n\t\t\t\t\t'rich-text',\n\t\t\t\t\t_clipboardData[ 'rich-text' ]\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst selection = canvasDoc.defaultView.getSelection()!;\n\t\t\t\tconst plainText = selection.toString();\n\t\t\t\tlet html = plainText;\n\t\t\t\tif ( selection.rangeCount ) {\n\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\tconst fragment = range.cloneContents();\n\t\t\t\t\thtml = Array.from( fragment.childNodes )\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t( node ) =>\n\t\t\t\t\t\t\t\t( node as Element ).outerHTML ??\n\t\t\t\t\t\t\t\t( node as Element ).nodeValue\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join( '' );\n\t\t\t\t}\n\t\t\t\tevent.clipboardData.setData( 'text/plain', plainText );\n\t\t\t\tevent.clipboardData.setData( 'text/html', html );\n\t\t\t}\n\n\t\t\tcanvasDoc.activeElement.dispatchEvent( event );\n\n\t\t\tif ( _type === 'paste' ) {\n\t\t\t\treturn event.defaultPrevented;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t'text/plain': event.clipboardData.getData( 'text/plain' ),\n\t\t\t\t'text/html': event.clipboardData.getData( 'text/html' ),\n\t\t\t\t'rich-text': event.clipboardData.getData( 'rich-text' ),\n\t\t\t};\n\t\t},\n\t\t[ type, clipboardDataHolder ] as const\n\t);\n\n\tif ( typeof output === 'object' ) {\n\t\tclipboardDataHolder = output;\n\t}\n\n\tif ( output === false ) {\n\t\t// Emulate paste by typing the clipboard content, which works across all\n\t\t// elements and documents (keyboard.type does uses the nested active\n\t\t// element automatically).\n\t\tawait page.keyboard.type( clipboardDataHolder[ 'text/plain' ] );\n\t}\n}\n\nconst isAppleOS = () => process.platform === 'darwin';\n\nconst isWebkit = ( page: Page ) =>\n\tpage.context().browser()!.browserType().name() === 'webkit';\n\nconst browserCache = new WeakMap();\nconst getHasNaturalTabNavigation = async ( page: Page ) => {\n\tif ( ! isAppleOS() || ! isWebkit( page ) ) {\n\t\treturn true;\n\t}\n\tif ( browserCache.has( page.context().browser()! ) ) {\n\t\treturn browserCache.get( page.context().browser()! );\n\t}\n\tconst testPage = await page.context().newPage();\n\tawait testPage.setContent( `<button>1</button><button>2</button>` );\n\tawait testPage.getByText( '1' ).focus();\n\tawait testPage.keyboard.press( 'Tab' );\n\tconst featureDetected = await testPage\n\t\t.getByText( '2' )\n\t\t.evaluate( ( node ) => node === document.activeElement );\n\tbrowserCache.set( page.context().browser()!, featureDetected );\n\tawait testPage.close();\n\treturn featureDetected;\n};\n\ntype Options = {\n\ttimes?: number;\n\tdelay?: number;\n};\n\nconst modifiers = {\n\t...baseModifiers,\n\tshiftAlt: ( _isApple: () => boolean ) =>\n\t\t_isApple() ? [ SHIFT, ALT ] : [ SHIFT, CTRL ],\n};\n\nexport async function pressKeys(\n\tthis: PageUtils,\n\tkey: string,\n\t{ times, ...pressOptions }: Options = {}\n) {\n\tconst hasNaturalTabNavigation = await getHasNaturalTabNavigation(\n\t\tthis.page\n\t);\n\n\tlet command: () => Promise< void >;\n\n\tif ( key.toLowerCase() === 'primary+c' ) {\n\t\tcommand = () => emulateClipboard( this.page, 'copy' );\n\t} else if ( key.toLowerCase() === 'primary+x' ) {\n\t\tcommand = () => emulateClipboard( this.page, 'cut' );\n\t} else if ( key.toLowerCase() === 'primary+v' ) {\n\t\tcommand = () => emulateClipboard( this.page, 'paste' );\n\t} else {\n\t\tconst keys = key.split( '+' ).flatMap( ( keyCode ) => {\n\t\t\tif ( Object.prototype.hasOwnProperty.call( modifiers, keyCode ) ) {\n\t\t\t\treturn modifiers[ keyCode as keyof typeof modifiers ](\n\t\t\t\t\tisAppleOS\n\t\t\t\t).map( ( modifier ) =>\n\t\t\t\t\tmodifier === CTRL ? 'Control' : capitalCase( modifier )\n\t\t\t\t);\n\t\t\t} else if ( keyCode === 'Tab' && ! hasNaturalTabNavigation ) {\n\t\t\t\treturn [ 'Alt', 'Tab' ];\n\t\t\t}\n\t\t\treturn keyCode;\n\t\t} );\n\t\tconst normalizedKeys = keys.join( '+' );\n\t\tcommand = () => this.page.keyboard.press( normalizedKeys );\n\t}\n\n\ttimes = times ?? 1;\n\tfor ( let i = 0; i < times; i += 1 ) {\n\t\tawait command();\n\n\t\tif ( times > 1 && pressOptions.delay ) {\n\t\t\tawait this.page.waitForTimeout( pressOptions.delay );\n\t\t}\n\t}\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["baseModifiers"]
|
|
7
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/page-utils/set-browser-viewport.js
|
|
21
|
-
var set_browser_viewport_exports = {};
|
|
22
|
-
__export(set_browser_viewport_exports, {
|
|
23
|
-
setBrowserViewport: () => setBrowserViewport
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(set_browser_viewport_exports);
|
|
26
|
-
var PREDEFINED_DIMENSIONS = {
|
|
27
|
-
large: { width: 960, height: 700 },
|
|
28
|
-
medium: { width: 768, height: 700 },
|
|
29
|
-
small: { width: 600, height: 700 }
|
|
30
|
-
};
|
|
31
|
-
async function setBrowserViewport(viewport) {
|
|
32
|
-
const dimensions = typeof viewport === "string" ? PREDEFINED_DIMENSIONS[viewport] : viewport;
|
|
33
|
-
await this.page.setViewportSize(dimensions);
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
setBrowserViewport
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=set-browser-viewport.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/page-utils/set-browser-viewport.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Named viewport options.\n *\n * @typedef {\"large\"|\"medium\"|\"small\"} WPDimensionsName\n */\n\n/**\n * Viewport dimensions object.\n *\n * @typedef {Object} WPViewportDimensions\n *\n * @property {number} width Width, in pixels.\n * @property {number} height Height, in pixels.\n */\n\n/**\n * Predefined viewport dimensions to reference by name.\n *\n * @enum {WPViewportDimensions}\n *\n * @type {Record<WPDimensionsName, WPViewportDimensions>}\n */\nconst PREDEFINED_DIMENSIONS = {\n\tlarge: { width: 960, height: 700 },\n\tmedium: { width: 768, height: 700 },\n\tsmall: { width: 600, height: 700 },\n};\n\n/**\n * Valid argument argument type from which to derive viewport dimensions.\n *\n * @typedef {WPDimensionsName|WPViewportDimensions} WPViewport\n */\n\n/**\n * Sets browser viewport to specified type.\n *\n * @this {import('./').PageUtils}\n * @param {WPViewport} viewport Viewport name or dimensions object to assign.\n */\nexport async function setBrowserViewport( viewport ) {\n\tconst dimensions =\n\t\ttypeof viewport === 'string'\n\t\t\t? PREDEFINED_DIMENSIONS[ viewport ]\n\t\t\t: viewport;\n\n\tawait this.page.setViewportSize( dimensions );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,IAAM,wBAAwB;AAAA,EAC7B,OAAO,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,EACjC,QAAQ,EAAE,OAAO,KAAK,QAAQ,IAAI;AAAA,EAClC,OAAO,EAAE,OAAO,KAAK,QAAQ,IAAI;AAClC;AAcA,eAAsB,mBAAoB,UAAW;AACpD,QAAM,aACL,OAAO,aAAa,WACjB,sBAAuB,QAAS,IAChC;AAEJ,QAAM,KAAK,KAAK,gBAAiB,UAAW;AAC7C;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/request-utils/blocks.ts
|
|
21
|
-
var blocks_exports = {};
|
|
22
|
-
__export(blocks_exports, {
|
|
23
|
-
createBlock: () => createBlock,
|
|
24
|
-
deleteAllBlocks: () => deleteAllBlocks
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(blocks_exports);
|
|
27
|
-
async function deleteAllBlocks() {
|
|
28
|
-
const blocks = await this.rest({
|
|
29
|
-
path: "/wp/v2/blocks",
|
|
30
|
-
params: {
|
|
31
|
-
per_page: 100,
|
|
32
|
-
// All possible statuses.
|
|
33
|
-
status: "publish,future,draft,pending,private,trash"
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
await this.batchRest(
|
|
37
|
-
blocks.map((block) => ({
|
|
38
|
-
method: "DELETE",
|
|
39
|
-
path: `/wp/v2/blocks/${block.id}?force=true`
|
|
40
|
-
}))
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
async function createBlock(payload) {
|
|
44
|
-
return this.createRecord("blocks", { ...payload });
|
|
45
|
-
}
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
createBlock,
|
|
49
|
-
deleteAllBlocks
|
|
50
|
-
});
|
|
51
|
-
//# sourceMappingURL=blocks.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/blocks.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\ntype CreateBlockPayload = {\n\tdate?: string;\n\tdate_gmt?: string;\n\tslug?: string;\n\ttitle: string;\n\tstatus: 'publish' | 'future' | 'draft' | 'pending' | 'private';\n\tcontent?: string;\n\tmeta?: unknown;\n\twp_pattern_category?: number[];\n};\n\n/**\n * Delete all blocks using REST API.\n *\n * @see https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks\n * @param this\n */\nexport async function deleteAllBlocks( this: RequestUtils ) {\n\t// List all blocks.\n\t// https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks\n\tconst blocks = await this.rest( {\n\t\tpath: '/wp/v2/blocks',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t\t// All possible statuses.\n\t\t\tstatus: 'publish,future,draft,pending,private,trash',\n\t\t},\n\t} );\n\n\t// Delete blocks.\n\t// https://developer.wordpress.org/rest-api/reference/blocks/#delete-a-editor-block\n\t// \"/wp/v2/posts\" not yet supports batch requests.\n\tawait this.batchRest(\n\t\tblocks.map( ( block: { id: number } ) => ( {\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: `/wp/v2/blocks/${ block.id }?force=true`,\n\t\t} ) )\n\t);\n}\n\n/**\n * Creates a new block using the REST API.\n *\n * @see https://developer.wordpress.org/rest-api/reference/blocks/#create-a-editor-block.\n * @param this\n * @param payload Block payload.\n */\nexport async function createBlock(\n\tthis: RequestUtils,\n\tpayload: CreateBlockPayload\n) {\n\treturn this.createRecord( 'blocks', { ...payload } );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,eAAsB,kBAAsC;AAG3D,QAAM,SAAS,MAAM,KAAK,KAAM;AAAA,IAC/B,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA;AAAA,MAEV,QAAQ;AAAA,IACT;AAAA,EACD,CAAE;AAKF,QAAM,KAAK;AAAA,IACV,OAAO,IAAK,CAAE,WAA6B;AAAA,MAC1C,QAAQ;AAAA,MACR,MAAM,iBAAkB,MAAM,EAAG;AAAA,IAClC,EAAI;AAAA,EACL;AACD;AASA,eAAsB,YAErB,SACC;AACD,SAAO,KAAK,aAAc,UAAU,EAAE,GAAG,QAAQ,CAAE;AACpD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/request-utils/comments.ts
|
|
21
|
-
var comments_exports = {};
|
|
22
|
-
__export(comments_exports, {
|
|
23
|
-
createComment: () => createComment,
|
|
24
|
-
deleteAllComments: () => deleteAllComments
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(comments_exports);
|
|
27
|
-
async function createComment(payload) {
|
|
28
|
-
const currentUser = await this.rest({
|
|
29
|
-
path: "/wp/v2/users/me",
|
|
30
|
-
method: "GET"
|
|
31
|
-
});
|
|
32
|
-
const author = currentUser.id;
|
|
33
|
-
const comment = await this.rest({
|
|
34
|
-
method: "POST",
|
|
35
|
-
path: "/wp/v2/comments",
|
|
36
|
-
data: { ...payload, author }
|
|
37
|
-
});
|
|
38
|
-
return comment;
|
|
39
|
-
}
|
|
40
|
-
async function deleteAllComments(type) {
|
|
41
|
-
const comments = await this.rest({
|
|
42
|
-
path: "/wp/v2/comments",
|
|
43
|
-
params: {
|
|
44
|
-
per_page: 100,
|
|
45
|
-
status: "all",
|
|
46
|
-
type: type || "comment"
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
await Promise.all(
|
|
50
|
-
comments.map(
|
|
51
|
-
(comment) => this.rest({
|
|
52
|
-
method: "DELETE",
|
|
53
|
-
path: `/wp/v2/comments/${comment.id}`,
|
|
54
|
-
params: {
|
|
55
|
-
force: true
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
createComment,
|
|
64
|
-
deleteAllComments
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=comments.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/comments.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface Comment {\n\tid: number;\n\tauthor: number;\n\tcontent: string;\n\tpost: number;\n}\n\nexport interface CreateCommentPayload {\n\tcontent: string;\n\tpost: number;\n}\n\nexport interface User {\n\tid: number;\n}\n\n/**\n * Create new comment using the REST API.\n *\n * @param this\n * @param payload\n */\nexport async function createComment(\n\tthis: RequestUtils,\n\tpayload: CreateCommentPayload\n) {\n\tconst currentUser = await this.rest< User >( {\n\t\tpath: '/wp/v2/users/me',\n\t\tmethod: 'GET',\n\t} );\n\n\tconst author = currentUser.id;\n\n\tconst comment = await this.rest< Comment >( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/comments',\n\t\tdata: { ...payload, author },\n\t} );\n\n\treturn comment;\n}\n\n/**\n * Delete all comments using the REST API.\n *\n * @param this\n * @param type - Optional comment type to delete.\n */\nexport async function deleteAllComments( this: RequestUtils, type?: string ) {\n\t// List all comments.\n\t// https://developer.wordpress.org/rest-api/reference/comments/#list-comments\n\tconst comments = await this.rest( {\n\t\tpath: '/wp/v2/comments',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t\tstatus: 'all',\n\t\t\ttype: type || 'comment',\n\t\t},\n\t} );\n\n\t// Delete all comments one by one.\n\t// https://developer.wordpress.org/rest-api/reference/comments/#delete-a-comment\n\t// \"/wp/v2/comments\" doesn't support batch requests yet.\n\tawait Promise.all(\n\t\tcomments.map( ( comment: Comment ) =>\n\t\t\tthis.rest( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\tpath: `/wp/v2/comments/${ comment.id }`,\n\t\t\t\tparams: {\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t} )\n\t\t)\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,eAAsB,cAErB,SACC;AACD,QAAM,cAAc,MAAM,KAAK,KAAc;AAAA,IAC5C,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AAEF,QAAM,SAAS,YAAY;AAE3B,QAAM,UAAU,MAAM,KAAK,KAAiB;AAAA,IAC3C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM,EAAE,GAAG,SAAS,OAAO;AAAA,EAC5B,CAAE;AAEF,SAAO;AACR;AAQA,eAAsB,kBAAuC,MAAgB;AAG5E,QAAM,WAAW,MAAM,KAAK,KAAM;AAAA,IACjC,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,MAAM,QAAQ;AAAA,IACf;AAAA,EACD,CAAE;AAKF,QAAM,QAAQ;AAAA,IACb,SAAS;AAAA,MAAK,CAAE,YACf,KAAK,KAAM;AAAA,QACV,QAAQ;AAAA,QACR,MAAM,mBAAoB,QAAQ,EAAG;AAAA,QACrC,QAAQ;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/e2e-test-utils-playwright/src/request-utils/gutenberg-experiments.ts
|
|
21
|
-
var gutenberg_experiments_exports = {};
|
|
22
|
-
__export(gutenberg_experiments_exports, {
|
|
23
|
-
setGutenbergExperiments: () => setGutenbergExperiments
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(gutenberg_experiments_exports);
|
|
26
|
-
async function setGutenbergExperiments(experiments) {
|
|
27
|
-
const regularExperiments = experiments.filter(
|
|
28
|
-
(exp) => exp !== "active_templates"
|
|
29
|
-
);
|
|
30
|
-
const hasActiveTemplates = experiments.includes("active_templates");
|
|
31
|
-
const experimentsData = {};
|
|
32
|
-
for (const experiment of regularExperiments) {
|
|
33
|
-
experimentsData[experiment] = true;
|
|
34
|
-
}
|
|
35
|
-
const settingsData = {
|
|
36
|
-
"gutenberg-experiments": experimentsData
|
|
37
|
-
};
|
|
38
|
-
if (hasActiveTemplates) {
|
|
39
|
-
settingsData.active_templates = {};
|
|
40
|
-
} else {
|
|
41
|
-
const currentSiteSettings = await this.getSiteSettings();
|
|
42
|
-
if (currentSiteSettings.active_templates !== null) {
|
|
43
|
-
settingsData.active_templates = null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
await this.rest({
|
|
47
|
-
path: "/wp/v2/settings",
|
|
48
|
-
method: "POST",
|
|
49
|
-
data: settingsData
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
-
0 && (module.exports = {
|
|
54
|
-
setGutenbergExperiments
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=gutenberg-experiments.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/gutenberg-experiments.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Sets the Gutenberg experiments.\n *\n * @param this\n * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.\n * Use 'active_templates' for the template activation feature.\n */\nasync function setGutenbergExperiments(\n\tthis: RequestUtils,\n\texperiments: string[]\n) {\n\t// Separate regular experiments from active_templates.\n\t// active_templates is stored as a separate option, not in the experiments array.\n\tconst regularExperiments = experiments.filter(\n\t\t( exp ) => exp !== 'active_templates'\n\t);\n\tconst hasActiveTemplates = experiments.includes( 'active_templates' );\n\n\t// Build the experiments object with boolean values.\n\t// When empty array is passed, we send an empty object to disable all experiments.\n\tconst experimentsData: Record< string, boolean > = {};\n\n\tfor ( const experiment of regularExperiments ) {\n\t\texperimentsData[ experiment ] = true;\n\t}\n\n\tconst settingsData: Record< string, unknown > = {\n\t\t'gutenberg-experiments': experimentsData,\n\t};\n\n\t// active_templates lives in a separate top-level option. Sending `{}`\n\t// enables the experiment; sending `null` deletes the option and disables\n\t// it.\n\tif ( hasActiveTemplates ) {\n\t\tsettingsData.active_templates = {};\n\t} else {\n\t\t// WP_REST_Settings_Controller rejects null updates when the stored\n\t\t// value does not match the `type: 'object'` schema (including when the\n\t\t// option is absent and `get_option` falls back to `false`), so we only\n\t\t// send null when the option actually exists.\n\t\tconst currentSiteSettings =\n\t\t\t( await this.getSiteSettings() ) as unknown as {\n\t\t\t\tactive_templates?: unknown;\n\t\t\t};\n\t\tif ( currentSiteSettings.active_templates !== null ) {\n\t\t\tsettingsData.active_templates = null;\n\t\t}\n\t}\n\n\tawait this.rest( {\n\t\tpath: '/wp/v2/settings',\n\t\tmethod: 'POST',\n\t\tdata: settingsData,\n\t} );\n}\n\nexport { setGutenbergExperiments };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,eAAe,wBAEd,aACC;AAGD,QAAM,qBAAqB,YAAY;AAAA,IACtC,CAAE,QAAS,QAAQ;AAAA,EACpB;AACA,QAAM,qBAAqB,YAAY,SAAU,kBAAmB;AAIpE,QAAM,kBAA6C,CAAC;AAEpD,aAAY,cAAc,oBAAqB;AAC9C,oBAAiB,UAAW,IAAI;AAAA,EACjC;AAEA,QAAM,eAA0C;AAAA,IAC/C,yBAAyB;AAAA,EAC1B;AAKA,MAAK,oBAAqB;AACzB,iBAAa,mBAAmB,CAAC;AAAA,EAClC,OAAO;AAKN,UAAM,sBACH,MAAM,KAAK,gBAAgB;AAG9B,QAAK,oBAAoB,qBAAqB,MAAO;AACpD,mBAAa,mBAAmB;AAAA,IACjC;AAAA,EACD;AAEA,QAAM,KAAK,KAAM;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,EACP,CAAE;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|