@wordpress/e2e-test-utils-playwright 1.36.0 → 1.36.1-next.738bb1424.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/admin/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 +2 -2
|
@@ -1,83 +1,81 @@
|
|
|
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/users.ts
|
|
21
|
-
var users_exports = {};
|
|
22
|
-
__export(users_exports, {
|
|
23
|
-
createUser: () => createUser,
|
|
24
|
-
deleteAllUsers: () => deleteAllUsers
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(users_exports);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUser = createUser;
|
|
4
|
+
exports.deleteAllUsers = deleteAllUsers;
|
|
5
|
+
/**
|
|
6
|
+
* List all users.
|
|
7
|
+
*
|
|
8
|
+
* @see https://developer.wordpress.org/rest-api/reference/users/#list-users
|
|
9
|
+
* @param this
|
|
10
|
+
*/
|
|
27
11
|
async function listUsers() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
const response = await this.rest({
|
|
13
|
+
method: 'GET',
|
|
14
|
+
path: '/wp/v2/users',
|
|
15
|
+
params: {
|
|
16
|
+
per_page: 100,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return response;
|
|
36
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Add a test user.
|
|
23
|
+
*
|
|
24
|
+
* @see https://developer.wordpress.org/rest-api/reference/users/#create-a-user
|
|
25
|
+
* @param this
|
|
26
|
+
* @param user User data to create.
|
|
27
|
+
*/
|
|
37
28
|
async function createUser(user) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
const userData = {
|
|
30
|
+
username: user.username,
|
|
31
|
+
email: user.email,
|
|
32
|
+
};
|
|
33
|
+
if (user.firstName) {
|
|
34
|
+
userData.first_name = user.firstName;
|
|
35
|
+
}
|
|
36
|
+
if (user.lastName) {
|
|
37
|
+
userData.last_name = user.lastName;
|
|
38
|
+
}
|
|
39
|
+
if (user.password) {
|
|
40
|
+
userData.password = user.password;
|
|
41
|
+
}
|
|
42
|
+
if (user.roles) {
|
|
43
|
+
userData.roles = user.roles;
|
|
44
|
+
}
|
|
45
|
+
const response = await this.rest({
|
|
46
|
+
method: 'POST',
|
|
47
|
+
path: '/wp/v2/users',
|
|
48
|
+
data: userData,
|
|
49
|
+
});
|
|
50
|
+
return response;
|
|
60
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Delete a user.
|
|
54
|
+
*
|
|
55
|
+
* @see https://developer.wordpress.org/rest-api/reference/users/#delete-a-user
|
|
56
|
+
* @param this
|
|
57
|
+
* @param userId The ID of the user.
|
|
58
|
+
*/
|
|
61
59
|
async function deleteUser(userId) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
const response = await this.rest({
|
|
61
|
+
method: 'DELETE',
|
|
62
|
+
path: `/wp/v2/users/${userId}`,
|
|
63
|
+
params: { force: true, reassign: 1 },
|
|
64
|
+
});
|
|
65
|
+
return response;
|
|
68
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Delete all users except main root user.
|
|
69
|
+
*
|
|
70
|
+
* @param this
|
|
71
|
+
*/
|
|
69
72
|
async function deleteAllUsers() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const users = await listUsers.bind(this)();
|
|
74
|
+
// The users endpoint doesn't support batch request yet.
|
|
75
|
+
const responses = await Promise.all(users
|
|
76
|
+
// Do not delete neither root user nor the current user.
|
|
77
|
+
.filter((user) => user.id !== 1 && user.name !== this.user.username)
|
|
78
|
+
.map((user) => deleteUser.bind(this)(user.id)));
|
|
79
|
+
return responses;
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
0 && (module.exports = {
|
|
80
|
-
createUser,
|
|
81
|
-
deleteAllUsers
|
|
82
|
-
});
|
|
83
|
-
//# sourceMappingURL=users.js.map
|
|
81
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/users.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface User {\n\tid: number;\n\tname: string;\n\temail: string;\n}\n\nexport interface UserData {\n\tusername: string;\n\temail: string;\n\tfirstName?: string;\n\tlastName?: string;\n\tpassword?: string;\n\troles?: string[];\n}\n\nexport interface UserRequestData {\n\tusername: string;\n\temail: string;\n\tfirst_name?: string;\n\tlast_name?: string;\n\tpassword?: string;\n\troles?: string[];\n}\n\n/**\n * List all users.\n *\n * @see https://developer.wordpress.org/rest-api/reference/users/#list-users\n * @param this\n */\nasync function listUsers( this: RequestUtils ) {\n\tconst response = await this.rest< User[] >( {\n\t\tmethod: 'GET',\n\t\tpath: '/wp/v2/users',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t},\n\t} );\n\n\treturn response;\n}\n\n/**\n * Add a test user.\n *\n * @see https://developer.wordpress.org/rest-api/reference/users/#create-a-user\n * @param this\n * @param user User data to create.\n */\nasync function createUser( this: RequestUtils, user: UserData ) {\n\tconst userData: UserRequestData = {\n\t\tusername: user.username,\n\t\temail: user.email,\n\t};\n\n\tif ( user.firstName ) {\n\t\tuserData.first_name = user.firstName;\n\t}\n\n\tif ( user.lastName ) {\n\t\tuserData.last_name = user.lastName;\n\t}\n\n\tif ( user.password ) {\n\t\tuserData.password = user.password;\n\t}\n\n\tif ( user.roles ) {\n\t\tuserData.roles = user.roles;\n\t}\n\n\tconst response = await this.rest< User >( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/users',\n\t\tdata: userData,\n\t} );\n\n\treturn response;\n}\n\n/**\n * Delete a user.\n *\n * @see https://developer.wordpress.org/rest-api/reference/users/#delete-a-user\n * @param this\n * @param userId The ID of the user.\n */\nasync function deleteUser( this: RequestUtils, userId: number ) {\n\tconst response = await this.rest( {\n\t\tmethod: 'DELETE',\n\t\tpath: `/wp/v2/users/${ userId }`,\n\t\tparams: { force: true, reassign: 1 },\n\t} );\n\n\treturn response;\n}\n\n/**\n * Delete all users except main root user.\n *\n * @param this\n */\nasync function deleteAllUsers( this: RequestUtils ) {\n\tconst users = await listUsers.bind( this )();\n\n\t// The users endpoint doesn't support batch request yet.\n\tconst responses = await Promise.all(\n\t\tusers\n\t\t\t// Do not delete neither root user nor the current user.\n\t\t\t.filter(\n\t\t\t\t( user: User ) =>\n\t\t\t\t\tuser.id !== 1 && user.name !== this.user.username\n\t\t\t)\n\t\t\t.map( ( user: User ) => deleteUser.bind( this )( user.id ) )\n\t);\n\n\treturn responses;\n}\n\nexport { createUser, deleteAllUsers };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCA,eAAe,YAAgC;AAC9C,QAAM,WAAW,MAAM,KAAK,KAAgB;AAAA,IAC3C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,IACX;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AASA,eAAe,WAAgC,MAAiB;AAC/D,QAAM,WAA4B;AAAA,IACjC,UAAU,KAAK;AAAA,IACf,OAAO,KAAK;AAAA,EACb;AAEA,MAAK,KAAK,WAAY;AACrB,aAAS,aAAa,KAAK;AAAA,EAC5B;AAEA,MAAK,KAAK,UAAW;AACpB,aAAS,YAAY,KAAK;AAAA,EAC3B;AAEA,MAAK,KAAK,UAAW;AACpB,aAAS,WAAW,KAAK;AAAA,EAC1B;AAEA,MAAK,KAAK,OAAQ;AACjB,aAAS,QAAQ,KAAK;AAAA,EACvB;AAEA,QAAM,WAAW,MAAM,KAAK,KAAc;AAAA,IACzC,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EACP,CAAE;AAEF,SAAO;AACR;AASA,eAAe,WAAgC,QAAiB;AAC/D,QAAM,WAAW,MAAM,KAAK,KAAM;AAAA,IACjC,QAAQ;AAAA,IACR,MAAM,gBAAiB,MAAO;AAAA,IAC9B,QAAQ,EAAE,OAAO,MAAM,UAAU,EAAE;AAAA,EACpC,CAAE;AAEF,SAAO;AACR;AAOA,eAAe,iBAAqC;AACnD,QAAM,QAAQ,MAAM,UAAU,KAAM,IAAK,EAAE;AAG3C,QAAM,YAAY,MAAM,QAAQ;AAAA,IAC/B,MAEE;AAAA,MACA,CAAE,SACD,KAAK,OAAO,KAAK,KAAK,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AAI,EAAE,QAAQ;KACd,CAAE,CAAC;IAEJ,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,UAAU,CAAsB,MAAc;IAC5D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACjC,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,gBAAiB,MAAO,EAAE;QAChC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE;KACpC,CAAE,CAAC;IAEJ,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,IAAI,CAAE,IAAI,CAAE,EAAE,CAAC;IAE7C,wDAAwD;IACxD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAClC,KAAK;QACJ,wDAAwD;SACvD,MAAM,CACN,CAAE,IAAU,EAAG,EAAE,CAChB,IAAI,CAAC,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,CAClD;SACA,GAAG,CAAE,CAAE,IAAU,EAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAE,IAAI,CAAE,CAAE,IAAI,CAAC,EAAE,CAAE,CAAE,CAC7D,CAAC;IAEF,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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/widgets.js
|
|
21
|
+
var widgets_exports = {};
|
|
22
|
+
__export(widgets_exports, {
|
|
23
|
+
addWidgetBlock: () => addWidgetBlock,
|
|
24
|
+
deleteAllWidgets: () => deleteAllWidgets
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(widgets_exports);
|
|
27
|
+
async function deleteAllWidgets() {
|
|
28
|
+
const [widgets, sidebars] = await Promise.all([
|
|
29
|
+
this.rest({ path: "/wp/v2/widgets" }),
|
|
30
|
+
this.rest({ path: "/wp/v2/sidebars" })
|
|
31
|
+
]);
|
|
32
|
+
await this.batchRest(
|
|
33
|
+
widgets.map((widget) => ({
|
|
34
|
+
method: "DELETE",
|
|
35
|
+
path: `/wp/v2/widgets/${widget.id}?force=true`
|
|
36
|
+
}))
|
|
37
|
+
);
|
|
38
|
+
await Promise.all(
|
|
39
|
+
sidebars.map(
|
|
40
|
+
(sidebar) => this.rest({
|
|
41
|
+
method: "POST",
|
|
42
|
+
path: `/wp/v2/sidebars/${sidebar.id}`,
|
|
43
|
+
data: { id: sidebar.id, widgets: [] }
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
async function addWidgetBlock(serializedBlock, widgetAreaId) {
|
|
49
|
+
const { id: blockId } = await this.rest({
|
|
50
|
+
method: "POST",
|
|
51
|
+
path: "/wp/v2/widgets",
|
|
52
|
+
data: {
|
|
53
|
+
id_base: "block",
|
|
54
|
+
sidebar: widgetAreaId,
|
|
55
|
+
instance: {
|
|
56
|
+
raw: { content: serializedBlock }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const { widgets } = await this.rest({
|
|
61
|
+
path: `/wp/v2/sidebars/${widgetAreaId}`
|
|
62
|
+
});
|
|
63
|
+
const updatedWidgets = new Set(widgets);
|
|
64
|
+
updatedWidgets.delete(blockId);
|
|
65
|
+
updatedWidgets.add(blockId);
|
|
66
|
+
await this.rest({
|
|
67
|
+
method: "PUT",
|
|
68
|
+
path: `/wp/v2/sidebars/${widgetAreaId}`,
|
|
69
|
+
data: {
|
|
70
|
+
widgets: [...updatedWidgets]
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
addWidgetBlock,
|
|
77
|
+
deleteAllWidgets
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=widgets.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/request-utils/widgets.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Delete all the widgets in the widgets screen.\n *\n * @this {import('./index').RequestUtils}\n */\nexport async function deleteAllWidgets() {\n\tconst [ widgets, sidebars ] = await Promise.all( [\n\t\tthis.rest( { path: '/wp/v2/widgets' } ),\n\t\tthis.rest( { path: '/wp/v2/sidebars' } ),\n\t] );\n\n\tawait this.batchRest(\n\t\twidgets.map( ( widget ) => ( {\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: `/wp/v2/widgets/${ widget.id }?force=true`,\n\t\t} ) )\n\t);\n\n\t// The endpoint doesn't support batch requests yet.\n\tawait Promise.all(\n\t\tsidebars.map( ( sidebar ) =>\n\t\t\tthis.rest( {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tpath: `/wp/v2/sidebars/${ sidebar.id }`,\n\t\t\t\tdata: { id: sidebar.id, widgets: [] },\n\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Add a widget block to the widget area.\n *\n * @this {import('./index').RequestUtils}\n * @param {string} serializedBlock The serialized content of the inserted block HTML.\n * @param {string} widgetAreaId The ID of the widget area.\n */\nexport async function addWidgetBlock( serializedBlock, widgetAreaId ) {\n\tconst { id: blockId } = await this.rest( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/widgets',\n\t\tdata: {\n\t\t\tid_base: 'block',\n\t\t\tsidebar: widgetAreaId,\n\t\t\tinstance: {\n\t\t\t\traw: { content: serializedBlock },\n\t\t\t},\n\t\t},\n\t} );\n\n\tconst { widgets } = await this.rest( {\n\t\tpath: `/wp/v2/sidebars/${ widgetAreaId }`,\n\t} );\n\n\tconst updatedWidgets = new Set( widgets );\n\t// Remove duplicate.\n\tupdatedWidgets.delete( blockId );\n\t// Add to last block.\n\tupdatedWidgets.add( blockId );\n\n\tawait this.rest( {\n\t\tmethod: 'PUT',\n\t\tpath: `/wp/v2/sidebars/${ widgetAreaId }`,\n\t\tdata: {\n\t\t\twidgets: [ ...updatedWidgets ],\n\t\t},\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,eAAsB,mBAAmB;AACxC,QAAM,CAAE,SAAS,QAAS,IAAI,MAAM,QAAQ,IAAK;AAAA,IAChD,KAAK,KAAM,EAAE,MAAM,iBAAiB,CAAE;AAAA,IACtC,KAAK,KAAM,EAAE,MAAM,kBAAkB,CAAE;AAAA,EACxC,CAAE;AAEF,QAAM,KAAK;AAAA,IACV,QAAQ,IAAK,CAAE,YAAc;AAAA,MAC5B,QAAQ;AAAA,MACR,MAAM,kBAAmB,OAAO,EAAG;AAAA,IACpC,EAAI;AAAA,EACL;AAGA,QAAM,QAAQ;AAAA,IACb,SAAS;AAAA,MAAK,CAAE,YACf,KAAK,KAAM;AAAA,QACV,QAAQ;AAAA,QACR,MAAM,mBAAoB,QAAQ,EAAG;AAAA,QACrC,MAAM,EAAE,IAAI,QAAQ,IAAI,SAAS,CAAC,EAAE;AAAA,MACrC,CAAE;AAAA,IACH;AAAA,EACD;AACD;AASA,eAAsB,eAAgB,iBAAiB,cAAe;AACrE,QAAM,EAAE,IAAI,QAAQ,IAAI,MAAM,KAAK,KAAM;AAAA,IACxC,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,UAAU;AAAA,QACT,KAAK,EAAE,SAAS,gBAAgB;AAAA,MACjC;AAAA,IACD;AAAA,EACD,CAAE;AAEF,QAAM,EAAE,QAAQ,IAAI,MAAM,KAAK,KAAM;AAAA,IACpC,MAAM,mBAAoB,YAAa;AAAA,EACxC,CAAE;AAEF,QAAM,iBAAiB,IAAI,IAAK,OAAQ;AAExC,iBAAe,OAAQ,OAAQ;AAE/B,iBAAe,IAAK,OAAQ;AAE5B,QAAM,KAAK,KAAM;AAAA,IAChB,QAAQ;AAAA,IACR,MAAM,mBAAoB,YAAa;AAAA,IACvC,MAAM;AAAA,MACL,SAAS,CAAE,GAAG,cAAe;AAAA,IAC9B;AAAA,EACD,CAAE;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,79 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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/widgets.js
|
|
21
|
-
var widgets_exports = {};
|
|
22
|
-
__export(widgets_exports, {
|
|
23
|
-
addWidgetBlock: () => addWidgetBlock,
|
|
24
|
-
deleteAllWidgets: () => deleteAllWidgets
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(widgets_exports);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteAllWidgets = deleteAllWidgets;
|
|
4
|
+
exports.addWidgetBlock = addWidgetBlock;
|
|
5
|
+
/**
|
|
6
|
+
* Delete all the widgets in the widgets screen.
|
|
7
|
+
*
|
|
8
|
+
* @this {import('./index').RequestUtils}
|
|
9
|
+
*/
|
|
27
10
|
async function deleteAllWidgets() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
sidebars.map(
|
|
40
|
-
(sidebar) => this.rest({
|
|
41
|
-
method: "POST",
|
|
11
|
+
const [widgets, sidebars] = await Promise.all([
|
|
12
|
+
this.rest({ path: '/wp/v2/widgets' }),
|
|
13
|
+
this.rest({ path: '/wp/v2/sidebars' }),
|
|
14
|
+
]);
|
|
15
|
+
await this.batchRest(widgets.map((widget) => ({
|
|
16
|
+
method: 'DELETE',
|
|
17
|
+
path: `/wp/v2/widgets/${widget.id}?force=true`,
|
|
18
|
+
})));
|
|
19
|
+
// The endpoint doesn't support batch requests yet.
|
|
20
|
+
await Promise.all(sidebars.map((sidebar) => this.rest({
|
|
21
|
+
method: 'POST',
|
|
42
22
|
path: `/wp/v2/sidebars/${sidebar.id}`,
|
|
43
|
-
data: { id: sidebar.id, widgets: [] }
|
|
44
|
-
|
|
45
|
-
)
|
|
46
|
-
);
|
|
23
|
+
data: { id: sidebar.id, widgets: [] },
|
|
24
|
+
})));
|
|
47
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Add a widget block to the widget area.
|
|
28
|
+
*
|
|
29
|
+
* @this {import('./index').RequestUtils}
|
|
30
|
+
* @param {string} serializedBlock The serialized content of the inserted block HTML.
|
|
31
|
+
* @param {string} widgetAreaId The ID of the widget area.
|
|
32
|
+
*/
|
|
48
33
|
async function addWidgetBlock(serializedBlock, widgetAreaId) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
34
|
+
const { id: blockId } = await this.rest({
|
|
35
|
+
method: 'POST',
|
|
36
|
+
path: '/wp/v2/widgets',
|
|
37
|
+
data: {
|
|
38
|
+
id_base: 'block',
|
|
39
|
+
sidebar: widgetAreaId,
|
|
40
|
+
instance: {
|
|
41
|
+
raw: { content: serializedBlock },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
const { widgets } = await this.rest({
|
|
46
|
+
path: `/wp/v2/sidebars/${widgetAreaId}`,
|
|
47
|
+
});
|
|
48
|
+
const updatedWidgets = new Set(widgets);
|
|
49
|
+
// Remove duplicate.
|
|
50
|
+
updatedWidgets.delete(blockId);
|
|
51
|
+
// Add to last block.
|
|
52
|
+
updatedWidgets.add(blockId);
|
|
53
|
+
await this.rest({
|
|
54
|
+
method: 'PUT',
|
|
55
|
+
path: `/wp/v2/sidebars/${widgetAreaId}`,
|
|
56
|
+
data: {
|
|
57
|
+
widgets: [...updatedWidgets],
|
|
58
|
+
},
|
|
59
|
+
});
|
|
73
60
|
}
|
|
74
|
-
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
addWidgetBlock,
|
|
77
|
-
deleteAllWidgets
|
|
78
|
-
});
|
|
79
|
-
//# sourceMappingURL=widgets.js.map
|
|
61
|
+
//# sourceMappingURL=widgets.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/widgets.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Delete all the widgets in the widgets screen.\n *\n * @this {import('./index').RequestUtils}\n */\nexport async function deleteAllWidgets() {\n\tconst [ widgets, sidebars ] = await Promise.all( [\n\t\tthis.rest( { path: '/wp/v2/widgets' } ),\n\t\tthis.rest( { path: '/wp/v2/sidebars' } ),\n\t] );\n\n\tawait this.batchRest(\n\t\twidgets.map( ( widget ) => ( {\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: `/wp/v2/widgets/${ widget.id }?force=true`,\n\t\t} ) )\n\t);\n\n\t// The endpoint doesn't support batch requests yet.\n\tawait Promise.all(\n\t\tsidebars.map( ( sidebar ) =>\n\t\t\tthis.rest( {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tpath: `/wp/v2/sidebars/${ sidebar.id }`,\n\t\t\t\tdata: { id: sidebar.id, widgets: [] },\n\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Add a widget block to the widget area.\n *\n * @this {import('./index').RequestUtils}\n * @param {string} serializedBlock The serialized content of the inserted block HTML.\n * @param {string} widgetAreaId The ID of the widget area.\n */\nexport async function addWidgetBlock( serializedBlock, widgetAreaId ) {\n\tconst { id: blockId } = await this.rest( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/widgets',\n\t\tdata: {\n\t\t\tid_base: 'block',\n\t\t\tsidebar: widgetAreaId,\n\t\t\tinstance: {\n\t\t\t\traw: { content: serializedBlock },\n\t\t\t},\n\t\t},\n\t} );\n\n\tconst { widgets } = await this.rest( {\n\t\tpath: `/wp/v2/sidebars/${ widgetAreaId }`,\n\t} );\n\n\tconst updatedWidgets = new Set( widgets );\n\t// Remove duplicate.\n\tupdatedWidgets.delete( blockId );\n\t// Add to last block.\n\tupdatedWidgets.add( blockId );\n\n\tawait this.rest( {\n\t\tmethod: 'PUT',\n\t\tpath: `/wp/v2/sidebars/${ widgetAreaId }`,\n\t\tdata: {\n\t\t\twidgets: [ ...updatedWidgets ],\n\t\t},\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,eAAsB,mBAAmB;AACxC,QAAM,CAAE,SAAS,QAAS,IAAI,MAAM,QAAQ,IAAK;AAAA,IAChD,KAAK,KAAM,EAAE,MAAM,iBAAiB,CAAE;AAAA,IACtC,KAAK,KAAM,EAAE,MAAM,kBAAkB,CAAE;AAAA,EACxC,CAAE;AAEF,QAAM,KAAK;AAAA,IACV,QAAQ,IAAK,CAAE,YAAc;AAAA,MAC5B,QAAQ;AAAA,MACR,MAAM,kBAAmB,OAAO,EAAG;AAAA,IACpC,EAAI;AAAA,EACL;AAGA,QAAM,QAAQ;AAAA,IACb,SAAS;AAAA,MAAK,CAAE,YACf,KAAK,KAAM;AAAA,QACV,QAAQ;AAAA,QACR,MAAM,mBAAoB,QAAQ,EAAG;AAAA,QACrC,MAAM,EAAE,IAAI,QAAQ,IAAI,SAAS,CAAC,EAAE;AAAA,MACrC,CAAE;AAAA,IACH;AAAA,EACD;AACD;AASA,eAAsB,eAAgB,iBAAiB,cAAe;AACrE,QAAM,EAAE,IAAI,QAAQ,IAAI,MAAM,KAAK,KAAM;AAAA,IACxC,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,MACL,SAAS;AAAA,MACT,SAAS;AAAA,MACT,UAAU;AAAA,QACT,KAAK,EAAE,SAAS,gBAAgB;AAAA,MACjC;AAAA,IACD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EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;KACrC,CAAE,CACH,CACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAAE,eAAe,EAAE,YAAY;IAClE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACxC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,YAAY;YACrB,QAAQ,EAAE;gBACT,GAAG,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE;aACjC;SACD;KACD,CAAE,CAAC;IAEJ,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACpC,IAAI,EAAE,mBAAoB,YAAa,EAAE;KACzC,CAAE,CAAC;IAEJ,MAAM,cAAc,GAAG,IAAI,GAAG,CAAE,OAAO,CAAE,CAAC;IAC1C,oBAAoB;IACpB,cAAc,CAAC,MAAM,CAAE,OAAO,CAAE,CAAC;IACjC,qBAAqB;IACrB,cAAc,CAAC,GAAG,CAAE,OAAO,CAAE,CAAC;IAE9B,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAoB,YAAa,EAAE;QACzC,IAAI,EAAE;YACL,OAAO,EAAE,CAAE,GAAG,cAAc,CAAE;SAC9B;KACD,CAAE,CAAC;AACL,CAAC"}
|
package/build/test.cjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
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/test.ts
|
|
31
|
+
var test_exports = {};
|
|
32
|
+
__export(test_exports, {
|
|
33
|
+
expect: () => import_test.expect,
|
|
34
|
+
test: () => test
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(test_exports);
|
|
37
|
+
var path = __toESM(require("path"));
|
|
38
|
+
var import_test = require("@playwright/test");
|
|
39
|
+
var import_get_port = __toESM(require("get-port"));
|
|
40
|
+
var import_index = require("./index.cjs");
|
|
41
|
+
var STORAGE_STATE_PATH = process.env.STORAGE_STATE_PATH || path.join(process.cwd(), "artifacts/storage-states/admin.json");
|
|
42
|
+
var OBSERVED_CONSOLE_MESSAGE_TYPES = ["warn", "error"];
|
|
43
|
+
function observeConsoleLogging(message) {
|
|
44
|
+
const type = message.type();
|
|
45
|
+
if (!OBSERVED_CONSOLE_MESSAGE_TYPES.includes(
|
|
46
|
+
type
|
|
47
|
+
)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const text = message.text();
|
|
51
|
+
if (text.includes("This is a global warning")) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (text.includes("A cookie associated with a cross-site resource") || text.includes(
|
|
55
|
+
"https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite"
|
|
56
|
+
)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (text.includes("net::ERR_UNKNOWN_URL_SCHEME")) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (text.includes("elements with non-unique id #_wpnonce")) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (text.includes("JQMIGRATE")) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (text.includes("Layout was forced before the page was fully loaded")) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (text.includes("MouseEvent.moz")) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const logFunction = type;
|
|
75
|
+
console[logFunction](text);
|
|
76
|
+
}
|
|
77
|
+
var test = import_test.test.extend({
|
|
78
|
+
admin: async ({ page, pageUtils, editor }, use) => {
|
|
79
|
+
await use(new import_index.Admin({ page, pageUtils, editor }));
|
|
80
|
+
},
|
|
81
|
+
editor: async ({ page }, use) => {
|
|
82
|
+
await use(new import_index.Editor({ page }));
|
|
83
|
+
},
|
|
84
|
+
page: async ({ page }, use) => {
|
|
85
|
+
page.on("console", observeConsoleLogging);
|
|
86
|
+
await use(page);
|
|
87
|
+
try {
|
|
88
|
+
await page.evaluate(() => {
|
|
89
|
+
window.localStorage.clear();
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
}
|
|
93
|
+
await page.close();
|
|
94
|
+
},
|
|
95
|
+
pageUtils: async ({ page, browserName }, use) => {
|
|
96
|
+
await use(new import_index.PageUtils({ page, browserName }));
|
|
97
|
+
},
|
|
98
|
+
requestUtils: [
|
|
99
|
+
async ({}, use, workerInfo) => {
|
|
100
|
+
const requestUtils = await import_index.RequestUtils.setup({
|
|
101
|
+
baseURL: workerInfo.project.use.baseURL,
|
|
102
|
+
storageStatePath: STORAGE_STATE_PATH
|
|
103
|
+
});
|
|
104
|
+
await use(requestUtils);
|
|
105
|
+
},
|
|
106
|
+
{ scope: "worker", auto: true }
|
|
107
|
+
],
|
|
108
|
+
// Spins up a new browser for use by the Lighthouse fixture
|
|
109
|
+
// so that Lighthouse can connect to the debugging port.
|
|
110
|
+
// As a worker-scoped fixture, this will only launch 1
|
|
111
|
+
// instance for the whole test worker, so multiple tests
|
|
112
|
+
// will share the same instance with the same port.
|
|
113
|
+
lighthousePort: [
|
|
114
|
+
async ({}, use) => {
|
|
115
|
+
const port = await (0, import_get_port.default)();
|
|
116
|
+
const browser = await import_test.chromium.launch({
|
|
117
|
+
args: [`--remote-debugging-port=${port}`]
|
|
118
|
+
});
|
|
119
|
+
await use(port);
|
|
120
|
+
await browser.close();
|
|
121
|
+
},
|
|
122
|
+
{ scope: "worker" }
|
|
123
|
+
],
|
|
124
|
+
lighthouse: async ({ page, lighthousePort }, use) => {
|
|
125
|
+
await use(new import_index.Lighthouse({ page, port: lighthousePort }));
|
|
126
|
+
},
|
|
127
|
+
metrics: async ({ page }, use) => {
|
|
128
|
+
await use(new import_index.Metrics({ page }));
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
expect,
|
|
134
|
+
test
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=test.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as path from 'path';\nimport { test as base, expect, chromium } from '@playwright/test';\nimport type { ConsoleMessage } from '@playwright/test';\nimport getPort from 'get-port';\n\n/**\n * Internal dependencies\n */\nimport {\n\tAdmin,\n\tEditor,\n\tPageUtils,\n\tRequestUtils,\n\tMetrics,\n\tLighthouse,\n} from './index';\n\nconst STORAGE_STATE_PATH =\n\tprocess.env.STORAGE_STATE_PATH ||\n\tpath.join( process.cwd(), 'artifacts/storage-states/admin.json' );\n\n/**\n * Set of console logging types observed to protect against unexpected yet\n * handled (i.e. not catastrophic) errors or warnings. Each key corresponds\n * to the Playwright ConsoleMessage type, its value the corresponding function\n * on the console global object.\n */\nconst OBSERVED_CONSOLE_MESSAGE_TYPES = [ 'warn', 'error' ] as const;\n\n/**\n * Adds a page event handler to emit uncaught exception to process if one of\n * the observed console logging types is encountered.\n *\n * @param message The console message.\n */\nfunction observeConsoleLogging( message: ConsoleMessage ) {\n\tconst type = message.type();\n\tif (\n\t\t! OBSERVED_CONSOLE_MESSAGE_TYPES.includes(\n\t\t\ttype as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ]\n\t\t)\n\t) {\n\t\treturn;\n\t}\n\n\tconst text = message.text();\n\n\t// An exception is made for _blanket_ deprecation warnings: Those\n\t// which log regardless of whether a deprecated feature is in use.\n\tif ( text.includes( 'This is a global warning' ) ) {\n\t\treturn;\n\t}\n\n\t// A chrome advisory warning about SameSite cookies is informational\n\t// about future changes, tracked separately for improvement in core.\n\t//\n\t// See: https://core.trac.wordpress.org/ticket/37000\n\t// See: https://www.chromestatus.com/feature/5088147346030592\n\t// See: https://www.chromestatus.com/feature/5633521622188032\n\tif (\n\t\ttext.includes( 'A cookie associated with a cross-site resource' ) ||\n\t\ttext.includes(\n\t\t\t'https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite'\n\t\t)\n\t) {\n\t\treturn;\n\t}\n\n\t// Viewing posts on the front end can result in this error, which\n\t// has nothing to do with Gutenberg.\n\tif ( text.includes( 'net::ERR_UNKNOWN_URL_SCHEME' ) ) {\n\t\treturn;\n\t}\n\n\t// TODO: Not implemented yet.\n\t// Network errors are ignored only if we are intentionally testing\n\t// offline mode.\n\t// if (\n\t// \ttext.includes( 'net::ERR_INTERNET_DISCONNECTED' ) &&\n\t// \tisOfflineMode()\n\t// ) {\n\t// \treturn;\n\t// }\n\n\t// As of WordPress 5.3.2 in Chrome 79, navigating to the block editor\n\t// (Posts > Add New) will display a console warning about\n\t// non - unique IDs.\n\t// See: https://core.trac.wordpress.org/ticket/23165\n\tif ( text.includes( 'elements with non-unique id #_wpnonce' ) ) {\n\t\treturn;\n\t}\n\n\t// Ignore all JQMIGRATE (jQuery migrate) deprecation warnings.\n\tif ( text.includes( 'JQMIGRATE' ) ) {\n\t\treturn;\n\t}\n\n\t// https://bugzilla.mozilla.org/show_bug.cgi?id=1404468\n\tif (\n\t\ttext.includes( 'Layout was forced before the page was fully loaded' )\n\t) {\n\t\treturn;\n\t}\n\n\t// Deprecated warnings coming from the third-party libraries.\n\tif ( text.includes( 'MouseEvent.moz' ) ) {\n\t\treturn;\n\t}\n\n\tconst logFunction =\n\t\ttype as ( typeof OBSERVED_CONSOLE_MESSAGE_TYPES )[ number ];\n\n\t// Disable reason: We intentionally bubble up the console message\n\t// which, unless the test explicitly anticipates the logging via\n\t// @wordpress/jest-console matchers, will cause the intended test\n\t// failure.\n\t// eslint-disable-next-line no-console\n\tconsole[ logFunction ]( text );\n}\n\nconst test = base.extend<\n\t{\n\t\tadmin: Admin;\n\t\teditor: Editor;\n\t\tpageUtils: PageUtils;\n\t\tsnapshotConfig: void;\n\t\tmetrics: Metrics;\n\t\tlighthouse: Lighthouse;\n\t},\n\t{\n\t\trequestUtils: RequestUtils;\n\t\tlighthousePort: number;\n\t}\n>( {\n\tadmin: async ( { page, pageUtils, editor }, use ) => {\n\t\tawait use( new Admin( { page, pageUtils, editor } ) );\n\t},\n\teditor: async ( { page }, use ) => {\n\t\tawait use( new Editor( { page } ) );\n\t},\n\tpage: async ( { page }, use ) => {\n\t\tpage.on( 'console', observeConsoleLogging );\n\n\t\tawait use( page );\n\n\t\t// Clear local storage after each test.\n\t\t// This needs to be wrapped with a try/catch because it can fail when\n\t\t// the test is skipped (e.g. via fixme).\n\t\ttry {\n\t\t\tawait page.evaluate( () => {\n\t\t\t\twindow.localStorage.clear();\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// noop.\n\t\t}\n\n\t\tawait page.close();\n\t},\n\tpageUtils: async ( { page, browserName }, use ) => {\n\t\tawait use( new PageUtils( { page, browserName } ) );\n\t},\n\trequestUtils: [\n\t\tasync ( {}, use, workerInfo ) => {\n\t\t\tconst requestUtils = await RequestUtils.setup( {\n\t\t\t\tbaseURL: workerInfo.project.use.baseURL,\n\t\t\t\tstorageStatePath: STORAGE_STATE_PATH,\n\t\t\t} );\n\n\t\t\tawait use( requestUtils );\n\t\t},\n\t\t{ scope: 'worker', auto: true },\n\t],\n\t// Spins up a new browser for use by the Lighthouse fixture\n\t// so that Lighthouse can connect to the debugging port.\n\t// As a worker-scoped fixture, this will only launch 1\n\t// instance for the whole test worker, so multiple tests\n\t// will share the same instance with the same port.\n\tlighthousePort: [\n\t\tasync ( {}, use ) => {\n\t\t\tconst port = await getPort();\n\t\t\tconst browser = await chromium.launch( {\n\t\t\t\targs: [ `--remote-debugging-port=${ port }` ],\n\t\t\t} );\n\n\t\t\tawait use( port );\n\n\t\t\tawait browser.close();\n\t\t},\n\t\t{ scope: 'worker' },\n\t],\n\tlighthouse: async ( { page, lighthousePort }, use ) => {\n\t\tawait use( new Lighthouse( { page, port: lighthousePort } ) );\n\t},\n\tmetrics: async ( { page }, use ) => {\n\t\tawait use( new Metrics( { page } ) );\n\t},\n} );\n\nexport { test, expect };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;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