@wordpress/e2e-test-utils-playwright 1.46.0 → 1.48.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-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 +4 -5
- package/src/admin/create-new-post.ts +47 -0
- package/src/admin/edit-post.ts +24 -0
- package/{build/admin/get-page-error.js → src/admin/get-page-error.ts} +12 -9
- package/src/admin/index.ts +52 -0
- package/src/admin/visit-admin-page.ts +43 -0
- package/src/admin/visit-site-editor.ts +62 -0
- package/src/admin/wait-for-site-editor.ts +52 -0
- package/src/config.ts +12 -0
- package/src/editor/click-block-options-menu-item.ts +18 -0
- package/src/editor/click-block-toolbar-button.ts +21 -0
- package/src/editor/get-blocks.ts +75 -0
- package/src/editor/get-edited-post-content.ts +19 -0
- package/src/editor/index.ts +95 -0
- package/src/editor/insert-block.ts +54 -0
- package/src/editor/open-document-settings-sidebar.ts +31 -0
- package/src/editor/preview.ts +32 -0
- package/src/editor/publish-post.ts +51 -0
- package/src/editor/save-draft.ts +20 -0
- package/src/editor/select-blocks.ts +48 -0
- package/src/editor/set-content.ts +24 -0
- package/src/editor/set-is-fixed-toolbar.ts +20 -0
- package/src/editor/set-preferences.ts +37 -0
- package/src/editor/show-block-toolbar.ts +20 -0
- package/src/editor/site-editor.ts +55 -0
- package/src/editor/switch-editor-tool.ts +34 -0
- package/src/editor/switch-to-legacy-canvas.ts +20 -0
- package/src/editor/transform-block-to.ts +34 -0
- package/src/index.ts +8 -0
- package/src/lighthouse/index.ts +75 -0
- package/src/metrics/index.ts +441 -0
- package/src/page-utils/drag-files.ts +173 -0
- package/src/page-utils/emulate-network-conditions.ts +101 -0
- package/src/page-utils/index.ts +54 -0
- package/src/page-utils/is-current-url.ts +20 -0
- package/src/page-utils/keycodes.ts +48 -0
- package/src/page-utils/press-keys.ts +195 -0
- package/{build → src}/page-utils/set-browser-viewport.js +14 -12
- package/src/request-utils/blocks.ts +58 -0
- package/src/request-utils/comments.ts +80 -0
- package/src/request-utils/gutenberg-experiments.ts +62 -0
- package/src/request-utils/index.ts +222 -0
- package/src/request-utils/login.ts +34 -0
- package/src/request-utils/media.ts +102 -0
- package/src/request-utils/menus.ts +145 -0
- package/src/request-utils/pages.ts +75 -0
- package/src/request-utils/patterns.ts +31 -0
- package/src/request-utils/plugins.ts +103 -0
- package/src/request-utils/posts.ts +69 -0
- package/src/request-utils/preferences.ts +63 -0
- package/{build/request-utils/records.js → src/request-utils/records.ts} +15 -10
- package/src/request-utils/rest.ts +222 -0
- package/src/request-utils/site-settings.ts +58 -0
- package/src/request-utils/templates.ts +83 -0
- package/src/request-utils/themes.ts +110 -0
- package/src/request-utils/users.ts +125 -0
- package/src/request-utils/widgets.js +68 -0
- package/src/test.ts +204 -0
- package/src/types.ts +13 -0
- package/build/admin/create-new-post.cjs +0 -51
- package/build/admin/create-new-post.cjs.map +0 -7
- package/build/admin/create-new-post.js +0 -31
- package/build/admin/create-new-post.js.map +0 -1
- package/build/admin/edit-post.cjs +0 -40
- package/build/admin/edit-post.cjs.map +0 -7
- package/build/admin/edit-post.js +0 -20
- package/build/admin/edit-post.js.map +0 -1
- package/build/admin/get-page-error.cjs +0 -36
- package/build/admin/get-page-error.cjs.map +0 -7
- package/build/admin/get-page-error.js.map +0 -1
- package/build/admin/index.cjs +0 -59
- package/build/admin/index.cjs.map +0 -7
- package/build/admin/index.js +0 -37
- package/build/admin/index.js.map +0 -1
- package/build/admin/visit-admin-page.cjs +0 -47
- package/build/admin/visit-admin-page.cjs.map +0 -7
- package/build/admin/visit-admin-page.js +0 -32
- package/build/admin/visit-admin-page.js.map +0 -1
- package/build/admin/visit-site-editor.cjs +0 -90
- package/build/admin/visit-site-editor.cjs.map +0 -7
- package/build/admin/visit-site-editor.js +0 -73
- package/build/admin/visit-site-editor.js.map +0 -1
- package/build/config.cjs +0 -45
- package/build/config.cjs.map +0 -7
- package/build/config.js +0 -13
- package/build/config.js.map +0 -1
- 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-options-menu-item.js +0 -17
- package/build/editor/click-block-options-menu-item.js.map +0 -1
- package/build/editor/click-block-toolbar-button.cjs +0 -38
- package/build/editor/click-block-toolbar-button.cjs.map +0 -7
- package/build/editor/click-block-toolbar-button.js +0 -16
- package/build/editor/click-block-toolbar-button.js.map +0 -1
- package/build/editor/get-blocks.cjs +0 -64
- package/build/editor/get-blocks.cjs.map +0 -7
- package/build/editor/get-blocks.js +0 -45
- package/build/editor/get-blocks.js.map +0 -1
- package/build/editor/get-edited-post-content.cjs +0 -36
- package/build/editor/get-edited-post-content.cjs.map +0 -7
- package/build/editor/get-edited-post-content.js +0 -15
- package/build/editor/get-edited-post-content.js.map +0 -1
- package/build/editor/index.cjs +0 -97
- package/build/editor/index.cjs.map +0 -7
- package/build/editor/index.js +0 -75
- package/build/editor/index.js.map +0 -1
- package/build/editor/insert-block.cjs +0 -55
- package/build/editor/insert-block.cjs.map +0 -7
- package/build/editor/insert-block.js +0 -23
- package/build/editor/insert-block.js.map +0 -1
- package/build/editor/open-document-settings-sidebar.cjs +0 -42
- package/build/editor/open-document-settings-sidebar.cjs.map +0 -7
- package/build/editor/open-document-settings-sidebar.js +0 -27
- package/build/editor/open-document-settings-sidebar.js.map +0 -1
- package/build/editor/preview.cjs +0 -42
- package/build/editor/preview.cjs.map +0 -7
- package/build/editor/preview.js +0 -21
- package/build/editor/preview.js.map +0 -1
- package/build/editor/publish-post.cjs +0 -47
- package/build/editor/publish-post.cjs.map +0 -7
- package/build/editor/publish-post.js +0 -45
- package/build/editor/publish-post.js.map +0 -1
- package/build/editor/save-draft.cjs +0 -34
- package/build/editor/save-draft.cjs.map +0 -7
- package/build/editor/save-draft.js +0 -18
- package/build/editor/save-draft.js.map +0 -1
- package/build/editor/select-blocks.cjs +0 -51
- package/build/editor/select-blocks.cjs.map +0 -7
- package/build/editor/select-blocks.js +0 -28
- package/build/editor/select-blocks.js.map +0 -1
- package/build/editor/set-content.cjs +0 -39
- package/build/editor/set-content.cjs.map +0 -7
- package/build/editor/set-content.js +0 -17
- package/build/editor/set-content.js.map +0 -1
- 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-is-fixed-toolbar.js +0 -18
- package/build/editor/set-is-fixed-toolbar.js.map +0 -1
- package/build/editor/set-preferences.cjs +0 -43
- package/build/editor/set-preferences.cjs.map +0 -7
- package/build/editor/set-preferences.js +0 -21
- package/build/editor/set-preferences.js.map +0 -1
- package/build/editor/show-block-toolbar.cjs +0 -35
- package/build/editor/show-block-toolbar.cjs.map +0 -7
- package/build/editor/show-block-toolbar.js +0 -19
- package/build/editor/show-block-toolbar.js.map +0 -1
- package/build/editor/site-editor.cjs +0 -51
- package/build/editor/site-editor.cjs.map +0 -7
- package/build/editor/site-editor.js +0 -44
- package/build/editor/site-editor.js.map +0 -1
- package/build/editor/switch-editor-tool.cjs +0 -47
- package/build/editor/switch-editor-tool.cjs.map +0 -7
- package/build/editor/switch-editor-tool.js +0 -33
- package/build/editor/switch-editor-tool.js.map +0 -1
- package/build/editor/switch-to-legacy-canvas.cjs +0 -39
- package/build/editor/switch-to-legacy-canvas.cjs.map +0 -7
- package/build/editor/switch-to-legacy-canvas.js +0 -18
- package/build/editor/switch-to-legacy-canvas.js.map +0 -1
- package/build/editor/transform-block-to.cjs +0 -46
- package/build/editor/transform-block-to.cjs.map +0 -7
- package/build/editor/transform-block-to.js +0 -24
- package/build/editor/transform-block-to.js.map +0 -1
- package/build/index.cjs +0 -51
- package/build/index.cjs.map +0 -7
- package/build/index.js +0 -19
- package/build/index.js.map +0 -1
- package/build/lighthouse/index.cjs +0 -96
- package/build/lighthouse/index.cjs.map +0 -7
- package/build/lighthouse/index.js +0 -61
- package/build/lighthouse/index.js.map +0 -1
- package/build/metrics/index.cjs +0 -309
- package/build/metrics/index.cjs.map +0 -7
- package/build/metrics/index.js +0 -258
- package/build/metrics/index.js.map +0 -1
- package/build/page-utils/drag-files.cjs +0 -143
- package/build/page-utils/drag-files.cjs.map +0 -7
- package/build/page-utils/drag-files.js +0 -119
- package/build/page-utils/drag-files.js.map +0 -1
- 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/emulate-network-conditions.js +0 -71
- package/build/page-utils/emulate-network-conditions.js.map +0 -1
- package/build/page-utils/index.cjs +0 -59
- package/build/page-utils/index.cjs.map +0 -7
- package/build/page-utils/index.js +0 -37
- package/build/page-utils/index.js.map +0 -1
- 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/is-current-url.js +0 -21
- package/build/page-utils/is-current-url.js.map +0 -1
- package/build/page-utils/keycodes.cjs +0 -55
- package/build/page-utils/keycodes.cjs.map +0 -7
- package/build/page-utils/keycodes.js +0 -41
- package/build/page-utils/keycodes.js.map +0 -1
- package/build/page-utils/press-keys.cjs +0 -165
- package/build/page-utils/press-keys.cjs.map +0 -7
- package/build/page-utils/press-keys.js +0 -141
- package/build/page-utils/press-keys.js.map +0 -1
- package/build/page-utils/set-browser-viewport.cjs +0 -39
- package/build/page-utils/set-browser-viewport.cjs.map +0 -7
- package/build/page-utils/set-browser-viewport.js.map +0 -1
- package/build/request-utils/blocks.cjs +0 -51
- package/build/request-utils/blocks.cjs.map +0 -7
- package/build/request-utils/blocks.js +0 -40
- package/build/request-utils/blocks.js.map +0 -1
- package/build/request-utils/comments.cjs +0 -66
- package/build/request-utils/comments.cjs.map +0 -7
- package/build/request-utils/comments.js +0 -52
- package/build/request-utils/comments.js.map +0 -1
- package/build/request-utils/gutenberg-experiments.cjs +0 -56
- package/build/request-utils/gutenberg-experiments.cjs.map +0 -7
- package/build/request-utils/gutenberg-experiments.js +0 -47
- package/build/request-utils/gutenberg-experiments.js.map +0 -1
- package/build/request-utils/index.cjs +0 -199
- package/build/request-utils/index.cjs.map +0 -7
- package/build/request-utils/index.js +0 -194
- package/build/request-utils/index.js.map +0 -1
- package/build/request-utils/login.cjs +0 -48
- package/build/request-utils/login.cjs.map +0 -7
- package/build/request-utils/login.js +0 -21
- package/build/request-utils/login.js.map +0 -1
- package/build/request-utils/media.cjs +0 -83
- package/build/request-utils/media.cjs.map +0 -7
- package/build/request-utils/media.js +0 -106
- package/build/request-utils/media.js.map +0 -1
- package/build/request-utils/menus.cjs +0 -128
- package/build/request-utils/menus.cjs.map +0 -7
- package/build/request-utils/menus.js +0 -116
- package/build/request-utils/menus.js.map +0 -1
- package/build/request-utils/pages.cjs +0 -66
- package/build/request-utils/pages.cjs.map +0 -7
- package/build/request-utils/pages.js +0 -53
- package/build/request-utils/pages.js.map +0 -1
- package/build/request-utils/patterns.cjs +0 -44
- package/build/request-utils/patterns.cjs.map +0 -7
- package/build/request-utils/patterns.js +0 -27
- package/build/request-utils/patterns.js.map +0 -1
- package/build/request-utils/plugins.cjs +0 -81
- package/build/request-utils/plugins.cjs.map +0 -7
- package/build/request-utils/plugins.js +0 -85
- package/build/request-utils/plugins.js.map +0 -1
- package/build/request-utils/posts.cjs +0 -56
- package/build/request-utils/posts.cjs.map +0 -7
- package/build/request-utils/posts.js +0 -42
- package/build/request-utils/posts.js.map +0 -1
- package/build/request-utils/preferences.cjs +0 -41
- package/build/request-utils/preferences.cjs.map +0 -7
- package/build/request-utils/preferences.js +0 -20
- package/build/request-utils/preferences.js.map +0 -1
- package/build/request-utils/records.cjs +0 -37
- package/build/request-utils/records.cjs.map +0 -7
- package/build/request-utils/records.js.map +0 -1
- package/build/request-utils/rest.cjs +0 -174
- package/build/request-utils/rest.cjs.map +0 -7
- package/build/request-utils/rest.js +0 -181
- package/build/request-utils/rest.js.map +0 -1
- package/build/request-utils/site-settings.cjs +0 -45
- package/build/request-utils/site-settings.cjs.map +0 -7
- package/build/request-utils/site-settings.js +0 -33
- package/build/request-utils/site-settings.js.map +0 -1
- package/build/request-utils/templates.cjs +0 -68
- package/build/request-utils/templates.cjs.map +0 -7
- package/build/request-utils/templates.js +0 -54
- package/build/request-utils/templates.js.map +0 -1
- package/build/request-utils/themes.cjs +0 -92
- package/build/request-utils/themes.cjs.map +0 -7
- package/build/request-utils/themes.js +0 -69
- package/build/request-utils/themes.js.map +0 -1
- package/build/request-utils/users.cjs +0 -83
- package/build/request-utils/users.cjs.map +0 -7
- package/build/request-utils/users.js +0 -81
- package/build/request-utils/users.js.map +0 -1
- package/build/request-utils/widgets.cjs +0 -79
- package/build/request-utils/widgets.cjs.map +0 -7
- package/build/request-utils/widgets.js +0 -61
- package/build/request-utils/widgets.js.map +0 -1
- package/build/test.cjs +0 -136
- package/build/test.cjs.map +0 -7
- package/build/test.js +0 -189
- package/build/test.js.map +0 -1
- package/build/types.cjs +0 -19
- package/build/types.cjs.map +0 -7
- package/build/types.js +0 -3
- package/build/types.js.map +0 -1
|
@@ -1,41 +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/preferences.ts
|
|
21
|
-
var preferences_exports = {};
|
|
22
|
-
__export(preferences_exports, {
|
|
23
|
-
resetPreferences: () => resetPreferences
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(preferences_exports);
|
|
26
|
-
async function resetPreferences() {
|
|
27
|
-
await this.rest({
|
|
28
|
-
path: "/wp/v2/users/me",
|
|
29
|
-
method: "PUT",
|
|
30
|
-
data: {
|
|
31
|
-
meta: {
|
|
32
|
-
persisted_preferences: {}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
resetPreferences
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=preferences.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/preferences.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Reset user preferences\n *\n * @param this Request utils.\n */\nexport async function resetPreferences( this: RequestUtils ) {\n\tawait this.rest( {\n\t\tpath: '/wp/v2/users/me',\n\t\tmethod: 'PUT',\n\t\tdata: {\n\t\t\tmeta: {\n\t\t\t\tpersisted_preferences: {},\n\t\t\t},\n\t\t},\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAsB,mBAAuC;AAC5D,QAAM,KAAK,KAAM;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,MAAM;AAAA,QACL,uBAAuB,CAAC;AAAA,MACzB;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetPreferences = resetPreferences;
|
|
4
|
-
/**
|
|
5
|
-
* Reset user preferences
|
|
6
|
-
*
|
|
7
|
-
* @param this Request utils.
|
|
8
|
-
*/
|
|
9
|
-
async function resetPreferences() {
|
|
10
|
-
await this.rest({
|
|
11
|
-
path: '/wp/v2/users/me',
|
|
12
|
-
method: 'PUT',
|
|
13
|
-
data: {
|
|
14
|
-
meta: {
|
|
15
|
-
persisted_preferences: {},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=preferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/request-utils/preferences.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACI,KAAK;IACX,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE;YACL,IAAI,EAAE;gBACL,qBAAqB,EAAE,EAAE;aACzB;SACD;KACD,CAAE,CAAC;AACL,CAAC"}
|
|
@@ -1,37 +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/records.ts
|
|
21
|
-
var records_exports = {};
|
|
22
|
-
__export(records_exports, {
|
|
23
|
-
createRecord: () => createRecord
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(records_exports);
|
|
26
|
-
async function createRecord(restBase, payload) {
|
|
27
|
-
return this.rest({
|
|
28
|
-
method: "POST",
|
|
29
|
-
path: `/wp/v2/${restBase}`,
|
|
30
|
-
data: payload
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
createRecord
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=records.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/records.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Create a new record at the given REST base path.\n *\n * Generic seeding helper for per-type wrappers (createPost, createPage, etc.).\n * Call directly for content types without a dedicated wrapper:\n *\n * requestUtils.createRecord( 'user-taxonomies', { ... } );\n *\n * @param this\n * @param restBase REST base, appended to `/wp/v2/`.\n * @param payload Record attributes.\n */\nexport async function createRecord< T = unknown >(\n\tthis: RequestUtils,\n\trestBase: string,\n\tpayload: Record< string, unknown >\n) {\n\treturn this.rest< T >( {\n\t\tmethod: 'POST',\n\t\tpath: `/wp/v2/${ restBase }`,\n\t\tdata: payload,\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,eAAsB,aAErB,UACA,SACC;AACD,SAAO,KAAK,KAAW;AAAA,IACtB,QAAQ;AAAA,IACR,MAAM,UAAW,QAAS;AAAA,IAC1B,MAAM;AAAA,EACP,CAAE;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/request-utils/records.ts"],"names":[],"mappings":";;;AAKA;;;;;;;;;;;GAWG;AACI,KAAK,uBAEX,QAAgB,EAChB,OAAkC;IAElC,OAAO,IAAI,CAAC,IAAI,CAAO;QACtB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAW,QAAS,EAAE;QAC5B,IAAI,EAAE,OAAO;KACb,CAAE,CAAC;AACL,CAAC"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/e2e-test-utils-playwright/src/request-utils/rest.ts
|
|
31
|
-
var rest_exports = {};
|
|
32
|
-
__export(rest_exports, {
|
|
33
|
-
batchRest: () => batchRest,
|
|
34
|
-
getMaxBatchSize: () => getMaxBatchSize,
|
|
35
|
-
rest: () => rest,
|
|
36
|
-
setupRest: () => setupRest
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(rest_exports);
|
|
39
|
-
var fs = __toESM(require("fs/promises"));
|
|
40
|
-
var import_path = require("path");
|
|
41
|
-
var import_test = require("@playwright/test");
|
|
42
|
-
var import_config = require("../config.cjs");
|
|
43
|
-
function splitRequestsToChunks(requests, chunkSize) {
|
|
44
|
-
const arr = [...requests];
|
|
45
|
-
const cache = [];
|
|
46
|
-
while (arr.length) {
|
|
47
|
-
cache.push(arr.splice(0, chunkSize));
|
|
48
|
-
}
|
|
49
|
-
return cache;
|
|
50
|
-
}
|
|
51
|
-
async function getAPIRootURL(request) {
|
|
52
|
-
const response = await request.head(import_config.WP_BASE_URL);
|
|
53
|
-
const links = response.headers().link;
|
|
54
|
-
const restLink = links?.match(/<([^>]+)>; rel="https:\/\/api\.w\.org\/"/);
|
|
55
|
-
if (!restLink) {
|
|
56
|
-
throw new Error(`Failed to discover REST API endpoint.
|
|
57
|
-
Link header: ${links}`);
|
|
58
|
-
}
|
|
59
|
-
const [, rootURL] = restLink;
|
|
60
|
-
return rootURL;
|
|
61
|
-
}
|
|
62
|
-
async function setupRest() {
|
|
63
|
-
let nonce = "";
|
|
64
|
-
let rootURL = "";
|
|
65
|
-
await import_test.expect.poll(
|
|
66
|
-
async () => {
|
|
67
|
-
try {
|
|
68
|
-
[nonce, rootURL] = await Promise.all([
|
|
69
|
-
this.login(),
|
|
70
|
-
getAPIRootURL(this.request)
|
|
71
|
-
]);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
return error;
|
|
74
|
-
}
|
|
75
|
-
return !!(nonce && rootURL);
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
message: "Failed to setup REST API.",
|
|
79
|
-
timeout: 6e4
|
|
80
|
-
// 1 minute.
|
|
81
|
-
}
|
|
82
|
-
).toBe(true);
|
|
83
|
-
const { cookies } = await this.request.storageState();
|
|
84
|
-
const storageState = {
|
|
85
|
-
cookies,
|
|
86
|
-
nonce,
|
|
87
|
-
rootURL
|
|
88
|
-
};
|
|
89
|
-
if (this.storageStatePath) {
|
|
90
|
-
await fs.mkdir((0, import_path.dirname)(this.storageStatePath), { recursive: true });
|
|
91
|
-
await fs.writeFile(
|
|
92
|
-
this.storageStatePath,
|
|
93
|
-
JSON.stringify(storageState),
|
|
94
|
-
"utf-8"
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
this.storageState = storageState;
|
|
98
|
-
return storageState;
|
|
99
|
-
}
|
|
100
|
-
async function rest(options) {
|
|
101
|
-
const { path, ...fetchOptions } = options;
|
|
102
|
-
if (!path) {
|
|
103
|
-
throw new Error('"path" is required to make a REST call');
|
|
104
|
-
}
|
|
105
|
-
if (!this.storageState?.nonce || !this.storageState?.rootURL) {
|
|
106
|
-
await this.setupRest();
|
|
107
|
-
}
|
|
108
|
-
const relativePath = path.startsWith("/") ? path.slice(1) : path;
|
|
109
|
-
const url = this.storageState.rootURL + relativePath;
|
|
110
|
-
try {
|
|
111
|
-
const response = await this.request.fetch(url, {
|
|
112
|
-
...fetchOptions,
|
|
113
|
-
failOnStatusCode: false,
|
|
114
|
-
headers: {
|
|
115
|
-
"X-WP-Nonce": this.storageState.nonce,
|
|
116
|
-
...fetchOptions.headers || {}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
const json = await response.json();
|
|
120
|
-
if (!response.ok()) {
|
|
121
|
-
throw json;
|
|
122
|
-
}
|
|
123
|
-
return json;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
if (typeof error === "object" && error !== null && Object.prototype.hasOwnProperty.call(error, "code") && error.code === "rest_cookie_invalid_nonce") {
|
|
126
|
-
await this.setupRest();
|
|
127
|
-
return this.rest(options);
|
|
128
|
-
}
|
|
129
|
-
throw error;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async function getMaxBatchSize(forceRefetch = false) {
|
|
133
|
-
if (!forceRefetch && this.maxBatchSize) {
|
|
134
|
-
return this.maxBatchSize;
|
|
135
|
-
}
|
|
136
|
-
const response = await this.rest({
|
|
137
|
-
method: "OPTIONS",
|
|
138
|
-
path: "/batch/v1"
|
|
139
|
-
});
|
|
140
|
-
this.maxBatchSize = response.endpoints[0].args.requests.maxItems;
|
|
141
|
-
return this.maxBatchSize;
|
|
142
|
-
}
|
|
143
|
-
async function batchRest(requests) {
|
|
144
|
-
const maxBatchSize = await this.getMaxBatchSize();
|
|
145
|
-
if (requests.length > maxBatchSize) {
|
|
146
|
-
const chunks = splitRequestsToChunks(requests, maxBatchSize);
|
|
147
|
-
const chunkResponses = await Promise.all(
|
|
148
|
-
chunks.map(
|
|
149
|
-
(chunkRequests) => this.batchRest(chunkRequests)
|
|
150
|
-
)
|
|
151
|
-
);
|
|
152
|
-
return chunkResponses.flat();
|
|
153
|
-
}
|
|
154
|
-
const batchResponses = await this.rest({
|
|
155
|
-
method: "POST",
|
|
156
|
-
path: "/batch/v1",
|
|
157
|
-
data: {
|
|
158
|
-
requests,
|
|
159
|
-
validation: "require-all-validate"
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
if (batchResponses.failed) {
|
|
163
|
-
throw batchResponses;
|
|
164
|
-
}
|
|
165
|
-
return batchResponses.responses;
|
|
166
|
-
}
|
|
167
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
-
0 && (module.exports = {
|
|
169
|
-
batchRest,
|
|
170
|
-
getMaxBatchSize,
|
|
171
|
-
rest,
|
|
172
|
-
setupRest
|
|
173
|
-
});
|
|
174
|
-
//# sourceMappingURL=rest.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/rest.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as fs from 'fs/promises';\nimport { dirname } from 'path';\nimport { expect } from '@playwright/test';\nimport type { APIRequestContext } from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport { WP_BASE_URL } from '../config';\nimport type { RequestUtils, StorageState } from './index';\n\nfunction splitRequestsToChunks( requests: BatchRequest[], chunkSize: number ) {\n\tconst arr = [ ...requests ];\n\tconst cache = [];\n\twhile ( arr.length ) {\n\t\tcache.push( arr.splice( 0, chunkSize ) );\n\t}\n\n\treturn cache;\n}\n\nasync function getAPIRootURL( request: APIRequestContext ) {\n\t// Discover the API root url using link header.\n\t// See https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/#link-header\n\tconst response = await request.head( WP_BASE_URL );\n\tconst links = response.headers().link;\n\tconst restLink = links?.match( /<([^>]+)>; rel=\"https:\\/\\/api\\.w\\.org\\/\"/ );\n\n\tif ( ! restLink ) {\n\t\tthrow new Error( `Failed to discover REST API endpoint.\n Link header: ${ links }` );\n\t}\n\n\tconst [ , rootURL ] = restLink;\n\n\treturn rootURL;\n}\n\nasync function setupRest( this: RequestUtils ): Promise< StorageState > {\n\tlet nonce = '';\n\tlet rootURL = '';\n\n\t// Poll until the REST API is discovered.\n\t// See https://github.com/WordPress/gutenberg/issues/61627\n\tawait expect\n\t\t.poll(\n\t\t\tasync () => {\n\t\t\t\ttry {\n\t\t\t\t\t[ nonce, rootURL ] = await Promise.all( [\n\t\t\t\t\t\tthis.login(),\n\t\t\t\t\t\tgetAPIRootURL( this.request ),\n\t\t\t\t\t] );\n\t\t\t\t} catch ( error ) {\n\t\t\t\t\t// Prints the error if the timeout is reached.\n\t\t\t\t\treturn error;\n\t\t\t\t}\n\n\t\t\t\treturn !! ( nonce && rootURL );\n\t\t\t},\n\t\t\t{\n\t\t\t\tmessage: 'Failed to setup REST API.',\n\t\t\t\ttimeout: 60_000, // 1 minute.\n\t\t\t}\n\t\t)\n\t\t.toBe( true );\n\n\tconst { cookies } = await this.request.storageState();\n\n\tconst storageState: StorageState = {\n\t\tcookies,\n\t\tnonce,\n\t\trootURL,\n\t};\n\n\tif ( this.storageStatePath ) {\n\t\tawait fs.mkdir( dirname( this.storageStatePath ), { recursive: true } );\n\t\tawait fs.writeFile(\n\t\t\tthis.storageStatePath,\n\t\t\tJSON.stringify( storageState ),\n\t\t\t'utf-8'\n\t\t);\n\t}\n\n\tthis.storageState = storageState;\n\n\treturn storageState;\n}\n\ntype RequestFetchOptions = Exclude<\n\tParameters< APIRequestContext[ 'fetch' ] >[ 1 ],\n\tundefined\n>;\nexport interface RestOptions extends RequestFetchOptions {\n\tpath: string;\n}\n\nasync function rest< RestResponse = any >(\n\tthis: RequestUtils,\n\toptions: RestOptions\n): Promise< RestResponse > {\n\tconst { path, ...fetchOptions } = options;\n\n\tif ( ! path ) {\n\t\tthrow new Error( '\"path\" is required to make a REST call' );\n\t}\n\n\tif ( ! this.storageState?.nonce || ! this.storageState?.rootURL ) {\n\t\tawait this.setupRest();\n\t}\n\n\tconst relativePath = path.startsWith( '/' ) ? path.slice( 1 ) : path;\n\n\tconst url = this.storageState!.rootURL + relativePath;\n\n\ttry {\n\t\tconst response = await this.request.fetch( url, {\n\t\t\t...fetchOptions,\n\t\t\tfailOnStatusCode: false,\n\t\t\theaders: {\n\t\t\t\t'X-WP-Nonce': this.storageState!.nonce,\n\t\t\t\t...( fetchOptions.headers || {} ),\n\t\t\t},\n\t\t} );\n\t\tconst json: RestResponse = await response.json();\n\n\t\tif ( ! response.ok() ) {\n\t\t\tthrow json;\n\t\t}\n\n\t\treturn json;\n\t} catch ( error ) {\n\t\t// Nonce in invalid, retry again with a renewed nonce.\n\t\tif (\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\tObject.prototype.hasOwnProperty.call( error, 'code' ) &&\n\t\t\t( error as { code: string } ).code === 'rest_cookie_invalid_nonce'\n\t\t) {\n\t\t\tawait this.setupRest();\n\n\t\t\treturn this.rest( options );\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Get the maximum batch size for the REST API.\n *\n * @param this\n * @param forceRefetch Force revalidate the cached max batch size.\n */\nasync function getMaxBatchSize( this: RequestUtils, forceRefetch = false ) {\n\tif ( ! forceRefetch && this.maxBatchSize ) {\n\t\treturn this.maxBatchSize;\n\t}\n\n\tconst response = await this.rest< {\n\t\tendpoints: {\n\t\t\targs: {\n\t\t\t\trequests: {\n\t\t\t\t\tmaxItems: number;\n\t\t\t\t};\n\t\t\t};\n\t\t}[];\n\t} >( {\n\t\tmethod: 'OPTIONS',\n\t\tpath: '/batch/v1',\n\t} );\n\tthis.maxBatchSize = response.endpoints[ 0 ].args.requests.maxItems;\n\treturn this.maxBatchSize;\n}\n\nexport interface BatchRequest {\n\tmethod?: string;\n\tpath: string;\n\theaders?: Record< string, string | string[] >;\n\tbody?: any;\n}\n\nasync function batchRest< BatchResponse >(\n\tthis: RequestUtils,\n\trequests: BatchRequest[]\n): Promise< BatchResponse[] > {\n\tconst maxBatchSize = await this.getMaxBatchSize();\n\n\tif ( requests.length > maxBatchSize ) {\n\t\tconst chunks = splitRequestsToChunks( requests, maxBatchSize );\n\n\t\tconst chunkResponses = await Promise.all(\n\t\t\tchunks.map( ( chunkRequests ) =>\n\t\t\t\tthis.batchRest< BatchResponse >( chunkRequests )\n\t\t\t)\n\t\t);\n\n\t\treturn chunkResponses.flat();\n\t}\n\n\tconst batchResponses = await this.rest< {\n\t\tfailed?: string;\n\t\tresponses: BatchResponse[];\n\t} >( {\n\t\tmethod: 'POST',\n\t\tpath: '/batch/v1',\n\t\tdata: {\n\t\t\trequests,\n\t\t\tvalidation: 'require-all-validate',\n\t\t},\n\t} );\n\n\tif ( batchResponses.failed ) {\n\t\tthrow batchResponses;\n\t}\n\n\treturn batchResponses.responses;\n}\n\nexport { setupRest, rest, getMaxBatchSize, batchRest };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAoB;AACpB,kBAAwB;AACxB,kBAAuB;AAMvB,oBAA4B;AAG5B,SAAS,sBAAuB,UAA0B,WAAoB;AAC7E,QAAM,MAAM,CAAE,GAAG,QAAS;AAC1B,QAAM,QAAQ,CAAC;AACf,SAAQ,IAAI,QAAS;AACpB,UAAM,KAAM,IAAI,OAAQ,GAAG,SAAU,CAAE;AAAA,EACxC;AAEA,SAAO;AACR;AAEA,eAAe,cAAe,SAA6B;AAG1D,QAAM,WAAW,MAAM,QAAQ,KAAM,yBAAY;AACjD,QAAM,QAAQ,SAAS,QAAQ,EAAE;AACjC,QAAM,WAAW,OAAO,MAAO,0CAA2C;AAE1E,MAAK,CAAE,UAAW;AACjB,UAAM,IAAI,MAAO;AAAA,gBACF,KAAM,EAAG;AAAA,EACzB;AAEA,QA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
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.setupRest = setupRest;
|
|
37
|
-
exports.rest = rest;
|
|
38
|
-
exports.getMaxBatchSize = getMaxBatchSize;
|
|
39
|
-
exports.batchRest = batchRest;
|
|
40
|
-
/**
|
|
41
|
-
* External dependencies
|
|
42
|
-
*/
|
|
43
|
-
const fs = __importStar(require("fs/promises"));
|
|
44
|
-
const path_1 = require("path");
|
|
45
|
-
const test_1 = require("@playwright/test");
|
|
46
|
-
/**
|
|
47
|
-
* Internal dependencies
|
|
48
|
-
*/
|
|
49
|
-
const config_1 = require("../config");
|
|
50
|
-
function splitRequestsToChunks(requests, chunkSize) {
|
|
51
|
-
const arr = [...requests];
|
|
52
|
-
const cache = [];
|
|
53
|
-
while (arr.length) {
|
|
54
|
-
cache.push(arr.splice(0, chunkSize));
|
|
55
|
-
}
|
|
56
|
-
return cache;
|
|
57
|
-
}
|
|
58
|
-
async function getAPIRootURL(request) {
|
|
59
|
-
// Discover the API root url using link header.
|
|
60
|
-
// See https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/#link-header
|
|
61
|
-
const response = await request.head(config_1.WP_BASE_URL);
|
|
62
|
-
const links = response.headers().link;
|
|
63
|
-
const restLink = links?.match(/<([^>]+)>; rel="https:\/\/api\.w\.org\/"/);
|
|
64
|
-
if (!restLink) {
|
|
65
|
-
throw new Error(`Failed to discover REST API endpoint.
|
|
66
|
-
Link header: ${links}`);
|
|
67
|
-
}
|
|
68
|
-
const [, rootURL] = restLink;
|
|
69
|
-
return rootURL;
|
|
70
|
-
}
|
|
71
|
-
async function setupRest() {
|
|
72
|
-
let nonce = '';
|
|
73
|
-
let rootURL = '';
|
|
74
|
-
// Poll until the REST API is discovered.
|
|
75
|
-
// See https://github.com/WordPress/gutenberg/issues/61627
|
|
76
|
-
await test_1.expect
|
|
77
|
-
.poll(async () => {
|
|
78
|
-
try {
|
|
79
|
-
[nonce, rootURL] = await Promise.all([
|
|
80
|
-
this.login(),
|
|
81
|
-
getAPIRootURL(this.request),
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
// Prints the error if the timeout is reached.
|
|
86
|
-
return error;
|
|
87
|
-
}
|
|
88
|
-
return !!(nonce && rootURL);
|
|
89
|
-
}, {
|
|
90
|
-
message: 'Failed to setup REST API.',
|
|
91
|
-
timeout: 60_000, // 1 minute.
|
|
92
|
-
})
|
|
93
|
-
.toBe(true);
|
|
94
|
-
const { cookies } = await this.request.storageState();
|
|
95
|
-
const storageState = {
|
|
96
|
-
cookies,
|
|
97
|
-
nonce,
|
|
98
|
-
rootURL,
|
|
99
|
-
};
|
|
100
|
-
if (this.storageStatePath) {
|
|
101
|
-
await fs.mkdir((0, path_1.dirname)(this.storageStatePath), { recursive: true });
|
|
102
|
-
await fs.writeFile(this.storageStatePath, JSON.stringify(storageState), 'utf-8');
|
|
103
|
-
}
|
|
104
|
-
this.storageState = storageState;
|
|
105
|
-
return storageState;
|
|
106
|
-
}
|
|
107
|
-
async function rest(options) {
|
|
108
|
-
const { path, ...fetchOptions } = options;
|
|
109
|
-
if (!path) {
|
|
110
|
-
throw new Error('"path" is required to make a REST call');
|
|
111
|
-
}
|
|
112
|
-
if (!this.storageState?.nonce || !this.storageState?.rootURL) {
|
|
113
|
-
await this.setupRest();
|
|
114
|
-
}
|
|
115
|
-
const relativePath = path.startsWith('/') ? path.slice(1) : path;
|
|
116
|
-
const url = this.storageState.rootURL + relativePath;
|
|
117
|
-
try {
|
|
118
|
-
const response = await this.request.fetch(url, {
|
|
119
|
-
...fetchOptions,
|
|
120
|
-
failOnStatusCode: false,
|
|
121
|
-
headers: {
|
|
122
|
-
'X-WP-Nonce': this.storageState.nonce,
|
|
123
|
-
...(fetchOptions.headers || {}),
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
const json = await response.json();
|
|
127
|
-
if (!response.ok()) {
|
|
128
|
-
throw json;
|
|
129
|
-
}
|
|
130
|
-
return json;
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
// Nonce in invalid, retry again with a renewed nonce.
|
|
134
|
-
if (typeof error === 'object' &&
|
|
135
|
-
error !== null &&
|
|
136
|
-
Object.prototype.hasOwnProperty.call(error, 'code') &&
|
|
137
|
-
error.code === 'rest_cookie_invalid_nonce') {
|
|
138
|
-
await this.setupRest();
|
|
139
|
-
return this.rest(options);
|
|
140
|
-
}
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get the maximum batch size for the REST API.
|
|
146
|
-
*
|
|
147
|
-
* @param this
|
|
148
|
-
* @param forceRefetch Force revalidate the cached max batch size.
|
|
149
|
-
*/
|
|
150
|
-
async function getMaxBatchSize(forceRefetch = false) {
|
|
151
|
-
if (!forceRefetch && this.maxBatchSize) {
|
|
152
|
-
return this.maxBatchSize;
|
|
153
|
-
}
|
|
154
|
-
const response = await this.rest({
|
|
155
|
-
method: 'OPTIONS',
|
|
156
|
-
path: '/batch/v1',
|
|
157
|
-
});
|
|
158
|
-
this.maxBatchSize = response.endpoints[0].args.requests.maxItems;
|
|
159
|
-
return this.maxBatchSize;
|
|
160
|
-
}
|
|
161
|
-
async function batchRest(requests) {
|
|
162
|
-
const maxBatchSize = await this.getMaxBatchSize();
|
|
163
|
-
if (requests.length > maxBatchSize) {
|
|
164
|
-
const chunks = splitRequestsToChunks(requests, maxBatchSize);
|
|
165
|
-
const chunkResponses = await Promise.all(chunks.map((chunkRequests) => this.batchRest(chunkRequests)));
|
|
166
|
-
return chunkResponses.flat();
|
|
167
|
-
}
|
|
168
|
-
const batchResponses = await this.rest({
|
|
169
|
-
method: 'POST',
|
|
170
|
-
path: '/batch/v1',
|
|
171
|
-
data: {
|
|
172
|
-
requests,
|
|
173
|
-
validation: 'require-all-validate',
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
if (batchResponses.failed) {
|
|
177
|
-
throw batchResponses;
|
|
178
|
-
}
|
|
179
|
-
return batchResponses.responses;
|
|
180
|
-
}
|
|
181
|
-
//# sourceMappingURL=rest.js.map
|
|
@@ -1 +0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45 +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/site-settings.ts
|
|
21
|
-
var site_settings_exports = {};
|
|
22
|
-
__export(site_settings_exports, {
|
|
23
|
-
getSiteSettings: () => getSiteSettings,
|
|
24
|
-
updateSiteSettings: () => updateSiteSettings
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(site_settings_exports);
|
|
27
|
-
async function getSiteSettings() {
|
|
28
|
-
return await this.rest({
|
|
29
|
-
path: "/wp/v2/settings",
|
|
30
|
-
method: "GET"
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async function updateSiteSettings(siteSettings) {
|
|
34
|
-
return await this.rest({
|
|
35
|
-
path: "/wp/v2/settings",
|
|
36
|
-
method: "POST",
|
|
37
|
-
data: siteSettings
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
getSiteSettings,
|
|
43
|
-
updateSiteSettings
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=site-settings.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/site-settings.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\ntype SiteSettings = {\n\ttitle: string;\n\tdescription: string;\n\turl: string;\n\temail: string;\n\ttimezone: string;\n\tdate_format: string;\n\ttime_format: string;\n\tstart_of_week: number;\n\tlanguage: string;\n\tuse_smilies: boolean;\n\tdefault_category: number;\n\tdefault_post_format: string;\n\tposts_per_page: number;\n\tdefault_ping_status: 'open' | 'closed';\n\tdefault_comment_status: 'open' | 'closed';\n\tshow_on_front: 'posts' | 'page';\n\tpage_on_front: number;\n\tpage_for_posts: number;\n};\n\n/**\n * Get the site settings.\n *\n * @see https://developer.wordpress.org/rest-api/reference/settings/#retrieve-a-site-setting\n *\n * @param this RequestUtils.\n */\nexport async function getSiteSettings( this: RequestUtils ) {\n\treturn await this.rest< SiteSettings >( {\n\t\tpath: '/wp/v2/settings',\n\t\tmethod: 'GET',\n\t} );\n}\n\n/**\n * Update the site settings.\n *\n * @see https://developer.wordpress.org/rest-api/reference/settings/#update-a-site-setting\n *\n * @param this RequestUtils.\n * @param siteSettings The partial settings payload to update.\n */\nexport async function updateSiteSettings(\n\tthis: RequestUtils,\n\tsiteSettings: Partial< SiteSettings >\n) {\n\treturn await this.rest< SiteSettings >( {\n\t\tpath: '/wp/v2/settings',\n\t\tmethod: 'POST',\n\t\tdata: siteSettings,\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiCA,eAAsB,kBAAsC;AAC3D,SAAO,MAAM,KAAK,KAAsB;AAAA,IACvC,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AACH;AAUA,eAAsB,mBAErB,cACC;AACD,SAAO,MAAM,KAAK,KAAsB;AAAA,IACvC,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,EACP,CAAE;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSiteSettings = getSiteSettings;
|
|
4
|
-
exports.updateSiteSettings = updateSiteSettings;
|
|
5
|
-
/**
|
|
6
|
-
* Get the site settings.
|
|
7
|
-
*
|
|
8
|
-
* @see https://developer.wordpress.org/rest-api/reference/settings/#retrieve-a-site-setting
|
|
9
|
-
*
|
|
10
|
-
* @param this RequestUtils.
|
|
11
|
-
*/
|
|
12
|
-
async function getSiteSettings() {
|
|
13
|
-
return await this.rest({
|
|
14
|
-
path: '/wp/v2/settings',
|
|
15
|
-
method: 'GET',
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Update the site settings.
|
|
20
|
-
*
|
|
21
|
-
* @see https://developer.wordpress.org/rest-api/reference/settings/#update-a-site-setting
|
|
22
|
-
*
|
|
23
|
-
* @param this RequestUtils.
|
|
24
|
-
* @param siteSettings The partial settings payload to update.
|
|
25
|
-
*/
|
|
26
|
-
async function updateSiteSettings(siteSettings) {
|
|
27
|
-
return await this.rest({
|
|
28
|
-
path: '/wp/v2/settings',
|
|
29
|
-
method: 'POST',
|
|
30
|
-
data: siteSettings,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=site-settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site-settings.js","sourceRoot":"","sources":["../../src/request-utils/site-settings.ts"],"names":[],"mappings":";;;;AA0BA;;;;;;GAMG;AACI,KAAK;IACX,OAAO,MAAM,IAAI,CAAC,IAAI,CAAkB;QACvC,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;KACb,CAAE,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,6BAEX,YAAqC;IAErC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAkB;QACvC,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,YAAY;KAClB,CAAE,CAAC;AACL,CAAC"}
|