@wordpress/e2e-test-utils-playwright 1.37.0 → 1.37.1-next.79a2f3cdd.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/build/admin/create-new-post.cjs +51 -0
- package/build/admin/create-new-post.cjs.map +7 -0
- package/build/admin/create-new-post.js +28 -48
- package/build/admin/create-new-post.js.map +1 -7
- package/build/admin/edit-post.cjs +40 -0
- package/build/admin/edit-post.cjs.map +7 -0
- package/build/admin/edit-post.js +17 -37
- package/build/admin/edit-post.js.map +1 -7
- package/build/admin/get-page-error.cjs +36 -0
- package/build/admin/get-page-error.cjs.map +7 -0
- package/build/admin/get-page-error.js +23 -33
- package/build/admin/get-page-error.js.map +1 -7
- package/build/admin/index.cjs +59 -0
- package/build/admin/index.cjs.map +7 -0
- package/build/admin/index.js +36 -58
- package/build/admin/index.js.map +1 -7
- package/build/admin/visit-admin-page.cjs +47 -0
- package/build/admin/visit-admin-page.cjs.map +7 -0
- package/build/admin/visit-admin-page.js +29 -44
- package/build/admin/visit-admin-page.js.map +1 -7
- package/build/admin/visit-site-editor.cjs +77 -0
- package/build/admin/visit-site-editor.cjs.map +7 -0
- package/build/admin/visit-site-editor.js +64 -73
- package/build/admin/visit-site-editor.js.map +1 -7
- package/build/config.cjs +45 -0
- package/build/config.cjs.map +7 -0
- package/build/config.js +11 -43
- package/build/config.js.map +1 -7
- package/build/editor/click-block-options-menu-item.cjs +34 -0
- package/build/editor/click-block-options-menu-item.cjs.map +7 -0
- package/build/editor/click-block-options-menu-item.js +14 -31
- package/build/editor/click-block-options-menu-item.js.map +1 -7
- package/build/editor/click-block-toolbar-button.cjs +38 -0
- package/build/editor/click-block-toolbar-button.cjs.map +7 -0
- package/build/editor/click-block-toolbar-button.js +13 -35
- package/build/editor/click-block-toolbar-button.js.map +1 -7
- package/build/editor/get-blocks.cjs +64 -0
- package/build/editor/get-blocks.cjs.map +7 -0
- package/build/editor/get-blocks.js +43 -61
- package/build/editor/get-blocks.js.map +1 -7
- package/build/editor/get-edited-post-content.cjs +36 -0
- package/build/editor/get-edited-post-content.cjs.map +7 -0
- package/build/editor/get-edited-post-content.js +12 -33
- package/build/editor/get-edited-post-content.js.map +1 -7
- package/build/editor/index.cjs +97 -0
- package/build/editor/index.cjs.map +7 -0
- package/build/editor/index.js +74 -96
- package/build/editor/index.js.map +1 -7
- package/build/editor/insert-block.cjs +55 -0
- package/build/editor/insert-block.cjs.map +7 -0
- package/build/editor/insert-block.js +21 -52
- package/build/editor/insert-block.js.map +1 -7
- package/build/editor/open-document-settings-sidebar.cjs +42 -0
- package/build/editor/open-document-settings-sidebar.cjs.map +7 -0
- package/build/editor/open-document-settings-sidebar.js +24 -39
- package/build/editor/open-document-settings-sidebar.js.map +1 -7
- package/build/editor/preview.cjs +42 -0
- package/build/editor/preview.cjs.map +7 -0
- package/build/editor/preview.js +18 -39
- package/build/editor/preview.js.map +1 -7
- package/build/editor/publish-post.cjs +47 -0
- package/build/editor/publish-post.cjs.map +7 -0
- package/build/editor/publish-post.js +42 -44
- package/build/editor/publish-post.js.map +1 -7
- package/build/editor/save-draft.cjs +34 -0
- package/build/editor/save-draft.cjs.map +7 -0
- package/build/editor/save-draft.js +15 -31
- package/build/editor/save-draft.js.map +1 -7
- package/build/editor/select-blocks.cjs +51 -0
- package/build/editor/select-blocks.cjs.map +7 -0
- package/build/editor/select-blocks.js +25 -48
- package/build/editor/select-blocks.js.map +1 -7
- package/build/editor/set-content.cjs +39 -0
- package/build/editor/set-content.cjs.map +7 -0
- package/build/editor/set-content.js +14 -36
- package/build/editor/set-content.js.map +1 -7
- package/build/editor/set-is-fixed-toolbar.cjs +36 -0
- package/build/editor/set-is-fixed-toolbar.cjs.map +7 -0
- package/build/editor/set-is-fixed-toolbar.js +15 -33
- package/build/editor/set-is-fixed-toolbar.js.map +1 -7
- package/build/editor/set-preferences.cjs +43 -0
- package/build/editor/set-preferences.cjs.map +7 -0
- package/build/editor/set-preferences.js +18 -40
- package/build/editor/set-preferences.js.map +1 -7
- package/build/editor/show-block-toolbar.cjs +35 -0
- package/build/editor/show-block-toolbar.cjs.map +7 -0
- package/build/editor/show-block-toolbar.js +16 -32
- package/build/editor/show-block-toolbar.js.map +1 -7
- package/build/editor/site-editor.cjs +51 -0
- package/build/editor/site-editor.cjs.map +7 -0
- package/build/editor/site-editor.js +41 -48
- package/build/editor/site-editor.js.map +1 -7
- package/build/editor/switch-editor-tool.cjs +47 -0
- package/build/editor/switch-editor-tool.cjs.map +7 -0
- package/build/editor/switch-editor-tool.js +30 -44
- package/build/editor/switch-editor-tool.js.map +1 -7
- package/build/editor/switch-to-legacy-canvas.cjs +39 -0
- package/build/editor/switch-to-legacy-canvas.cjs.map +7 -0
- package/build/editor/switch-to-legacy-canvas.js +14 -35
- package/build/editor/switch-to-legacy-canvas.js.map +1 -7
- package/build/editor/transform-block-to.cjs +46 -0
- package/build/editor/transform-block-to.cjs.map +7 -0
- package/build/editor/transform-block-to.js +21 -43
- package/build/editor/transform-block-to.js.map +1 -7
- package/build/index.cjs +51 -0
- package/build/index.cjs.map +7 -0
- package/build/index.js +18 -53
- package/build/index.js.map +1 -7
- package/build/lighthouse/index.cjs +96 -0
- package/build/lighthouse/index.cjs.map +7 -0
- package/build/lighthouse/index.js +55 -93
- package/build/lighthouse/index.js.map +1 -7
- package/build/metrics/index.cjs +309 -0
- package/build/metrics/index.cjs.map +7 -0
- package/build/metrics/index.js +251 -302
- package/build/metrics/index.js.map +1 -7
- package/build/page-utils/drag-files.cjs +143 -0
- package/build/page-utils/drag-files.cjs.map +7 -0
- package/build/page-utils/drag-files.js +112 -136
- package/build/page-utils/drag-files.js.map +1 -7
- package/build/page-utils/emulate-network-conditions.cjs +99 -0
- package/build/page-utils/emulate-network-conditions.cjs.map +7 -0
- package/build/page-utils/emulate-network-conditions.js +67 -95
- package/build/page-utils/emulate-network-conditions.js.map +1 -7
- package/build/page-utils/index.cjs +59 -0
- package/build/page-utils/index.cjs.map +7 -0
- package/build/page-utils/index.js +36 -58
- package/build/page-utils/index.js.map +1 -7
- package/build/page-utils/is-current-url.cjs +36 -0
- package/build/page-utils/is-current-url.cjs.map +7 -0
- package/build/page-utils/is-current-url.js +18 -33
- package/build/page-utils/is-current-url.js.map +1 -7
- package/build/page-utils/keycodes.cjs +55 -0
- package/build/page-utils/keycodes.cjs.map +7 -0
- package/build/page-utils/keycodes.js +39 -53
- package/build/page-utils/keycodes.js.map +1 -7
- package/build/page-utils/press-keys.cjs +165 -0
- package/build/page-utils/press-keys.cjs.map +7 -0
- package/build/page-utils/press-keys.js +130 -153
- package/build/page-utils/press-keys.js.map +1 -7
- package/build/page-utils/set-browser-viewport.cjs +39 -0
- package/build/page-utils/set-browser-viewport.cjs.map +7 -0
- package/build/page-utils/set-browser-viewport.js +42 -35
- package/build/page-utils/set-browser-viewport.js.map +1 -7
- package/build/request-utils/blocks.cjs +56 -0
- package/build/request-utils/blocks.cjs.map +7 -0
- package/build/request-utils/blocks.js +40 -51
- package/build/request-utils/blocks.js.map +1 -7
- package/build/request-utils/comments.cjs +66 -0
- package/build/request-utils/comments.cjs.map +7 -0
- package/build/request-utils/comments.js +45 -59
- package/build/request-utils/comments.js.map +1 -7
- package/build/request-utils/gutenberg-experiments.cjs +66 -0
- package/build/request-utils/gutenberg-experiments.cjs.map +7 -0
- package/build/request-utils/gutenberg-experiments.js +38 -63
- package/build/request-utils/gutenberg-experiments.js.map +1 -7
- package/build/request-utils/index.cjs +194 -0
- package/build/request-utils/index.cjs.map +7 -0
- package/build/request-utils/index.js +155 -191
- package/build/request-utils/index.js.map +1 -7
- package/build/request-utils/login.cjs +48 -0
- package/build/request-utils/login.cjs.map +7 -0
- package/build/request-utils/login.js +18 -45
- package/build/request-utils/login.js.map +1 -7
- package/build/request-utils/media.cjs +83 -0
- package/build/request-utils/media.cjs.map +7 -0
- package/build/request-utils/media.js +64 -74
- package/build/request-utils/media.js.map +1 -7
- package/build/request-utils/menus.cjs +132 -0
- package/build/request-utils/menus.cjs.map +7 -0
- package/build/request-utils/menus.js +109 -121
- package/build/request-utils/menus.js.map +1 -7
- package/build/request-utils/pages.cjs +71 -0
- package/build/request-utils/pages.cjs.map +7 -0
- package/build/request-utils/pages.js +50 -63
- package/build/request-utils/pages.js.map +1 -7
- package/build/request-utils/patterns.cjs +44 -0
- package/build/request-utils/patterns.cjs.map +7 -0
- package/build/request-utils/patterns.js +24 -41
- package/build/request-utils/patterns.js.map +1 -7
- package/build/request-utils/plugins.cjs +81 -0
- package/build/request-utils/plugins.cjs.map +7 -0
- package/build/request-utils/plugins.js +74 -70
- package/build/request-utils/plugins.js.map +1 -7
- package/build/request-utils/posts.cjs +61 -0
- package/build/request-utils/posts.cjs.map +7 -0
- package/build/request-utils/posts.js +41 -55
- package/build/request-utils/posts.js.map +1 -7
- package/build/request-utils/preferences.cjs +41 -0
- package/build/request-utils/preferences.cjs.map +7 -0
- package/build/request-utils/preferences.js +17 -38
- package/build/request-utils/preferences.js.map +1 -7
- package/build/request-utils/rest.cjs +174 -0
- package/build/request-utils/rest.cjs.map +7 -0
- package/build/request-utils/rest.js +129 -155
- package/build/request-utils/rest.js.map +1 -7
- package/build/request-utils/site-settings.cjs +45 -0
- package/build/request-utils/site-settings.cjs.map +7 -0
- package/build/request-utils/site-settings.js +28 -40
- package/build/request-utils/site-settings.js.map +1 -7
- package/build/request-utils/templates.cjs +68 -0
- package/build/request-utils/templates.cjs.map +7 -0
- package/build/request-utils/templates.js +46 -60
- package/build/request-utils/templates.js.map +1 -7
- package/build/request-utils/themes.cjs +89 -0
- package/build/request-utils/themes.cjs.map +7 -0
- package/build/request-utils/themes.js +53 -80
- package/build/request-utils/themes.js.map +1 -7
- package/build/request-utils/users.cjs +83 -0
- package/build/request-utils/users.cjs.map +7 -0
- package/build/request-utils/users.js +72 -74
- package/build/request-utils/users.js.map +1 -7
- package/build/request-utils/widgets.cjs +79 -0
- package/build/request-utils/widgets.cjs.map +7 -0
- package/build/request-utils/widgets.js +55 -73
- package/build/request-utils/widgets.js.map +1 -7
- package/build/test.cjs +136 -0
- package/build/test.cjs.map +7 -0
- package/build/test.js +146 -130
- package/build/test.js.map +1 -7
- package/build/types.cjs +19 -0
- package/build/types.cjs.map +7 -0
- package/build/types.js +2 -18
- package/build/types.js.map +1 -7
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/package.json +7 -4
|
@@ -1,194 +1,158 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var RequestUtils = class {
|
|
58
|
-
request;
|
|
59
|
-
user;
|
|
60
|
-
maxBatchSize;
|
|
61
|
-
storageState;
|
|
62
|
-
storageStatePath;
|
|
63
|
-
baseURL;
|
|
64
|
-
pluginsMap = null;
|
|
65
|
-
static async setup({
|
|
66
|
-
user,
|
|
67
|
-
storageStatePath,
|
|
68
|
-
baseURL = import_config.WP_BASE_URL
|
|
69
|
-
}) {
|
|
70
|
-
let storageState;
|
|
71
|
-
if (storageStatePath) {
|
|
72
|
-
await fs.mkdir(path.dirname(storageStatePath), {
|
|
73
|
-
recursive: true
|
|
74
|
-
});
|
|
75
|
-
try {
|
|
76
|
-
storageState = JSON.parse(
|
|
77
|
-
await fs.readFile(storageStatePath, "utf-8")
|
|
78
|
-
);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
if (error instanceof Error && error.code === "ENOENT") {
|
|
81
|
-
} else {
|
|
82
|
-
throw error;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestUtils = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
const fs = require("fs/promises");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const test_1 = require("@playwright/test");
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
const config_1 = require("../config");
|
|
14
|
+
const login_1 = require("./login");
|
|
15
|
+
const media_1 = require("./media");
|
|
16
|
+
const users_1 = require("./users");
|
|
17
|
+
const rest_1 = require("./rest");
|
|
18
|
+
const plugins_1 = require("./plugins");
|
|
19
|
+
const templates_1 = require("./templates");
|
|
20
|
+
const themes_1 = require("./themes");
|
|
21
|
+
const blocks_1 = require("./blocks");
|
|
22
|
+
const comments_1 = require("./comments");
|
|
23
|
+
const posts_1 = require("./posts");
|
|
24
|
+
const menus_1 = require("./menus");
|
|
25
|
+
const pages_1 = require("./pages");
|
|
26
|
+
const preferences_1 = require("./preferences");
|
|
27
|
+
const site_settings_1 = require("./site-settings");
|
|
28
|
+
const widgets_1 = require("./widgets");
|
|
29
|
+
const patterns_1 = require("./patterns");
|
|
30
|
+
const gutenberg_experiments_1 = require("./gutenberg-experiments");
|
|
31
|
+
class RequestUtils {
|
|
32
|
+
request;
|
|
33
|
+
user;
|
|
34
|
+
maxBatchSize;
|
|
35
|
+
storageState;
|
|
36
|
+
storageStatePath;
|
|
37
|
+
baseURL;
|
|
38
|
+
pluginsMap = null;
|
|
39
|
+
static async setup({ user, storageStatePath, baseURL = config_1.WP_BASE_URL, }) {
|
|
40
|
+
let storageState;
|
|
41
|
+
if (storageStatePath) {
|
|
42
|
+
await fs.mkdir(path.dirname(storageStatePath), {
|
|
43
|
+
recursive: true,
|
|
44
|
+
});
|
|
45
|
+
try {
|
|
46
|
+
storageState = JSON.parse(await fs.readFile(storageStatePath, 'utf-8'));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error instanceof Error &&
|
|
50
|
+
error.code === 'ENOENT') {
|
|
51
|
+
// Ignore errors if the state is not found.
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
83
57
|
}
|
|
84
|
-
|
|
58
|
+
const requestContext = await test_1.request.newContext({
|
|
59
|
+
baseURL,
|
|
60
|
+
storageState: storageState && {
|
|
61
|
+
cookies: storageState.cookies,
|
|
62
|
+
origins: [],
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
const requestUtils = new this(requestContext, {
|
|
66
|
+
user,
|
|
67
|
+
storageState,
|
|
68
|
+
storageStatePath,
|
|
69
|
+
baseURL,
|
|
70
|
+
});
|
|
71
|
+
return requestUtils;
|
|
85
72
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
deleteAllUsers = import_users.deleteAllUsers.bind(this);
|
|
173
|
-
/** @borrows getSiteSettings as this.getSiteSettings */
|
|
174
|
-
getSiteSettings = import_site_settings.getSiteSettings.bind(this);
|
|
175
|
-
/** @borrows updateSiteSettings as this.updateSiteSettings */
|
|
176
|
-
updateSiteSettings = import_site_settings.updateSiteSettings.bind(this);
|
|
177
|
-
/** @borrows deleteAllPages as this.deleteAllPages */
|
|
178
|
-
deleteAllPages = import_pages.deleteAllPages.bind(this);
|
|
179
|
-
/** @borrows createPage as this.createPage */
|
|
180
|
-
createPage = import_pages.createPage.bind(this);
|
|
181
|
-
/** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
|
|
182
|
-
getCurrentThemeGlobalStylesPostId = import_themes.getCurrentThemeGlobalStylesPostId.bind(this);
|
|
183
|
-
/** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
|
|
184
|
-
getThemeGlobalStylesRevisions = import_themes.getThemeGlobalStylesRevisions.bind(this);
|
|
185
|
-
/** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
|
|
186
|
-
deleteAllPatternCategories = import_patterns.deleteAllPatternCategories.bind(this);
|
|
187
|
-
/** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
|
|
188
|
-
setGutenbergExperiments = import_gutenberg_experiments.setGutenbergExperiments.bind(this);
|
|
189
|
-
};
|
|
190
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
-
0 && (module.exports = {
|
|
192
|
-
RequestUtils
|
|
193
|
-
});
|
|
194
|
-
//# sourceMappingURL=index.js.map
|
|
73
|
+
constructor(requestContext, { user = config_1.WP_ADMIN_USER, storageState, storageStatePath, baseURL = config_1.WP_BASE_URL, } = {}) {
|
|
74
|
+
this.user = user;
|
|
75
|
+
this.request = requestContext;
|
|
76
|
+
this.storageStatePath = storageStatePath;
|
|
77
|
+
this.storageState = storageState;
|
|
78
|
+
this.baseURL = baseURL;
|
|
79
|
+
}
|
|
80
|
+
/** @borrows login as this.login */
|
|
81
|
+
login = login_1.login.bind(this);
|
|
82
|
+
/** @borrows setupRest as this.setupRest */
|
|
83
|
+
setupRest = rest_1.setupRest.bind(this);
|
|
84
|
+
// .bind() drops the generic types. Re-casting it to keep the type signature.
|
|
85
|
+
rest = rest_1.rest.bind(this);
|
|
86
|
+
/** @borrows getMaxBatchSize as this.getMaxBatchSize */
|
|
87
|
+
getMaxBatchSize = rest_1.getMaxBatchSize.bind(this);
|
|
88
|
+
// .bind() drops the generic types. Re-casting it to keep the type signature.
|
|
89
|
+
batchRest = rest_1.batchRest.bind(this);
|
|
90
|
+
/** @borrows getPluginsMap as this.getPluginsMap */
|
|
91
|
+
getPluginsMap = plugins_1.getPluginsMap.bind(this);
|
|
92
|
+
/** @borrows activatePlugin as this.activatePlugin */
|
|
93
|
+
activatePlugin = plugins_1.activatePlugin.bind(this);
|
|
94
|
+
/** @borrows deactivatePlugin as this.deactivatePlugin */
|
|
95
|
+
deactivatePlugin = plugins_1.deactivatePlugin.bind(this);
|
|
96
|
+
/** @borrows activateTheme as this.activateTheme */
|
|
97
|
+
activateTheme = themes_1.activateTheme.bind(this);
|
|
98
|
+
/** @borrows createBlock as this.createBlock */
|
|
99
|
+
createBlock = blocks_1.createBlock.bind(this);
|
|
100
|
+
/** @borrows deleteAllBlocks as this.deleteAllBlocks */
|
|
101
|
+
deleteAllBlocks = blocks_1.deleteAllBlocks.bind(this);
|
|
102
|
+
/** @borrows createPost as this.createPost */
|
|
103
|
+
createPost = posts_1.createPost.bind(this);
|
|
104
|
+
/** @borrows deleteAllPosts as this.deleteAllPosts */
|
|
105
|
+
deleteAllPosts = posts_1.deleteAllPosts.bind(this);
|
|
106
|
+
/** @borrows createClassicMenu as this.createClassicMenu */
|
|
107
|
+
createClassicMenu = menus_1.createClassicMenu.bind(this);
|
|
108
|
+
/** @borrows createNavigationMenu as this.createNavigationMenu */
|
|
109
|
+
createNavigationMenu = menus_1.createNavigationMenu.bind(this);
|
|
110
|
+
/** @borrows deleteAllMenus as this.deleteAllMenus */
|
|
111
|
+
deleteAllMenus = menus_1.deleteAllMenus.bind(this);
|
|
112
|
+
/** @borrows getNavigationMenus as this.getNavigationMenus */
|
|
113
|
+
getNavigationMenus = menus_1.getNavigationMenus.bind(this);
|
|
114
|
+
/** @borrows createComment as this.createComment */
|
|
115
|
+
createComment = comments_1.createComment.bind(this);
|
|
116
|
+
/** @borrows deleteAllComments as this.deleteAllComments */
|
|
117
|
+
deleteAllComments = comments_1.deleteAllComments.bind(this);
|
|
118
|
+
/** @borrows deleteAllWidgets as this.deleteAllWidgets */
|
|
119
|
+
deleteAllWidgets = widgets_1.deleteAllWidgets.bind(this);
|
|
120
|
+
/** @borrows addWidgetBlock as this.addWidgetBlock */
|
|
121
|
+
addWidgetBlock = widgets_1.addWidgetBlock.bind(this);
|
|
122
|
+
/** @borrows deleteAllTemplates as this.deleteAllTemplates */
|
|
123
|
+
deleteAllTemplates = templates_1.deleteAllTemplates.bind(this);
|
|
124
|
+
/** @borrows createTemplate as this.createTemplate */
|
|
125
|
+
createTemplate = templates_1.createTemplate.bind(this);
|
|
126
|
+
/** @borrows resetPreferences as this.resetPreferences */
|
|
127
|
+
resetPreferences = preferences_1.resetPreferences.bind(this);
|
|
128
|
+
/** @borrows listMedia as this.listMedia */
|
|
129
|
+
listMedia = media_1.listMedia.bind(this);
|
|
130
|
+
/** @borrows uploadMedia as this.uploadMedia */
|
|
131
|
+
uploadMedia = media_1.uploadMedia.bind(this);
|
|
132
|
+
/** @borrows deleteMedia as this.deleteMedia */
|
|
133
|
+
deleteMedia = media_1.deleteMedia.bind(this);
|
|
134
|
+
/** @borrows deleteAllMedia as this.deleteAllMedia */
|
|
135
|
+
deleteAllMedia = media_1.deleteAllMedia.bind(this);
|
|
136
|
+
/** @borrows createUser as this.createUser */
|
|
137
|
+
createUser = users_1.createUser.bind(this);
|
|
138
|
+
/** @borrows deleteAllUsers as this.deleteAllUsers */
|
|
139
|
+
deleteAllUsers = users_1.deleteAllUsers.bind(this);
|
|
140
|
+
/** @borrows getSiteSettings as this.getSiteSettings */
|
|
141
|
+
getSiteSettings = site_settings_1.getSiteSettings.bind(this);
|
|
142
|
+
/** @borrows updateSiteSettings as this.updateSiteSettings */
|
|
143
|
+
updateSiteSettings = site_settings_1.updateSiteSettings.bind(this);
|
|
144
|
+
/** @borrows deleteAllPages as this.deleteAllPages */
|
|
145
|
+
deleteAllPages = pages_1.deleteAllPages.bind(this);
|
|
146
|
+
/** @borrows createPage as this.createPage */
|
|
147
|
+
createPage = pages_1.createPage.bind(this);
|
|
148
|
+
/** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
|
|
149
|
+
getCurrentThemeGlobalStylesPostId = themes_1.getCurrentThemeGlobalStylesPostId.bind(this);
|
|
150
|
+
/** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
|
|
151
|
+
getThemeGlobalStylesRevisions = themes_1.getThemeGlobalStylesRevisions.bind(this);
|
|
152
|
+
/** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
|
|
153
|
+
deleteAllPatternCategories = patterns_1.deleteAllPatternCategories.bind(this);
|
|
154
|
+
/** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
|
|
155
|
+
setGutenbergExperiments = gutenberg_experiments_1.setGutenbergExperiments.bind(this);
|
|
156
|
+
}
|
|
157
|
+
exports.RequestUtils = RequestUtils;
|
|
158
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { request } from '@playwright/test';\nimport type { APIRequestContext, Cookie } from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport { WP_ADMIN_USER, WP_BASE_URL } from '../config';\nimport type { User } from './login';\nimport { login } from './login';\nimport { listMedia, uploadMedia, deleteMedia, deleteAllMedia } from './media';\nimport { createUser, deleteAllUsers } from './users';\nimport { setupRest, rest, getMaxBatchSize, batchRest } from './rest';\nimport { getPluginsMap, activatePlugin, deactivatePlugin } from './plugins';\nimport { deleteAllTemplates, createTemplate } from './templates';\nimport {\n\tactivateTheme,\n\tgetCurrentThemeGlobalStylesPostId,\n\tgetThemeGlobalStylesRevisions,\n} from './themes';\nimport { createBlock, deleteAllBlocks } from './blocks';\nimport { createComment, deleteAllComments } from './comments';\nimport { createPost, deleteAllPosts } from './posts';\nimport {\n\tcreateClassicMenu,\n\tcreateNavigationMenu,\n\tdeleteAllMenus,\n\tgetNavigationMenus,\n} from './menus';\nimport { deleteAllPages, createPage } from './pages';\nimport { resetPreferences } from './preferences';\nimport { getSiteSettings, updateSiteSettings } from './site-settings';\nimport { deleteAllWidgets, addWidgetBlock } from './widgets';\nimport { deleteAllPatternCategories } from './patterns';\nimport { setGutenbergExperiments } from './gutenberg-experiments';\n\ninterface StorageState {\n\tcookies: Cookie[];\n\tnonce: string;\n\trootURL: string;\n}\n\nclass RequestUtils {\n\trequest: APIRequestContext;\n\tuser: User;\n\tmaxBatchSize?: number;\n\tstorageState?: StorageState;\n\tstorageStatePath?: string;\n\tbaseURL?: string;\n\n\tpluginsMap: Record< string, string > | null = null;\n\n\tstatic async setup( {\n\t\tuser,\n\t\tstorageStatePath,\n\t\tbaseURL = WP_BASE_URL,\n\t}: {\n\t\tuser?: User;\n\t\tstorageStatePath?: string;\n\t\tbaseURL?: string;\n\t} ) {\n\t\tlet storageState: StorageState | undefined;\n\t\tif ( storageStatePath ) {\n\t\t\tawait fs.mkdir( path.dirname( storageStatePath ), {\n\t\t\t\trecursive: true,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tstorageState = JSON.parse(\n\t\t\t\t\tawait fs.readFile( storageStatePath, 'utf-8' )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t( error as NodeJS.ErrnoException ).code === 'ENOENT'\n\t\t\t\t) {\n\t\t\t\t\t// Ignore errors if the state is not found.\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst requestContext = await request.newContext( {\n\t\t\tbaseURL,\n\t\t\tstorageState: storageState && {\n\t\t\t\tcookies: storageState.cookies,\n\t\t\t\torigins: [],\n\t\t\t},\n\t\t} );\n\n\t\tconst requestUtils = new this( requestContext, {\n\t\t\tuser,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL,\n\t\t} );\n\n\t\treturn requestUtils;\n\t}\n\n\tconstructor(\n\t\trequestContext: APIRequestContext,\n\t\t{\n\t\t\tuser = WP_ADMIN_USER,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL = WP_BASE_URL,\n\t\t}: {\n\t\t\tuser?: User;\n\t\t\tstorageState?: StorageState;\n\t\t\tstorageStatePath?: string;\n\t\t\tbaseURL?: string;\n\t\t} = {}\n\t) {\n\t\tthis.user = user;\n\t\tthis.request = requestContext;\n\t\tthis.storageStatePath = storageStatePath;\n\t\tthis.storageState = storageState;\n\t\tthis.baseURL = baseURL;\n\t}\n\n\t/** @borrows login as this.login */\n\tlogin: typeof login = login.bind( this );\n\t/** @borrows setupRest as this.setupRest */\n\tsetupRest: typeof setupRest = setupRest.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\trest: typeof rest = rest.bind( this ) as typeof rest;\n\t/** @borrows getMaxBatchSize as this.getMaxBatchSize */\n\tgetMaxBatchSize: typeof getMaxBatchSize = getMaxBatchSize.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\tbatchRest: typeof batchRest = batchRest.bind( this ) as typeof batchRest;\n\t/** @borrows getPluginsMap as this.getPluginsMap */\n\tgetPluginsMap: typeof getPluginsMap = getPluginsMap.bind( this );\n\t/** @borrows activatePlugin as this.activatePlugin */\n\tactivatePlugin: typeof activatePlugin = activatePlugin.bind( this );\n\t/** @borrows deactivatePlugin as this.deactivatePlugin */\n\tdeactivatePlugin: typeof deactivatePlugin = deactivatePlugin.bind( this );\n\t/** @borrows activateTheme as this.activateTheme */\n\tactivateTheme: typeof activateTheme = activateTheme.bind( this );\n\t/** @borrows createBlock as this.createBlock */\n\tcreateBlock: typeof createBlock = createBlock.bind( this );\n\t/** @borrows deleteAllBlocks as this.deleteAllBlocks */\n\tdeleteAllBlocks = deleteAllBlocks.bind( this );\n\t/** @borrows createPost as this.createPost */\n\tcreatePost: typeof createPost = createPost.bind( this );\n\t/** @borrows deleteAllPosts as this.deleteAllPosts */\n\tdeleteAllPosts: typeof deleteAllPosts = deleteAllPosts.bind( this );\n\t/** @borrows createClassicMenu as this.createClassicMenu */\n\tcreateClassicMenu: typeof createClassicMenu =\n\t\tcreateClassicMenu.bind( this );\n\t/** @borrows createNavigationMenu as this.createNavigationMenu */\n\tcreateNavigationMenu: typeof createNavigationMenu =\n\t\tcreateNavigationMenu.bind( this );\n\t/** @borrows deleteAllMenus as this.deleteAllMenus */\n\tdeleteAllMenus: typeof deleteAllMenus = deleteAllMenus.bind( this );\n\t/** @borrows getNavigationMenus as this.getNavigationMenus */\n\tgetNavigationMenus: typeof getNavigationMenus =\n\t\tgetNavigationMenus.bind( this );\n\t/** @borrows createComment as this.createComment */\n\tcreateComment: typeof createComment = createComment.bind( this );\n\t/** @borrows deleteAllComments as this.deleteAllComments */\n\tdeleteAllComments: typeof deleteAllComments =\n\t\tdeleteAllComments.bind( this );\n\t/** @borrows deleteAllWidgets as this.deleteAllWidgets */\n\tdeleteAllWidgets: typeof deleteAllWidgets = deleteAllWidgets.bind( this );\n\t/** @borrows addWidgetBlock as this.addWidgetBlock */\n\taddWidgetBlock: typeof addWidgetBlock = addWidgetBlock.bind( this );\n\t/** @borrows deleteAllTemplates as this.deleteAllTemplates */\n\tdeleteAllTemplates: typeof deleteAllTemplates =\n\t\tdeleteAllTemplates.bind( this );\n\t/** @borrows createTemplate as this.createTemplate */\n\tcreateTemplate: typeof createTemplate = createTemplate.bind( this );\n\t/** @borrows resetPreferences as this.resetPreferences */\n\tresetPreferences: typeof resetPreferences = resetPreferences.bind( this );\n\t/** @borrows listMedia as this.listMedia */\n\tlistMedia: typeof listMedia = listMedia.bind( this );\n\t/** @borrows uploadMedia as this.uploadMedia */\n\tuploadMedia: typeof uploadMedia = uploadMedia.bind( this );\n\t/** @borrows deleteMedia as this.deleteMedia */\n\tdeleteMedia: typeof deleteMedia = deleteMedia.bind( this );\n\t/** @borrows deleteAllMedia as this.deleteAllMedia */\n\tdeleteAllMedia: typeof deleteAllMedia = deleteAllMedia.bind( this );\n\t/** @borrows createUser as this.createUser */\n\tcreateUser: typeof createUser = createUser.bind( this );\n\t/** @borrows deleteAllUsers as this.deleteAllUsers */\n\tdeleteAllUsers: typeof deleteAllUsers = deleteAllUsers.bind( this );\n\t/** @borrows getSiteSettings as this.getSiteSettings */\n\tgetSiteSettings: typeof getSiteSettings = getSiteSettings.bind( this );\n\t/** @borrows updateSiteSettings as this.updateSiteSettings */\n\tupdateSiteSettings: typeof updateSiteSettings =\n\t\tupdateSiteSettings.bind( this );\n\t/** @borrows deleteAllPages as this.deleteAllPages */\n\tdeleteAllPages: typeof deleteAllPages = deleteAllPages.bind( this );\n\t/** @borrows createPage as this.createPage */\n\tcreatePage: typeof createPage = createPage.bind( this );\n\t/** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */\n\tgetCurrentThemeGlobalStylesPostId: typeof getCurrentThemeGlobalStylesPostId =\n\t\tgetCurrentThemeGlobalStylesPostId.bind( this );\n\t/** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */\n\tgetThemeGlobalStylesRevisions: typeof getThemeGlobalStylesRevisions =\n\t\tgetThemeGlobalStylesRevisions.bind( this );\n\t/** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */\n\tdeleteAllPatternCategories = deleteAllPatternCategories.bind( this );\n\t/** @borrows setGutenbergExperiments as this.setGutenbergExperiments */\n\tsetGutenbergExperiments: typeof setGutenbergExperiments =\n\t\tsetGutenbergExperiments.bind( this );\n}\n\nexport type { StorageState };\nexport { RequestUtils };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAoB;AACpB,WAAsB;AACtB,kBAAwB;AAMxB,oBAA2C;AAE3C,mBAAsB;AACtB,mBAAoE;AACpE,mBAA2C;AAC3C,kBAA4D;AAC5D,qBAAgE;AAChE,uBAAmD;AACnD,oBAIO;AACP,oBAA6C;AAC7C,sBAAiD;AACjD,mBAA2C;AAC3C,mBAKO;AACP,mBAA2C;AAC3C,yBAAiC;AACjC,2BAAoD;AACpD,qBAAiD;AACjD,sBAA2C;AAC3C,mCA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AAiC,GAChC,0CAAiC,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAChD,mFAAmF;IACnF,6BAA6B,GAC5B,sCAA6B,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC5C,6EAA6E;IAC7E,0BAA0B,GAAG,qCAA0B,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrE,uEAAuE;IACvE,uBAAuB,GACtB,+CAAuB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;CACtC;AAGQ,oCAAY"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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/login.ts
|
|
21
|
+
var login_exports = {};
|
|
22
|
+
__export(login_exports, {
|
|
23
|
+
login: () => login
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(login_exports);
|
|
26
|
+
async function login(user = this.user) {
|
|
27
|
+
let response = await this.request.post("wp-login.php", {
|
|
28
|
+
failOnStatusCode: true,
|
|
29
|
+
form: {
|
|
30
|
+
log: user.username,
|
|
31
|
+
pwd: user.password
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
await response.dispose();
|
|
35
|
+
response = await this.request.get(
|
|
36
|
+
"wp-admin/admin-ajax.php?action=rest-nonce",
|
|
37
|
+
{
|
|
38
|
+
failOnStatusCode: true
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
const nonce = await response.text();
|
|
42
|
+
return nonce;
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
login
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=login.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/request-utils/login.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface User {\n\tusername: string;\n\tpassword: string;\n}\n\nasync function login( this: RequestUtils, user: User = this.user ) {\n\t// Login to admin using request context.\n\tlet response = await this.request.post( 'wp-login.php', {\n\t\tfailOnStatusCode: true,\n\t\tform: {\n\t\t\tlog: user.username,\n\t\t\tpwd: user.password,\n\t\t},\n\t} );\n\tawait response.dispose();\n\n\t// Get the nonce.\n\tresponse = await this.request.get(\n\t\t'wp-admin/admin-ajax.php?action=rest-nonce',\n\t\t{\n\t\t\tfailOnStatusCode: true,\n\t\t}\n\t);\n\tconst nonce = await response.text();\n\n\treturn nonce;\n}\n\nexport { login };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAe,MAA2B,OAAa,KAAK,MAAO;AAElE,MAAI,WAAW,MAAM,KAAK,QAAQ,KAAM,gBAAgB;AAAA,IACvD,kBAAkB;AAAA,IAClB,MAAM;AAAA,MACL,KAAK,KAAK;AAAA,MACV,KAAK,KAAK;AAAA,IACX;AAAA,EACD,CAAE;AACF,QAAM,SAAS,QAAQ;AAGvB,aAAW,MAAM,KAAK,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,MACC,kBAAkB;AAAA,IACnB;AAAA,EACD;AACA,QAAM,QAAQ,MAAM,SAAS,KAAK;AAElC,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,48 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
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/login.ts
|
|
21
|
-
var login_exports = {};
|
|
22
|
-
__export(login_exports, {
|
|
23
|
-
login: () => login
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(login_exports);
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.login = login;
|
|
26
4
|
async function login(user = this.user) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return nonce;
|
|
5
|
+
// Login to admin using request context.
|
|
6
|
+
let response = await this.request.post('wp-login.php', {
|
|
7
|
+
failOnStatusCode: true,
|
|
8
|
+
form: {
|
|
9
|
+
log: user.username,
|
|
10
|
+
pwd: user.password,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
await response.dispose();
|
|
14
|
+
// Get the nonce.
|
|
15
|
+
response = await this.request.get('wp-admin/admin-ajax.php?action=rest-nonce', {
|
|
16
|
+
failOnStatusCode: true,
|
|
17
|
+
});
|
|
18
|
+
const nonce = await response.text();
|
|
19
|
+
return nonce;
|
|
43
20
|
}
|
|
44
|
-
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
login
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=login.js.map
|
|
21
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/request-utils/login.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface User {\n\tusername: string;\n\tpassword: string;\n}\n\nasync function login( this: RequestUtils, user: User = this.user ) {\n\t// Login to admin using request context.\n\tlet response = await this.request.post( 'wp-login.php', {\n\t\tfailOnStatusCode: true,\n\t\tform: {\n\t\t\tlog: user.username,\n\t\t\tpwd: user.password,\n\t\t},\n\t} );\n\tawait response.dispose();\n\n\t// Get the nonce.\n\tresponse = await this.request.get(\n\t\t'wp-admin/admin-ajax.php?action=rest-nonce',\n\t\t{\n\t\t\tfailOnStatusCode: true,\n\t\t}\n\t);\n\tconst nonce = await response.text();\n\n\treturn nonce;\n}\n\nexport { login };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAe,MAA2B,OAAa,KAAK,MAAO;AAElE,MAAI,WAAW,MAAM,KAAK,QAAQ,KAAM,gBAAgB;AAAA,IACvD,kBAAkB;AAAA,IAClB,MAAM;AAAA,MACL,KAAK,KAAK;AAAA,MACV,KAAK,KAAK;AAAA,IACX;AAAA,EACD,CAAE;AACF,QAAM,SAAS,QAAQ;AAGvB,aAAW,MAAM,KAAK,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,MACC,kBAAkB;AAAA,IACnB;AAAA,EACD;AACA,QAAM,QAAQ,MAAM,SAAS,KAAK;AAElC,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/request-utils/login.ts"],"names":[],"mappings":";;AAiCS,sBAAK;AAvBd,KAAK,UAAU,KAAK,CAAsB,OAAa,IAAI,CAAC,IAAI;IAC/D,wCAAwC;IACxC,IAAI,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAE,cAAc,EAAE;QACvD,gBAAgB,EAAE,IAAI;QACtB,IAAI,EAAE;YACL,GAAG,EAAE,IAAI,CAAC,QAAQ;YAClB,GAAG,EAAE,IAAI,CAAC,QAAQ;SAClB;KACD,CAAE,CAAC;IACJ,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAEzB,iBAAiB;IACjB,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAChC,2CAA2C,EAC3C;QACC,gBAAgB,EAAE,IAAI;KACtB,CACD,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEpC,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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/media.ts
|
|
31
|
+
var media_exports = {};
|
|
32
|
+
__export(media_exports, {
|
|
33
|
+
deleteAllMedia: () => deleteAllMedia,
|
|
34
|
+
deleteMedia: () => deleteMedia,
|
|
35
|
+
listMedia: () => listMedia,
|
|
36
|
+
uploadMedia: () => uploadMedia
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(media_exports);
|
|
39
|
+
var fs = __toESM(require("fs"));
|
|
40
|
+
async function listMedia() {
|
|
41
|
+
const response = await this.rest({
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/wp/v2/media",
|
|
44
|
+
params: {
|
|
45
|
+
per_page: 100
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return response;
|
|
49
|
+
}
|
|
50
|
+
async function uploadMedia(filePathOrData) {
|
|
51
|
+
const file = typeof filePathOrData === "string" ? fs.createReadStream(filePathOrData) : filePathOrData;
|
|
52
|
+
const response = await this.rest({
|
|
53
|
+
method: "POST",
|
|
54
|
+
path: "/wp/v2/media",
|
|
55
|
+
multipart: {
|
|
56
|
+
file
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
async function deleteMedia(mediaId) {
|
|
62
|
+
const response = await this.rest({
|
|
63
|
+
method: "DELETE",
|
|
64
|
+
path: `/wp/v2/media/${mediaId}`,
|
|
65
|
+
params: { force: true }
|
|
66
|
+
});
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
async function deleteAllMedia() {
|
|
70
|
+
const files = await this.listMedia();
|
|
71
|
+
const responses = await Promise.all(
|
|
72
|
+
files.map((media) => this.deleteMedia(media.id))
|
|
73
|
+
);
|
|
74
|
+
return responses;
|
|
75
|
+
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
deleteAllMedia,
|
|
79
|
+
deleteMedia,
|
|
80
|
+
listMedia,
|
|
81
|
+
uploadMedia
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=media.cjs.map
|