@wordpress/e2e-test-utils-playwright 1.37.0 → 1.37.1-next.79a2f3cdd.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/LICENSE.md +1 -1
- package/build/admin/create-new-post.cjs +51 -0
- package/build/admin/create-new-post.cjs.map +7 -0
- package/build/admin/create-new-post.js +28 -48
- package/build/admin/create-new-post.js.map +1 -7
- package/build/admin/edit-post.cjs +40 -0
- package/build/admin/edit-post.cjs.map +7 -0
- package/build/admin/edit-post.js +17 -37
- package/build/admin/edit-post.js.map +1 -7
- package/build/admin/get-page-error.cjs +36 -0
- package/build/admin/get-page-error.cjs.map +7 -0
- package/build/admin/get-page-error.js +23 -33
- package/build/admin/get-page-error.js.map +1 -7
- package/build/admin/index.cjs +59 -0
- package/build/admin/index.cjs.map +7 -0
- package/build/admin/index.js +36 -58
- package/build/admin/index.js.map +1 -7
- package/build/admin/visit-admin-page.cjs +47 -0
- package/build/admin/visit-admin-page.cjs.map +7 -0
- package/build/admin/visit-admin-page.js +29 -44
- package/build/admin/visit-admin-page.js.map +1 -7
- package/build/admin/visit-site-editor.cjs +77 -0
- package/build/admin/visit-site-editor.cjs.map +7 -0
- package/build/admin/visit-site-editor.js +64 -73
- package/build/admin/visit-site-editor.js.map +1 -7
- package/build/config.cjs +45 -0
- package/build/config.cjs.map +7 -0
- package/build/config.js +11 -43
- package/build/config.js.map +1 -7
- package/build/editor/click-block-options-menu-item.cjs +34 -0
- package/build/editor/click-block-options-menu-item.cjs.map +7 -0
- package/build/editor/click-block-options-menu-item.js +14 -31
- package/build/editor/click-block-options-menu-item.js.map +1 -7
- package/build/editor/click-block-toolbar-button.cjs +38 -0
- package/build/editor/click-block-toolbar-button.cjs.map +7 -0
- package/build/editor/click-block-toolbar-button.js +13 -35
- package/build/editor/click-block-toolbar-button.js.map +1 -7
- package/build/editor/get-blocks.cjs +64 -0
- package/build/editor/get-blocks.cjs.map +7 -0
- package/build/editor/get-blocks.js +43 -61
- package/build/editor/get-blocks.js.map +1 -7
- package/build/editor/get-edited-post-content.cjs +36 -0
- package/build/editor/get-edited-post-content.cjs.map +7 -0
- package/build/editor/get-edited-post-content.js +12 -33
- package/build/editor/get-edited-post-content.js.map +1 -7
- package/build/editor/index.cjs +97 -0
- package/build/editor/index.cjs.map +7 -0
- package/build/editor/index.js +74 -96
- package/build/editor/index.js.map +1 -7
- package/build/editor/insert-block.cjs +55 -0
- package/build/editor/insert-block.cjs.map +7 -0
- package/build/editor/insert-block.js +21 -52
- package/build/editor/insert-block.js.map +1 -7
- package/build/editor/open-document-settings-sidebar.cjs +42 -0
- package/build/editor/open-document-settings-sidebar.cjs.map +7 -0
- package/build/editor/open-document-settings-sidebar.js +24 -39
- package/build/editor/open-document-settings-sidebar.js.map +1 -7
- package/build/editor/preview.cjs +42 -0
- package/build/editor/preview.cjs.map +7 -0
- package/build/editor/preview.js +18 -39
- package/build/editor/preview.js.map +1 -7
- package/build/editor/publish-post.cjs +47 -0
- package/build/editor/publish-post.cjs.map +7 -0
- package/build/editor/publish-post.js +42 -44
- package/build/editor/publish-post.js.map +1 -7
- package/build/editor/save-draft.cjs +34 -0
- package/build/editor/save-draft.cjs.map +7 -0
- package/build/editor/save-draft.js +15 -31
- package/build/editor/save-draft.js.map +1 -7
- package/build/editor/select-blocks.cjs +51 -0
- package/build/editor/select-blocks.cjs.map +7 -0
- package/build/editor/select-blocks.js +25 -48
- package/build/editor/select-blocks.js.map +1 -7
- package/build/editor/set-content.cjs +39 -0
- package/build/editor/set-content.cjs.map +7 -0
- package/build/editor/set-content.js +14 -36
- package/build/editor/set-content.js.map +1 -7
- package/build/editor/set-is-fixed-toolbar.cjs +36 -0
- package/build/editor/set-is-fixed-toolbar.cjs.map +7 -0
- package/build/editor/set-is-fixed-toolbar.js +15 -33
- package/build/editor/set-is-fixed-toolbar.js.map +1 -7
- package/build/editor/set-preferences.cjs +43 -0
- package/build/editor/set-preferences.cjs.map +7 -0
- package/build/editor/set-preferences.js +18 -40
- package/build/editor/set-preferences.js.map +1 -7
- package/build/editor/show-block-toolbar.cjs +35 -0
- package/build/editor/show-block-toolbar.cjs.map +7 -0
- package/build/editor/show-block-toolbar.js +16 -32
- package/build/editor/show-block-toolbar.js.map +1 -7
- package/build/editor/site-editor.cjs +51 -0
- package/build/editor/site-editor.cjs.map +7 -0
- package/build/editor/site-editor.js +41 -48
- package/build/editor/site-editor.js.map +1 -7
- package/build/editor/switch-editor-tool.cjs +47 -0
- package/build/editor/switch-editor-tool.cjs.map +7 -0
- package/build/editor/switch-editor-tool.js +30 -44
- package/build/editor/switch-editor-tool.js.map +1 -7
- package/build/editor/switch-to-legacy-canvas.cjs +39 -0
- package/build/editor/switch-to-legacy-canvas.cjs.map +7 -0
- package/build/editor/switch-to-legacy-canvas.js +14 -35
- package/build/editor/switch-to-legacy-canvas.js.map +1 -7
- package/build/editor/transform-block-to.cjs +46 -0
- package/build/editor/transform-block-to.cjs.map +7 -0
- package/build/editor/transform-block-to.js +21 -43
- package/build/editor/transform-block-to.js.map +1 -7
- package/build/index.cjs +51 -0
- package/build/index.cjs.map +7 -0
- package/build/index.js +18 -53
- package/build/index.js.map +1 -7
- package/build/lighthouse/index.cjs +96 -0
- package/build/lighthouse/index.cjs.map +7 -0
- package/build/lighthouse/index.js +55 -93
- package/build/lighthouse/index.js.map +1 -7
- package/build/metrics/index.cjs +309 -0
- package/build/metrics/index.cjs.map +7 -0
- package/build/metrics/index.js +251 -302
- package/build/metrics/index.js.map +1 -7
- package/build/page-utils/drag-files.cjs +143 -0
- package/build/page-utils/drag-files.cjs.map +7 -0
- package/build/page-utils/drag-files.js +112 -136
- package/build/page-utils/drag-files.js.map +1 -7
- package/build/page-utils/emulate-network-conditions.cjs +99 -0
- package/build/page-utils/emulate-network-conditions.cjs.map +7 -0
- package/build/page-utils/emulate-network-conditions.js +67 -95
- package/build/page-utils/emulate-network-conditions.js.map +1 -7
- package/build/page-utils/index.cjs +59 -0
- package/build/page-utils/index.cjs.map +7 -0
- package/build/page-utils/index.js +36 -58
- package/build/page-utils/index.js.map +1 -7
- package/build/page-utils/is-current-url.cjs +36 -0
- package/build/page-utils/is-current-url.cjs.map +7 -0
- package/build/page-utils/is-current-url.js +18 -33
- package/build/page-utils/is-current-url.js.map +1 -7
- package/build/page-utils/keycodes.cjs +55 -0
- package/build/page-utils/keycodes.cjs.map +7 -0
- package/build/page-utils/keycodes.js +39 -53
- package/build/page-utils/keycodes.js.map +1 -7
- package/build/page-utils/press-keys.cjs +165 -0
- package/build/page-utils/press-keys.cjs.map +7 -0
- package/build/page-utils/press-keys.js +130 -153
- package/build/page-utils/press-keys.js.map +1 -7
- package/build/page-utils/set-browser-viewport.cjs +39 -0
- package/build/page-utils/set-browser-viewport.cjs.map +7 -0
- package/build/page-utils/set-browser-viewport.js +42 -35
- package/build/page-utils/set-browser-viewport.js.map +1 -7
- package/build/request-utils/blocks.cjs +56 -0
- package/build/request-utils/blocks.cjs.map +7 -0
- package/build/request-utils/blocks.js +40 -51
- package/build/request-utils/blocks.js.map +1 -7
- package/build/request-utils/comments.cjs +66 -0
- package/build/request-utils/comments.cjs.map +7 -0
- package/build/request-utils/comments.js +45 -59
- package/build/request-utils/comments.js.map +1 -7
- package/build/request-utils/gutenberg-experiments.cjs +66 -0
- package/build/request-utils/gutenberg-experiments.cjs.map +7 -0
- package/build/request-utils/gutenberg-experiments.js +38 -63
- package/build/request-utils/gutenberg-experiments.js.map +1 -7
- package/build/request-utils/index.cjs +194 -0
- package/build/request-utils/index.cjs.map +7 -0
- package/build/request-utils/index.js +155 -191
- package/build/request-utils/index.js.map +1 -7
- package/build/request-utils/login.cjs +48 -0
- package/build/request-utils/login.cjs.map +7 -0
- package/build/request-utils/login.js +18 -45
- package/build/request-utils/login.js.map +1 -7
- package/build/request-utils/media.cjs +83 -0
- package/build/request-utils/media.cjs.map +7 -0
- package/build/request-utils/media.js +64 -74
- package/build/request-utils/media.js.map +1 -7
- package/build/request-utils/menus.cjs +132 -0
- package/build/request-utils/menus.cjs.map +7 -0
- package/build/request-utils/menus.js +109 -121
- package/build/request-utils/menus.js.map +1 -7
- package/build/request-utils/pages.cjs +71 -0
- package/build/request-utils/pages.cjs.map +7 -0
- package/build/request-utils/pages.js +50 -63
- package/build/request-utils/pages.js.map +1 -7
- package/build/request-utils/patterns.cjs +44 -0
- package/build/request-utils/patterns.cjs.map +7 -0
- package/build/request-utils/patterns.js +24 -41
- package/build/request-utils/patterns.js.map +1 -7
- package/build/request-utils/plugins.cjs +81 -0
- package/build/request-utils/plugins.cjs.map +7 -0
- package/build/request-utils/plugins.js +74 -70
- package/build/request-utils/plugins.js.map +1 -7
- package/build/request-utils/posts.cjs +61 -0
- package/build/request-utils/posts.cjs.map +7 -0
- package/build/request-utils/posts.js +41 -55
- package/build/request-utils/posts.js.map +1 -7
- package/build/request-utils/preferences.cjs +41 -0
- package/build/request-utils/preferences.cjs.map +7 -0
- package/build/request-utils/preferences.js +17 -38
- package/build/request-utils/preferences.js.map +1 -7
- package/build/request-utils/rest.cjs +174 -0
- package/build/request-utils/rest.cjs.map +7 -0
- package/build/request-utils/rest.js +129 -155
- package/build/request-utils/rest.js.map +1 -7
- package/build/request-utils/site-settings.cjs +45 -0
- package/build/request-utils/site-settings.cjs.map +7 -0
- package/build/request-utils/site-settings.js +28 -40
- package/build/request-utils/site-settings.js.map +1 -7
- package/build/request-utils/templates.cjs +68 -0
- package/build/request-utils/templates.cjs.map +7 -0
- package/build/request-utils/templates.js +46 -60
- package/build/request-utils/templates.js.map +1 -7
- package/build/request-utils/themes.cjs +89 -0
- package/build/request-utils/themes.cjs.map +7 -0
- package/build/request-utils/themes.js +53 -80
- package/build/request-utils/themes.js.map +1 -7
- package/build/request-utils/users.cjs +83 -0
- package/build/request-utils/users.cjs.map +7 -0
- package/build/request-utils/users.js +72 -74
- package/build/request-utils/users.js.map +1 -7
- package/build/request-utils/widgets.cjs +79 -0
- package/build/request-utils/widgets.cjs.map +7 -0
- package/build/request-utils/widgets.js +55 -73
- package/build/request-utils/widgets.js.map +1 -7
- package/build/test.cjs +136 -0
- package/build/test.cjs.map +7 -0
- package/build/test.js +146 -130
- package/build/test.js.map +1 -7
- package/build/types.cjs +19 -0
- package/build/types.cjs.map +7 -0
- package/build/types.js +2 -18
- package/build/types.js.map +1 -7
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1,39 @@
|
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
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,39 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
medium: { width: 768, height: 700 },
|
|
29
|
-
small: { width: 600, height: 700 }
|
|
2
|
+
/**
|
|
3
|
+
* Named viewport options.
|
|
4
|
+
*
|
|
5
|
+
* @typedef {"large"|"medium"|"small"} WPDimensionsName
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.setBrowserViewport = setBrowserViewport;
|
|
9
|
+
/**
|
|
10
|
+
* Viewport dimensions object.
|
|
11
|
+
*
|
|
12
|
+
* @typedef {Object} WPViewportDimensions
|
|
13
|
+
*
|
|
14
|
+
* @property {number} width Width, in pixels.
|
|
15
|
+
* @property {number} height Height, in pixels.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Predefined viewport dimensions to reference by name.
|
|
19
|
+
*
|
|
20
|
+
* @enum {WPViewportDimensions}
|
|
21
|
+
*
|
|
22
|
+
* @type {Record<WPDimensionsName, WPViewportDimensions>}
|
|
23
|
+
*/
|
|
24
|
+
const PREDEFINED_DIMENSIONS = {
|
|
25
|
+
large: { width: 960, height: 700 },
|
|
26
|
+
medium: { width: 768, height: 700 },
|
|
27
|
+
small: { width: 600, height: 700 },
|
|
30
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Valid argument argument type from which to derive viewport dimensions.
|
|
31
|
+
*
|
|
32
|
+
* @typedef {WPDimensionsName|WPViewportDimensions} WPViewport
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Sets browser viewport to specified type.
|
|
36
|
+
*
|
|
37
|
+
* @this {import('./').PageUtils}
|
|
38
|
+
* @param {WPViewport} viewport Viewport name or dimensions object to assign.
|
|
39
|
+
*/
|
|
31
40
|
async function setBrowserViewport(viewport) {
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
const dimensions = typeof viewport === 'string'
|
|
42
|
+
? PREDEFINED_DIMENSIONS[viewport]
|
|
43
|
+
: viewport;
|
|
44
|
+
await this.page.setViewportSize(dimensions);
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
setBrowserViewport
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=set-browser-viewport.js.map
|
|
46
|
+
//# sourceMappingURL=set-browser-viewport.js.map
|
|
@@ -1,7 +1 @@
|
|
|
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
|
+
{"version":3,"file":"set-browser-viewport.js","sourceRoot":"","sources":["../../src/page-utils/set-browser-viewport.js"],"names":[],"mappings":";AAAA;;;;GAIG;;AAoCH,gDAOC;AAzCD;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG;IAC7B,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAClC,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IACnC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;CAClC,CAAC;AAEF;;;;GAIG;AAEH;;;;;GAKG;AACI,KAAK,UAAU,kBAAkB,CAAE,QAAQ;IACjD,MAAM,UAAU,GACf,OAAO,QAAQ,KAAK,QAAQ;QAC3B,CAAC,CAAC,qBAAqB,CAAE,QAAQ,CAAE;QACnC,CAAC,CAAC,QAAQ,CAAC;IAEb,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,UAAU,CAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
const block = await this.rest({
|
|
45
|
+
path: "/wp/v2/blocks",
|
|
46
|
+
method: "POST",
|
|
47
|
+
data: { ...payload }
|
|
48
|
+
});
|
|
49
|
+
return block;
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
createBlock,
|
|
54
|
+
deleteAllBlocks
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=blocks.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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\tconst block = await this.rest( {\n\t\tpath: '/wp/v2/blocks',\n\t\tmethod: 'POST',\n\t\tdata: { ...payload },\n\t} );\n\n\treturn block;\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,QAAM,QAAQ,MAAM,KAAK,KAAM;AAAA,IAC9B,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM,EAAE,GAAG,QAAQ;AAAA,EACpB,CAAE;AAEF,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,56 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteAllBlocks = deleteAllBlocks;
|
|
4
|
+
exports.createBlock = createBlock;
|
|
5
|
+
/**
|
|
6
|
+
* Delete all blocks using REST API.
|
|
7
|
+
*
|
|
8
|
+
* @see https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks
|
|
9
|
+
* @param this
|
|
10
|
+
*/
|
|
27
11
|
async function deleteAllBlocks() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
12
|
+
// List all blocks.
|
|
13
|
+
// https://developer.wordpress.org/rest-api/reference/blocks/#list-editor-blocks
|
|
14
|
+
const blocks = await this.rest({
|
|
15
|
+
path: '/wp/v2/blocks',
|
|
16
|
+
params: {
|
|
17
|
+
per_page: 100,
|
|
18
|
+
// All possible statuses.
|
|
19
|
+
status: 'publish,future,draft,pending,private,trash',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
// Delete blocks.
|
|
23
|
+
// https://developer.wordpress.org/rest-api/reference/blocks/#delete-a-editor-block
|
|
24
|
+
// "/wp/v2/posts" not yet supports batch requests.
|
|
25
|
+
await this.batchRest(blocks.map((block) => ({
|
|
26
|
+
method: 'DELETE',
|
|
27
|
+
path: `/wp/v2/blocks/${block.id}?force=true`,
|
|
28
|
+
})));
|
|
42
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new block using the REST API.
|
|
32
|
+
*
|
|
33
|
+
* @see https://developer.wordpress.org/rest-api/reference/blocks/#create-a-editor-block.
|
|
34
|
+
* @param this
|
|
35
|
+
* @param payload Block payload.
|
|
36
|
+
*/
|
|
43
37
|
async function createBlock(payload) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
const block = await this.rest({
|
|
39
|
+
path: '/wp/v2/blocks',
|
|
40
|
+
method: 'POST',
|
|
41
|
+
data: { ...payload },
|
|
42
|
+
});
|
|
43
|
+
return block;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
createBlock,
|
|
54
|
-
deleteAllBlocks
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=blocks.js.map
|
|
45
|
+
//# sourceMappingURL=blocks.js.map
|
|
@@ -1,7 +1 @@
|
|
|
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\tconst block = await this.rest( {\n\t\tpath: '/wp/v2/blocks',\n\t\tmethod: 'POST',\n\t\tdata: { ...payload },\n\t} );\n\n\treturn block;\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,QAAM,QAAQ,MAAM,KAAK,KAAM;AAAA,IAC9B,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM,EAAE,GAAG,QAAQ;AAAA,EACpB,CAAE;AAEF,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/request-utils/blocks.ts"],"names":[],"mappings":";;AAsBA,0CAqBC;AASD,kCAWC;AA/CD;;;;;GAKG;AACI,KAAK,UAAU,eAAe;IACpC,mBAAmB;IACnB,gFAAgF;IAChF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QAC/B,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;YACb,yBAAyB;YACzB,MAAM,EAAE,4CAA4C;SACpD;KACD,CAAE,CAAC;IAEJ,iBAAiB;IACjB,mFAAmF;IACnF,kDAAkD;IAClD,MAAM,IAAI,CAAC,SAAS,CACnB,MAAM,CAAC,GAAG,CAAE,CAAE,KAAqB,EAAG,EAAE,CAAC,CAAE;QAC1C,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,iBAAkB,KAAK,CAAC,EAAG,aAAa;KAC9C,CAAE,CAAE,CACL,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,WAAW,CAEhC,OAA2B;IAE3B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QAC9B,IAAI,EAAE,eAAe;QACrB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE;KACpB,CAAE,CAAC;IAEJ,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
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,66 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createComment = createComment;
|
|
4
|
+
exports.deleteAllComments = deleteAllComments;
|
|
5
|
+
/**
|
|
6
|
+
* Create new comment using the REST API.
|
|
7
|
+
*
|
|
8
|
+
* @param this
|
|
9
|
+
* @param payload
|
|
10
|
+
*/
|
|
27
11
|
async function createComment(payload) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
const currentUser = await this.rest({
|
|
13
|
+
path: '/wp/v2/users/me',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
});
|
|
16
|
+
const author = currentUser.id;
|
|
17
|
+
const comment = await this.rest({
|
|
18
|
+
method: 'POST',
|
|
19
|
+
path: '/wp/v2/comments',
|
|
20
|
+
data: { ...payload, author },
|
|
21
|
+
});
|
|
22
|
+
return comment;
|
|
39
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Delete all comments using the REST API.
|
|
26
|
+
*
|
|
27
|
+
* @param this
|
|
28
|
+
* @param type - Optional comment type to delete.
|
|
29
|
+
*/
|
|
40
30
|
async function deleteAllComments(type) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
// List all comments.
|
|
32
|
+
// https://developer.wordpress.org/rest-api/reference/comments/#list-comments
|
|
33
|
+
const comments = await this.rest({
|
|
34
|
+
path: '/wp/v2/comments',
|
|
35
|
+
params: {
|
|
36
|
+
per_page: 100,
|
|
37
|
+
status: 'all',
|
|
38
|
+
type: type || 'comment',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
// Delete all comments one by one.
|
|
42
|
+
// https://developer.wordpress.org/rest-api/reference/comments/#delete-a-comment
|
|
43
|
+
// "/wp/v2/comments" doesn't support batch requests yet.
|
|
44
|
+
await Promise.all(comments.map((comment) => this.rest({
|
|
45
|
+
method: 'DELETE',
|
|
53
46
|
path: `/wp/v2/comments/${comment.id}`,
|
|
54
47
|
params: {
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
)
|
|
59
|
-
);
|
|
48
|
+
force: true,
|
|
49
|
+
},
|
|
50
|
+
})));
|
|
60
51
|
}
|
|
61
|
-
|
|
62
|
-
0 && (module.exports = {
|
|
63
|
-
createComment,
|
|
64
|
-
deleteAllComments
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=comments.js.map
|
|
52
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -1,7 +1 @@
|
|
|
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
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/request-utils/comments.ts"],"names":[],"mappings":";;AA2BA,sCAkBC;AAQD,8CA0BC;AA1DD;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAElC,OAA6B;IAE7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAU;QAC5C,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;KACb,CAAE,CAAC;IAEJ,MAAM,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAa;QAC3C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE;KAC5B,CAAE,CAAC;IAEJ,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CAAsB,IAAa;IACzE,qBAAqB;IACrB,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACjC,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;YACb,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,IAAI,SAAS;SACvB;KACD,CAAE,CAAC;IAEJ,kCAAkC;IAClC,gFAAgF;IAChF,wDAAwD;IACxD,MAAM,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,GAAG,CAAE,CAAE,OAAgB,EAAG,EAAE,CACpC,IAAI,CAAC,IAAI,CAAE;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,mBAAoB,OAAO,CAAC,EAAG,EAAE;QACvC,MAAM,EAAE;YACP,KAAK,EAAE,IAAI;SACX;KACD,CAAE,CACH,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 response = await this.request.get(
|
|
28
|
+
"/wp-admin/admin.php?page=gutenberg-experiments"
|
|
29
|
+
);
|
|
30
|
+
const html = await response.text();
|
|
31
|
+
const nonce = html.match(/name="_wpnonce" value="([^"]+)"/)[1];
|
|
32
|
+
const formData = {
|
|
33
|
+
option_page: "gutenberg-experiments",
|
|
34
|
+
action: "update",
|
|
35
|
+
_wpnonce: nonce,
|
|
36
|
+
_wp_http_referer: "/wp-admin/admin.php?page=gutenberg-experiments",
|
|
37
|
+
submit: "Save Changes"
|
|
38
|
+
};
|
|
39
|
+
const regularExperiments = experiments.filter(
|
|
40
|
+
(exp) => exp !== "active_templates"
|
|
41
|
+
);
|
|
42
|
+
const hasActiveTemplates = experiments.includes("active_templates");
|
|
43
|
+
if (regularExperiments.length > 0) {
|
|
44
|
+
Object.assign(
|
|
45
|
+
formData,
|
|
46
|
+
Object.fromEntries(
|
|
47
|
+
regularExperiments.map((experiment) => [
|
|
48
|
+
`gutenberg-experiments[${experiment}]`,
|
|
49
|
+
1
|
|
50
|
+
])
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (hasActiveTemplates) {
|
|
55
|
+
formData.active_templates = 1;
|
|
56
|
+
}
|
|
57
|
+
await this.request.post("/wp-admin/options.php", {
|
|
58
|
+
form: formData,
|
|
59
|
+
failOnStatusCode: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
setGutenbergExperiments
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=gutenberg-experiments.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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\tconst response = await this.request.get(\n\t\t'/wp-admin/admin.php?page=gutenberg-experiments'\n\t);\n\tconst html = await response.text();\n\tconst nonce = html.match( /name=\"_wpnonce\" value=\"([^\"]+)\"/ )![ 1 ];\n\n\tconst formData: Record< string, string | number > = {\n\t\toption_page: 'gutenberg-experiments',\n\t\taction: 'update',\n\t\t_wpnonce: nonce,\n\t\t_wp_http_referer: '/wp-admin/admin.php?page=gutenberg-experiments',\n\t\tsubmit: 'Save Changes',\n\t};\n\n\t// Separate regular experiments from active_templates.\n\tconst regularExperiments = experiments.filter(\n\t\t( exp ) => exp !== 'active_templates'\n\t);\n\tconst hasActiveTemplates = experiments.includes( 'active_templates' );\n\n\t// Add regular experiments to the gutenberg-experiments array.\n\tif ( regularExperiments.length > 0 ) {\n\t\tObject.assign(\n\t\t\tformData,\n\t\t\tObject.fromEntries(\n\t\t\t\tregularExperiments.map( ( experiment ) => [\n\t\t\t\t\t`gutenberg-experiments[${ experiment }]`,\n\t\t\t\t\t1,\n\t\t\t\t] )\n\t\t\t)\n\t\t);\n\t}\n\n\t// Template activation uses the active_templates checkbox field.\n\tif ( hasActiveTemplates ) {\n\t\tformData.active_templates = 1;\n\t}\n\n\tawait this.request.post( '/wp-admin/options.php', {\n\t\tform: formData,\n\t\tfailOnStatusCode: true,\n\t} );\n}\n\nexport { setGutenbergExperiments };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,eAAe,wBAEd,aACC;AACD,QAAM,WAAW,MAAM,KAAK,QAAQ;AAAA,IACnC;AAAA,EACD;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAM,QAAQ,KAAK,MAAO,iCAAkC,EAAI,CAAE;AAElE,QAAM,WAA8C;AAAA,IACnD,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EACT;AAGA,QAAM,qBAAqB,YAAY;AAAA,IACtC,CAAE,QAAS,QAAQ;AAAA,EACpB;AACA,QAAM,qBAAqB,YAAY,SAAU,kBAAmB;AAGpE,MAAK,mBAAmB,SAAS,GAAI;AACpC,WAAO;AAAA,MACN;AAAA,MACA,OAAO;AAAA,QACN,mBAAmB,IAAK,CAAE,eAAgB;AAAA,UACzC,yBAA0B,UAAW;AAAA,UACrC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAGA,MAAK,oBAAqB;AACzB,aAAS,mBAAmB;AAAA,EAC7B;AAEA,QAAM,KAAK,QAAQ,KAAM,yBAAyB;AAAA,IACjD,MAAM;AAAA,IACN,kBAAkB;AAAA,EACnB,CAAE;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|