@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.
Files changed (295) hide show
  1. package/build-types/admin/index.d.ts +3 -0
  2. package/build-types/admin/index.d.ts.map +1 -1
  3. package/build-types/admin/visit-site-editor.d.ts.map +1 -1
  4. package/build-types/admin/wait-for-site-editor.d.ts +12 -0
  5. package/build-types/admin/wait-for-site-editor.d.ts.map +1 -0
  6. package/build-types/metrics/index.d.ts +22 -5
  7. package/build-types/metrics/index.d.ts.map +1 -1
  8. package/build-types/request-utils/index.d.ts +3 -1
  9. package/build-types/request-utils/index.d.ts.map +1 -1
  10. package/build-types/request-utils/preferences.d.ts +11 -0
  11. package/build-types/request-utils/preferences.d.ts.map +1 -1
  12. package/package.json +4 -5
  13. package/src/admin/create-new-post.ts +47 -0
  14. package/src/admin/edit-post.ts +24 -0
  15. package/{build/admin/get-page-error.js → src/admin/get-page-error.ts} +12 -9
  16. package/src/admin/index.ts +52 -0
  17. package/src/admin/visit-admin-page.ts +43 -0
  18. package/src/admin/visit-site-editor.ts +62 -0
  19. package/src/admin/wait-for-site-editor.ts +52 -0
  20. package/src/config.ts +12 -0
  21. package/src/editor/click-block-options-menu-item.ts +18 -0
  22. package/src/editor/click-block-toolbar-button.ts +21 -0
  23. package/src/editor/get-blocks.ts +75 -0
  24. package/src/editor/get-edited-post-content.ts +19 -0
  25. package/src/editor/index.ts +95 -0
  26. package/src/editor/insert-block.ts +54 -0
  27. package/src/editor/open-document-settings-sidebar.ts +31 -0
  28. package/src/editor/preview.ts +32 -0
  29. package/src/editor/publish-post.ts +51 -0
  30. package/src/editor/save-draft.ts +20 -0
  31. package/src/editor/select-blocks.ts +48 -0
  32. package/src/editor/set-content.ts +24 -0
  33. package/src/editor/set-is-fixed-toolbar.ts +20 -0
  34. package/src/editor/set-preferences.ts +37 -0
  35. package/src/editor/show-block-toolbar.ts +20 -0
  36. package/src/editor/site-editor.ts +55 -0
  37. package/src/editor/switch-editor-tool.ts +34 -0
  38. package/src/editor/switch-to-legacy-canvas.ts +20 -0
  39. package/src/editor/transform-block-to.ts +34 -0
  40. package/src/index.ts +8 -0
  41. package/src/lighthouse/index.ts +75 -0
  42. package/src/metrics/index.ts +441 -0
  43. package/src/page-utils/drag-files.ts +173 -0
  44. package/src/page-utils/emulate-network-conditions.ts +101 -0
  45. package/src/page-utils/index.ts +54 -0
  46. package/src/page-utils/is-current-url.ts +20 -0
  47. package/src/page-utils/keycodes.ts +48 -0
  48. package/src/page-utils/press-keys.ts +195 -0
  49. package/{build → src}/page-utils/set-browser-viewport.js +14 -12
  50. package/src/request-utils/blocks.ts +58 -0
  51. package/src/request-utils/comments.ts +80 -0
  52. package/src/request-utils/gutenberg-experiments.ts +62 -0
  53. package/src/request-utils/index.ts +222 -0
  54. package/src/request-utils/login.ts +34 -0
  55. package/src/request-utils/media.ts +102 -0
  56. package/src/request-utils/menus.ts +145 -0
  57. package/src/request-utils/pages.ts +75 -0
  58. package/src/request-utils/patterns.ts +31 -0
  59. package/src/request-utils/plugins.ts +103 -0
  60. package/src/request-utils/posts.ts +69 -0
  61. package/src/request-utils/preferences.ts +63 -0
  62. package/{build/request-utils/records.js → src/request-utils/records.ts} +15 -10
  63. package/src/request-utils/rest.ts +222 -0
  64. package/src/request-utils/site-settings.ts +58 -0
  65. package/src/request-utils/templates.ts +83 -0
  66. package/src/request-utils/themes.ts +110 -0
  67. package/src/request-utils/users.ts +125 -0
  68. package/src/request-utils/widgets.js +68 -0
  69. package/src/test.ts +204 -0
  70. package/src/types.ts +13 -0
  71. package/build/admin/create-new-post.cjs +0 -51
  72. package/build/admin/create-new-post.cjs.map +0 -7
  73. package/build/admin/create-new-post.js +0 -31
  74. package/build/admin/create-new-post.js.map +0 -1
  75. package/build/admin/edit-post.cjs +0 -40
  76. package/build/admin/edit-post.cjs.map +0 -7
  77. package/build/admin/edit-post.js +0 -20
  78. package/build/admin/edit-post.js.map +0 -1
  79. package/build/admin/get-page-error.cjs +0 -36
  80. package/build/admin/get-page-error.cjs.map +0 -7
  81. package/build/admin/get-page-error.js.map +0 -1
  82. package/build/admin/index.cjs +0 -59
  83. package/build/admin/index.cjs.map +0 -7
  84. package/build/admin/index.js +0 -37
  85. package/build/admin/index.js.map +0 -1
  86. package/build/admin/visit-admin-page.cjs +0 -47
  87. package/build/admin/visit-admin-page.cjs.map +0 -7
  88. package/build/admin/visit-admin-page.js +0 -32
  89. package/build/admin/visit-admin-page.js.map +0 -1
  90. package/build/admin/visit-site-editor.cjs +0 -90
  91. package/build/admin/visit-site-editor.cjs.map +0 -7
  92. package/build/admin/visit-site-editor.js +0 -73
  93. package/build/admin/visit-site-editor.js.map +0 -1
  94. package/build/config.cjs +0 -45
  95. package/build/config.cjs.map +0 -7
  96. package/build/config.js +0 -13
  97. package/build/config.js.map +0 -1
  98. package/build/editor/click-block-options-menu-item.cjs +0 -34
  99. package/build/editor/click-block-options-menu-item.cjs.map +0 -7
  100. package/build/editor/click-block-options-menu-item.js +0 -17
  101. package/build/editor/click-block-options-menu-item.js.map +0 -1
  102. package/build/editor/click-block-toolbar-button.cjs +0 -38
  103. package/build/editor/click-block-toolbar-button.cjs.map +0 -7
  104. package/build/editor/click-block-toolbar-button.js +0 -16
  105. package/build/editor/click-block-toolbar-button.js.map +0 -1
  106. package/build/editor/get-blocks.cjs +0 -64
  107. package/build/editor/get-blocks.cjs.map +0 -7
  108. package/build/editor/get-blocks.js +0 -45
  109. package/build/editor/get-blocks.js.map +0 -1
  110. package/build/editor/get-edited-post-content.cjs +0 -36
  111. package/build/editor/get-edited-post-content.cjs.map +0 -7
  112. package/build/editor/get-edited-post-content.js +0 -15
  113. package/build/editor/get-edited-post-content.js.map +0 -1
  114. package/build/editor/index.cjs +0 -97
  115. package/build/editor/index.cjs.map +0 -7
  116. package/build/editor/index.js +0 -75
  117. package/build/editor/index.js.map +0 -1
  118. package/build/editor/insert-block.cjs +0 -55
  119. package/build/editor/insert-block.cjs.map +0 -7
  120. package/build/editor/insert-block.js +0 -23
  121. package/build/editor/insert-block.js.map +0 -1
  122. package/build/editor/open-document-settings-sidebar.cjs +0 -42
  123. package/build/editor/open-document-settings-sidebar.cjs.map +0 -7
  124. package/build/editor/open-document-settings-sidebar.js +0 -27
  125. package/build/editor/open-document-settings-sidebar.js.map +0 -1
  126. package/build/editor/preview.cjs +0 -42
  127. package/build/editor/preview.cjs.map +0 -7
  128. package/build/editor/preview.js +0 -21
  129. package/build/editor/preview.js.map +0 -1
  130. package/build/editor/publish-post.cjs +0 -47
  131. package/build/editor/publish-post.cjs.map +0 -7
  132. package/build/editor/publish-post.js +0 -45
  133. package/build/editor/publish-post.js.map +0 -1
  134. package/build/editor/save-draft.cjs +0 -34
  135. package/build/editor/save-draft.cjs.map +0 -7
  136. package/build/editor/save-draft.js +0 -18
  137. package/build/editor/save-draft.js.map +0 -1
  138. package/build/editor/select-blocks.cjs +0 -51
  139. package/build/editor/select-blocks.cjs.map +0 -7
  140. package/build/editor/select-blocks.js +0 -28
  141. package/build/editor/select-blocks.js.map +0 -1
  142. package/build/editor/set-content.cjs +0 -39
  143. package/build/editor/set-content.cjs.map +0 -7
  144. package/build/editor/set-content.js +0 -17
  145. package/build/editor/set-content.js.map +0 -1
  146. package/build/editor/set-is-fixed-toolbar.cjs +0 -36
  147. package/build/editor/set-is-fixed-toolbar.cjs.map +0 -7
  148. package/build/editor/set-is-fixed-toolbar.js +0 -18
  149. package/build/editor/set-is-fixed-toolbar.js.map +0 -1
  150. package/build/editor/set-preferences.cjs +0 -43
  151. package/build/editor/set-preferences.cjs.map +0 -7
  152. package/build/editor/set-preferences.js +0 -21
  153. package/build/editor/set-preferences.js.map +0 -1
  154. package/build/editor/show-block-toolbar.cjs +0 -35
  155. package/build/editor/show-block-toolbar.cjs.map +0 -7
  156. package/build/editor/show-block-toolbar.js +0 -19
  157. package/build/editor/show-block-toolbar.js.map +0 -1
  158. package/build/editor/site-editor.cjs +0 -51
  159. package/build/editor/site-editor.cjs.map +0 -7
  160. package/build/editor/site-editor.js +0 -44
  161. package/build/editor/site-editor.js.map +0 -1
  162. package/build/editor/switch-editor-tool.cjs +0 -47
  163. package/build/editor/switch-editor-tool.cjs.map +0 -7
  164. package/build/editor/switch-editor-tool.js +0 -33
  165. package/build/editor/switch-editor-tool.js.map +0 -1
  166. package/build/editor/switch-to-legacy-canvas.cjs +0 -39
  167. package/build/editor/switch-to-legacy-canvas.cjs.map +0 -7
  168. package/build/editor/switch-to-legacy-canvas.js +0 -18
  169. package/build/editor/switch-to-legacy-canvas.js.map +0 -1
  170. package/build/editor/transform-block-to.cjs +0 -46
  171. package/build/editor/transform-block-to.cjs.map +0 -7
  172. package/build/editor/transform-block-to.js +0 -24
  173. package/build/editor/transform-block-to.js.map +0 -1
  174. package/build/index.cjs +0 -51
  175. package/build/index.cjs.map +0 -7
  176. package/build/index.js +0 -19
  177. package/build/index.js.map +0 -1
  178. package/build/lighthouse/index.cjs +0 -96
  179. package/build/lighthouse/index.cjs.map +0 -7
  180. package/build/lighthouse/index.js +0 -61
  181. package/build/lighthouse/index.js.map +0 -1
  182. package/build/metrics/index.cjs +0 -309
  183. package/build/metrics/index.cjs.map +0 -7
  184. package/build/metrics/index.js +0 -258
  185. package/build/metrics/index.js.map +0 -1
  186. package/build/page-utils/drag-files.cjs +0 -143
  187. package/build/page-utils/drag-files.cjs.map +0 -7
  188. package/build/page-utils/drag-files.js +0 -119
  189. package/build/page-utils/drag-files.js.map +0 -1
  190. package/build/page-utils/emulate-network-conditions.cjs +0 -99
  191. package/build/page-utils/emulate-network-conditions.cjs.map +0 -7
  192. package/build/page-utils/emulate-network-conditions.js +0 -71
  193. package/build/page-utils/emulate-network-conditions.js.map +0 -1
  194. package/build/page-utils/index.cjs +0 -59
  195. package/build/page-utils/index.cjs.map +0 -7
  196. package/build/page-utils/index.js +0 -37
  197. package/build/page-utils/index.js.map +0 -1
  198. package/build/page-utils/is-current-url.cjs +0 -36
  199. package/build/page-utils/is-current-url.cjs.map +0 -7
  200. package/build/page-utils/is-current-url.js +0 -21
  201. package/build/page-utils/is-current-url.js.map +0 -1
  202. package/build/page-utils/keycodes.cjs +0 -55
  203. package/build/page-utils/keycodes.cjs.map +0 -7
  204. package/build/page-utils/keycodes.js +0 -41
  205. package/build/page-utils/keycodes.js.map +0 -1
  206. package/build/page-utils/press-keys.cjs +0 -165
  207. package/build/page-utils/press-keys.cjs.map +0 -7
  208. package/build/page-utils/press-keys.js +0 -141
  209. package/build/page-utils/press-keys.js.map +0 -1
  210. package/build/page-utils/set-browser-viewport.cjs +0 -39
  211. package/build/page-utils/set-browser-viewport.cjs.map +0 -7
  212. package/build/page-utils/set-browser-viewport.js.map +0 -1
  213. package/build/request-utils/blocks.cjs +0 -51
  214. package/build/request-utils/blocks.cjs.map +0 -7
  215. package/build/request-utils/blocks.js +0 -40
  216. package/build/request-utils/blocks.js.map +0 -1
  217. package/build/request-utils/comments.cjs +0 -66
  218. package/build/request-utils/comments.cjs.map +0 -7
  219. package/build/request-utils/comments.js +0 -52
  220. package/build/request-utils/comments.js.map +0 -1
  221. package/build/request-utils/gutenberg-experiments.cjs +0 -56
  222. package/build/request-utils/gutenberg-experiments.cjs.map +0 -7
  223. package/build/request-utils/gutenberg-experiments.js +0 -47
  224. package/build/request-utils/gutenberg-experiments.js.map +0 -1
  225. package/build/request-utils/index.cjs +0 -199
  226. package/build/request-utils/index.cjs.map +0 -7
  227. package/build/request-utils/index.js +0 -194
  228. package/build/request-utils/index.js.map +0 -1
  229. package/build/request-utils/login.cjs +0 -48
  230. package/build/request-utils/login.cjs.map +0 -7
  231. package/build/request-utils/login.js +0 -21
  232. package/build/request-utils/login.js.map +0 -1
  233. package/build/request-utils/media.cjs +0 -83
  234. package/build/request-utils/media.cjs.map +0 -7
  235. package/build/request-utils/media.js +0 -106
  236. package/build/request-utils/media.js.map +0 -1
  237. package/build/request-utils/menus.cjs +0 -128
  238. package/build/request-utils/menus.cjs.map +0 -7
  239. package/build/request-utils/menus.js +0 -116
  240. package/build/request-utils/menus.js.map +0 -1
  241. package/build/request-utils/pages.cjs +0 -66
  242. package/build/request-utils/pages.cjs.map +0 -7
  243. package/build/request-utils/pages.js +0 -53
  244. package/build/request-utils/pages.js.map +0 -1
  245. package/build/request-utils/patterns.cjs +0 -44
  246. package/build/request-utils/patterns.cjs.map +0 -7
  247. package/build/request-utils/patterns.js +0 -27
  248. package/build/request-utils/patterns.js.map +0 -1
  249. package/build/request-utils/plugins.cjs +0 -81
  250. package/build/request-utils/plugins.cjs.map +0 -7
  251. package/build/request-utils/plugins.js +0 -85
  252. package/build/request-utils/plugins.js.map +0 -1
  253. package/build/request-utils/posts.cjs +0 -56
  254. package/build/request-utils/posts.cjs.map +0 -7
  255. package/build/request-utils/posts.js +0 -42
  256. package/build/request-utils/posts.js.map +0 -1
  257. package/build/request-utils/preferences.cjs +0 -41
  258. package/build/request-utils/preferences.cjs.map +0 -7
  259. package/build/request-utils/preferences.js +0 -20
  260. package/build/request-utils/preferences.js.map +0 -1
  261. package/build/request-utils/records.cjs +0 -37
  262. package/build/request-utils/records.cjs.map +0 -7
  263. package/build/request-utils/records.js.map +0 -1
  264. package/build/request-utils/rest.cjs +0 -174
  265. package/build/request-utils/rest.cjs.map +0 -7
  266. package/build/request-utils/rest.js +0 -181
  267. package/build/request-utils/rest.js.map +0 -1
  268. package/build/request-utils/site-settings.cjs +0 -45
  269. package/build/request-utils/site-settings.cjs.map +0 -7
  270. package/build/request-utils/site-settings.js +0 -33
  271. package/build/request-utils/site-settings.js.map +0 -1
  272. package/build/request-utils/templates.cjs +0 -68
  273. package/build/request-utils/templates.cjs.map +0 -7
  274. package/build/request-utils/templates.js +0 -54
  275. package/build/request-utils/templates.js.map +0 -1
  276. package/build/request-utils/themes.cjs +0 -92
  277. package/build/request-utils/themes.cjs.map +0 -7
  278. package/build/request-utils/themes.js +0 -69
  279. package/build/request-utils/themes.js.map +0 -1
  280. package/build/request-utils/users.cjs +0 -83
  281. package/build/request-utils/users.cjs.map +0 -7
  282. package/build/request-utils/users.js +0 -81
  283. package/build/request-utils/users.js.map +0 -1
  284. package/build/request-utils/widgets.cjs +0 -79
  285. package/build/request-utils/widgets.cjs.map +0 -7
  286. package/build/request-utils/widgets.js +0 -61
  287. package/build/request-utils/widgets.js.map +0 -1
  288. package/build/test.cjs +0 -136
  289. package/build/test.cjs.map +0 -7
  290. package/build/test.js +0 -189
  291. package/build/test.js.map +0 -1
  292. package/build/types.cjs +0 -19
  293. package/build/types.cjs.map +0 -7
  294. package/build/types.js +0 -3
  295. package/build/types.js.map +0 -1
@@ -1,66 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/e2e-test-utils-playwright/src/request-utils/comments.ts
21
- var comments_exports = {};
22
- __export(comments_exports, {
23
- createComment: () => createComment,
24
- deleteAllComments: () => deleteAllComments
25
- });
26
- module.exports = __toCommonJS(comments_exports);
27
- async function createComment(payload) {
28
- const currentUser = await this.rest({
29
- path: "/wp/v2/users/me",
30
- method: "GET"
31
- });
32
- const author = currentUser.id;
33
- const comment = await this.rest({
34
- method: "POST",
35
- path: "/wp/v2/comments",
36
- data: { ...payload, author }
37
- });
38
- return comment;
39
- }
40
- async function deleteAllComments(type) {
41
- const comments = await this.rest({
42
- path: "/wp/v2/comments",
43
- params: {
44
- per_page: 100,
45
- status: "all",
46
- type: type || "comment"
47
- }
48
- });
49
- await Promise.all(
50
- comments.map(
51
- (comment) => this.rest({
52
- method: "DELETE",
53
- path: `/wp/v2/comments/${comment.id}`,
54
- params: {
55
- force: true
56
- }
57
- })
58
- )
59
- );
60
- }
61
- // Annotate the CommonJS export names for ESM import in node:
62
- 0 && (module.exports = {
63
- createComment,
64
- deleteAllComments
65
- });
66
- //# sourceMappingURL=comments.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/comments.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface Comment {\n\tid: number;\n\tauthor: number;\n\tcontent: string;\n\tpost: number;\n}\n\nexport interface CreateCommentPayload {\n\tcontent: string;\n\tpost: number;\n}\n\nexport interface User {\n\tid: number;\n}\n\n/**\n * Create new comment using the REST API.\n *\n * @param this\n * @param payload\n */\nexport async function createComment(\n\tthis: RequestUtils,\n\tpayload: CreateCommentPayload\n) {\n\tconst currentUser = await this.rest< User >( {\n\t\tpath: '/wp/v2/users/me',\n\t\tmethod: 'GET',\n\t} );\n\n\tconst author = currentUser.id;\n\n\tconst comment = await this.rest< Comment >( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/comments',\n\t\tdata: { ...payload, author },\n\t} );\n\n\treturn comment;\n}\n\n/**\n * Delete all comments using the REST API.\n *\n * @param this\n * @param type - Optional comment type to delete.\n */\nexport async function deleteAllComments( this: RequestUtils, type?: string ) {\n\t// List all comments.\n\t// https://developer.wordpress.org/rest-api/reference/comments/#list-comments\n\tconst comments = await this.rest( {\n\t\tpath: '/wp/v2/comments',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t\tstatus: 'all',\n\t\t\ttype: type || 'comment',\n\t\t},\n\t} );\n\n\t// Delete all comments one by one.\n\t// https://developer.wordpress.org/rest-api/reference/comments/#delete-a-comment\n\t// \"/wp/v2/comments\" doesn't support batch requests yet.\n\tawait Promise.all(\n\t\tcomments.map( ( comment: Comment ) =>\n\t\t\tthis.rest( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\tpath: `/wp/v2/comments/${ comment.id }`,\n\t\t\t\tparams: {\n\t\t\t\t\tforce: true,\n\t\t\t\t},\n\t\t\t} )\n\t\t)\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,eAAsB,cAErB,SACC;AACD,QAAM,cAAc,MAAM,KAAK,KAAc;AAAA,IAC5C,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AAEF,QAAM,SAAS,YAAY;AAE3B,QAAM,UAAU,MAAM,KAAK,KAAiB;AAAA,IAC3C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM,EAAE,GAAG,SAAS,OAAO;AAAA,EAC5B,CAAE;AAEF,SAAO;AACR;AAQA,eAAsB,kBAAuC,MAAgB;AAG5E,QAAM,WAAW,MAAM,KAAK,KAAM;AAAA,IACjC,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,MAAM,QAAQ;AAAA,IACf;AAAA,EACD,CAAE;AAKF,QAAM,QAAQ;AAAA,IACb,SAAS;AAAA,MAAK,CAAE,YACf,KAAK,KAAM;AAAA,QACV,QAAQ;AAAA,QACR,MAAM,mBAAoB,QAAQ,EAAG;AAAA,QACrC,QAAQ;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;",
6
- "names": []
7
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createComment = createComment;
4
- exports.deleteAllComments = deleteAllComments;
5
- /**
6
- * Create new comment using the REST API.
7
- *
8
- * @param this
9
- * @param payload
10
- */
11
- async function createComment(payload) {
12
- const currentUser = await this.rest({
13
- path: '/wp/v2/users/me',
14
- method: 'GET',
15
- });
16
- const author = currentUser.id;
17
- const comment = await this.rest({
18
- method: 'POST',
19
- path: '/wp/v2/comments',
20
- data: { ...payload, author },
21
- });
22
- return comment;
23
- }
24
- /**
25
- * Delete all comments using the REST API.
26
- *
27
- * @param this
28
- * @param type - Optional comment type to delete.
29
- */
30
- async function deleteAllComments(type) {
31
- // List all comments.
32
- // https://developer.wordpress.org/rest-api/reference/comments/#list-comments
33
- const comments = await this.rest({
34
- path: '/wp/v2/comments',
35
- params: {
36
- per_page: 100,
37
- status: 'all',
38
- type: type || 'comment',
39
- },
40
- });
41
- // Delete all comments one by one.
42
- // https://developer.wordpress.org/rest-api/reference/comments/#delete-a-comment
43
- // "/wp/v2/comments" doesn't support batch requests yet.
44
- await Promise.all(comments.map((comment) => this.rest({
45
- method: 'DELETE',
46
- path: `/wp/v2/comments/${comment.id}`,
47
- params: {
48
- force: true,
49
- },
50
- })));
51
- }
52
- //# sourceMappingURL=comments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/request-utils/comments.ts"],"names":[],"mappings":";;;;AAqBA;;;;;GAKG;AACI,KAAK,wBAEX,OAA6B;IAE7B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAU;QAC5C,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;KACb,CAAE,CAAC;IAEJ,MAAM,MAAM,GAAG,WAAW,CAAC,EAAE,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAa;QAC3C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE;KAC5B,CAAE,CAAC;IAEJ,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACI,KAAK,4BAAiD,IAAa;IACzE,qBAAqB;IACrB,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACjC,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;YACb,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,IAAI,SAAS;SACvB;KACD,CAAE,CAAC;IAEJ,kCAAkC;IAClC,gFAAgF;IAChF,wDAAwD;IACxD,MAAM,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,GAAG,CAAE,CAAE,OAAgB,EAAG,EAAE,CACpC,IAAI,CAAC,IAAI,CAAE;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,mBAAoB,OAAO,CAAC,EAAG,EAAE;QACvC,MAAM,EAAE;YACP,KAAK,EAAE,IAAI;SACX;KACD,CAAE,CACH,CACD,CAAC;AACH,CAAC"}
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/e2e-test-utils-playwright/src/request-utils/gutenberg-experiments.ts
21
- var gutenberg_experiments_exports = {};
22
- __export(gutenberg_experiments_exports, {
23
- setGutenbergExperiments: () => setGutenbergExperiments
24
- });
25
- module.exports = __toCommonJS(gutenberg_experiments_exports);
26
- async function setGutenbergExperiments(experiments) {
27
- const regularExperiments = experiments.filter(
28
- (exp) => exp !== "active_templates"
29
- );
30
- const hasActiveTemplates = experiments.includes("active_templates");
31
- const experimentsData = {};
32
- for (const experiment of regularExperiments) {
33
- experimentsData[experiment] = true;
34
- }
35
- const settingsData = {
36
- "gutenberg-experiments": experimentsData
37
- };
38
- if (hasActiveTemplates) {
39
- settingsData.active_templates = {};
40
- } else {
41
- const currentSiteSettings = await this.getSiteSettings();
42
- if (currentSiteSettings.active_templates !== null) {
43
- settingsData.active_templates = null;
44
- }
45
- }
46
- await this.rest({
47
- path: "/wp/v2/settings",
48
- method: "POST",
49
- data: settingsData
50
- });
51
- }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- setGutenbergExperiments
55
- });
56
- //# sourceMappingURL=gutenberg-experiments.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/gutenberg-experiments.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Sets the Gutenberg experiments.\n *\n * @param this\n * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.\n * Use 'active_templates' for the template activation feature.\n */\nasync function setGutenbergExperiments(\n\tthis: RequestUtils,\n\texperiments: string[]\n) {\n\t// Separate regular experiments from active_templates.\n\t// active_templates is stored as a separate option, not in the experiments array.\n\tconst regularExperiments = experiments.filter(\n\t\t( exp ) => exp !== 'active_templates'\n\t);\n\tconst hasActiveTemplates = experiments.includes( 'active_templates' );\n\n\t// Build the experiments object with boolean values.\n\t// When empty array is passed, we send an empty object to disable all experiments.\n\tconst experimentsData: Record< string, boolean > = {};\n\n\tfor ( const experiment of regularExperiments ) {\n\t\texperimentsData[ experiment ] = true;\n\t}\n\n\tconst settingsData: Record< string, unknown > = {\n\t\t'gutenberg-experiments': experimentsData,\n\t};\n\n\t// active_templates lives in a separate top-level option. Sending `{}`\n\t// enables the experiment; sending `null` deletes the option and disables\n\t// it.\n\tif ( hasActiveTemplates ) {\n\t\tsettingsData.active_templates = {};\n\t} else {\n\t\t// WP_REST_Settings_Controller rejects null updates when the stored\n\t\t// value does not match the `type: 'object'` schema (including when the\n\t\t// option is absent and `get_option` falls back to `false`), so we only\n\t\t// send null when the option actually exists.\n\t\tconst currentSiteSettings =\n\t\t\t( await this.getSiteSettings() ) as unknown as {\n\t\t\t\tactive_templates?: unknown;\n\t\t\t};\n\t\tif ( currentSiteSettings.active_templates !== null ) {\n\t\t\tsettingsData.active_templates = null;\n\t\t}\n\t}\n\n\tawait this.rest( {\n\t\tpath: '/wp/v2/settings',\n\t\tmethod: 'POST',\n\t\tdata: settingsData,\n\t} );\n}\n\nexport { setGutenbergExperiments };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,eAAe,wBAEd,aACC;AAGD,QAAM,qBAAqB,YAAY;AAAA,IACtC,CAAE,QAAS,QAAQ;AAAA,EACpB;AACA,QAAM,qBAAqB,YAAY,SAAU,kBAAmB;AAIpE,QAAM,kBAA6C,CAAC;AAEpD,aAAY,cAAc,oBAAqB;AAC9C,oBAAiB,UAAW,IAAI;AAAA,EACjC;AAEA,QAAM,eAA0C;AAAA,IAC/C,yBAAyB;AAAA,EAC1B;AAKA,MAAK,oBAAqB;AACzB,iBAAa,mBAAmB,CAAC;AAAA,EAClC,OAAO;AAKN,UAAM,sBACH,MAAM,KAAK,gBAAgB;AAG9B,QAAK,oBAAoB,qBAAqB,MAAO;AACpD,mBAAa,mBAAmB;AAAA,IACjC;AAAA,EACD;AAEA,QAAM,KAAK,KAAM;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,EACP,CAAE;AACH;",
6
- "names": []
7
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setGutenbergExperiments = setGutenbergExperiments;
4
- /**
5
- * Sets the Gutenberg experiments.
6
- *
7
- * @param this
8
- * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.
9
- * Use 'active_templates' for the template activation feature.
10
- */
11
- async function setGutenbergExperiments(experiments) {
12
- // Separate regular experiments from active_templates.
13
- // active_templates is stored as a separate option, not in the experiments array.
14
- const regularExperiments = experiments.filter((exp) => exp !== 'active_templates');
15
- const hasActiveTemplates = experiments.includes('active_templates');
16
- // Build the experiments object with boolean values.
17
- // When empty array is passed, we send an empty object to disable all experiments.
18
- const experimentsData = {};
19
- for (const experiment of regularExperiments) {
20
- experimentsData[experiment] = true;
21
- }
22
- const settingsData = {
23
- 'gutenberg-experiments': experimentsData,
24
- };
25
- // active_templates lives in a separate top-level option. Sending `{}`
26
- // enables the experiment; sending `null` deletes the option and disables
27
- // it.
28
- if (hasActiveTemplates) {
29
- settingsData.active_templates = {};
30
- }
31
- else {
32
- // WP_REST_Settings_Controller rejects null updates when the stored
33
- // value does not match the `type: 'object'` schema (including when the
34
- // option is absent and `get_option` falls back to `false`), so we only
35
- // send null when the option actually exists.
36
- const currentSiteSettings = (await this.getSiteSettings());
37
- if (currentSiteSettings.active_templates !== null) {
38
- settingsData.active_templates = null;
39
- }
40
- }
41
- await this.rest({
42
- path: '/wp/v2/settings',
43
- method: 'POST',
44
- data: settingsData,
45
- });
46
- }
47
- //# sourceMappingURL=gutenberg-experiments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gutenberg-experiments.js","sourceRoot":"","sources":["../../src/request-utils/gutenberg-experiments.ts"],"names":[],"mappings":";;QA6DS,uBAAuB;AAxDhC;;;;;;GAMG;AACH,KAAK,UAAU,uBAAuB,CAErC,WAAqB;IAErB,sDAAsD;IACtD,iFAAiF;IACjF,MAAM,kBAAkB,GAAG,WAAW,CAAC,MAAM,CAC5C,CAAE,GAAG,EAAG,EAAE,CAAC,GAAG,KAAK,kBAAkB,CACrC,CAAC;IACF,MAAM,kBAAkB,GAAG,WAAW,CAAC,QAAQ,CAAE,kBAAkB,CAAE,CAAC;IAEtE,oDAAoD;IACpD,kFAAkF;IAClF,MAAM,eAAe,GAA8B,EAAE,CAAC;IAEtD,KAAM,MAAM,UAAU,IAAI,kBAAkB,EAAG,CAAC;QAC/C,eAAe,CAAE,UAAU,CAAE,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,MAAM,YAAY,GAA8B;QAC/C,uBAAuB,EAAE,eAAe;KACxC,CAAC;IAEF,sEAAsE;IACtE,yEAAyE;IACzE,MAAM;IACN,IAAK,kBAAkB,EAAG,CAAC;QAC1B,YAAY,CAAC,gBAAgB,GAAG,EAAE,CAAC;IACpC,CAAC;SAAM,CAAC;QACP,mEAAmE;QACnE,uEAAuE;QACvE,uEAAuE;QACvE,6CAA6C;QAC7C,MAAM,mBAAmB,GACxB,CAAE,MAAM,IAAI,CAAC,eAAe,EAAE,CAE7B,CAAC;QACH,IAAK,mBAAmB,CAAC,gBAAgB,KAAK,IAAI,EAAG,CAAC;YACrD,YAAY,CAAC,gBAAgB,GAAG,IAAI,CAAC;QACtC,CAAC;IACF,CAAC;IAED,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,YAAY;KAClB,CAAE,CAAC;AACL,CAAC"}
@@ -1,199 +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/index.ts
31
- var request_utils_exports = {};
32
- __export(request_utils_exports, {
33
- RequestUtils: () => RequestUtils
34
- });
35
- module.exports = __toCommonJS(request_utils_exports);
36
- var fs = __toESM(require("fs/promises"));
37
- var path = __toESM(require("path"));
38
- var import_test = require("@playwright/test");
39
- var import_config = require("../config.cjs");
40
- var import_login = require("./login.cjs");
41
- var import_media = require("./media.cjs");
42
- var import_users = require("./users.cjs");
43
- var import_rest = require("./rest.cjs");
44
- var import_plugins = require("./plugins.cjs");
45
- var import_templates = require("./templates.cjs");
46
- var import_themes = require("./themes.cjs");
47
- var import_blocks = require("./blocks.cjs");
48
- var import_comments = require("./comments.cjs");
49
- var import_posts = require("./posts.cjs");
50
- var import_menus = require("./menus.cjs");
51
- var import_pages = require("./pages.cjs");
52
- var import_records = require("./records.cjs");
53
- var import_preferences = require("./preferences.cjs");
54
- var import_site_settings = require("./site-settings.cjs");
55
- var import_widgets = require("./widgets.cjs");
56
- var import_patterns = require("./patterns.cjs");
57
- var import_gutenberg_experiments = require("./gutenberg-experiments.cjs");
58
- var RequestUtils = class {
59
- request;
60
- user;
61
- maxBatchSize;
62
- storageState;
63
- storageStatePath;
64
- baseURL;
65
- pluginsMap = null;
66
- static async setup({
67
- user,
68
- storageStatePath,
69
- baseURL = import_config.WP_BASE_URL
70
- }) {
71
- let storageState;
72
- if (storageStatePath) {
73
- await fs.mkdir(path.dirname(storageStatePath), {
74
- recursive: true
75
- });
76
- try {
77
- storageState = JSON.parse(
78
- await fs.readFile(storageStatePath, "utf-8")
79
- );
80
- } catch (error) {
81
- if (error instanceof Error && error.code === "ENOENT") {
82
- } else {
83
- throw error;
84
- }
85
- }
86
- }
87
- const requestContext = await import_test.request.newContext({
88
- baseURL,
89
- storageState: storageState && {
90
- cookies: storageState.cookies,
91
- origins: []
92
- }
93
- });
94
- const requestUtils = new this(requestContext, {
95
- user,
96
- storageState,
97
- storageStatePath,
98
- baseURL
99
- });
100
- return requestUtils;
101
- }
102
- constructor(requestContext, {
103
- user = import_config.WP_ADMIN_USER,
104
- storageState,
105
- storageStatePath,
106
- baseURL = import_config.WP_BASE_URL
107
- } = {}) {
108
- this.user = user;
109
- this.request = requestContext;
110
- this.storageStatePath = storageStatePath;
111
- this.storageState = storageState;
112
- this.baseURL = baseURL;
113
- }
114
- /** @borrows login as this.login */
115
- login = import_login.login.bind(this);
116
- /** @borrows setupRest as this.setupRest */
117
- setupRest = import_rest.setupRest.bind(this);
118
- // .bind() drops the generic types. Re-casting it to keep the type signature.
119
- rest = import_rest.rest.bind(this);
120
- /** @borrows getMaxBatchSize as this.getMaxBatchSize */
121
- getMaxBatchSize = import_rest.getMaxBatchSize.bind(this);
122
- // .bind() drops the generic types. Re-casting it to keep the type signature.
123
- batchRest = import_rest.batchRest.bind(this);
124
- // .bind() drops the generic types. Re-casting it to keep the type signature.
125
- createRecord = import_records.createRecord.bind(
126
- this
127
- );
128
- /** @borrows getPluginsMap as this.getPluginsMap */
129
- getPluginsMap = import_plugins.getPluginsMap.bind(this);
130
- /** @borrows activatePlugin as this.activatePlugin */
131
- activatePlugin = import_plugins.activatePlugin.bind(this);
132
- /** @borrows deactivatePlugin as this.deactivatePlugin */
133
- deactivatePlugin = import_plugins.deactivatePlugin.bind(this);
134
- /** @borrows activateTheme as this.activateTheme */
135
- activateTheme = import_themes.activateTheme.bind(this);
136
- /** @borrows createBlock as this.createBlock */
137
- createBlock = import_blocks.createBlock.bind(this);
138
- /** @borrows deleteAllBlocks as this.deleteAllBlocks */
139
- deleteAllBlocks = import_blocks.deleteAllBlocks.bind(this);
140
- /** @borrows createPost as this.createPost */
141
- createPost = import_posts.createPost.bind(this);
142
- /** @borrows deleteAllPosts as this.deleteAllPosts */
143
- deleteAllPosts = import_posts.deleteAllPosts.bind(this);
144
- /** @borrows createClassicMenu as this.createClassicMenu */
145
- createClassicMenu = import_menus.createClassicMenu.bind(this);
146
- /** @borrows createNavigationMenu as this.createNavigationMenu */
147
- createNavigationMenu = import_menus.createNavigationMenu.bind(this);
148
- /** @borrows deleteAllMenus as this.deleteAllMenus */
149
- deleteAllMenus = import_menus.deleteAllMenus.bind(this);
150
- /** @borrows getNavigationMenus as this.getNavigationMenus */
151
- getNavigationMenus = import_menus.getNavigationMenus.bind(this);
152
- /** @borrows createComment as this.createComment */
153
- createComment = import_comments.createComment.bind(this);
154
- /** @borrows deleteAllComments as this.deleteAllComments */
155
- deleteAllComments = import_comments.deleteAllComments.bind(this);
156
- /** @borrows deleteAllWidgets as this.deleteAllWidgets */
157
- deleteAllWidgets = import_widgets.deleteAllWidgets.bind(this);
158
- /** @borrows addWidgetBlock as this.addWidgetBlock */
159
- addWidgetBlock = import_widgets.addWidgetBlock.bind(this);
160
- /** @borrows deleteAllTemplates as this.deleteAllTemplates */
161
- deleteAllTemplates = import_templates.deleteAllTemplates.bind(this);
162
- /** @borrows createTemplate as this.createTemplate */
163
- createTemplate = import_templates.createTemplate.bind(this);
164
- /** @borrows resetPreferences as this.resetPreferences */
165
- resetPreferences = import_preferences.resetPreferences.bind(this);
166
- /** @borrows listMedia as this.listMedia */
167
- listMedia = import_media.listMedia.bind(this);
168
- /** @borrows uploadMedia as this.uploadMedia */
169
- uploadMedia = import_media.uploadMedia.bind(this);
170
- /** @borrows deleteMedia as this.deleteMedia */
171
- deleteMedia = import_media.deleteMedia.bind(this);
172
- /** @borrows deleteAllMedia as this.deleteAllMedia */
173
- deleteAllMedia = import_media.deleteAllMedia.bind(this);
174
- /** @borrows createUser as this.createUser */
175
- createUser = import_users.createUser.bind(this);
176
- /** @borrows deleteAllUsers as this.deleteAllUsers */
177
- deleteAllUsers = import_users.deleteAllUsers.bind(this);
178
- /** @borrows getSiteSettings as this.getSiteSettings */
179
- getSiteSettings = import_site_settings.getSiteSettings.bind(this);
180
- /** @borrows updateSiteSettings as this.updateSiteSettings */
181
- updateSiteSettings = import_site_settings.updateSiteSettings.bind(this);
182
- /** @borrows deleteAllPages as this.deleteAllPages */
183
- deleteAllPages = import_pages.deleteAllPages.bind(this);
184
- /** @borrows createPage as this.createPage */
185
- createPage = import_pages.createPage.bind(this);
186
- /** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
187
- getCurrentThemeGlobalStylesPostId = import_themes.getCurrentThemeGlobalStylesPostId.bind(this);
188
- /** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
189
- getThemeGlobalStylesRevisions = import_themes.getThemeGlobalStylesRevisions.bind(this);
190
- /** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
191
- deleteAllPatternCategories = import_patterns.deleteAllPatternCategories.bind(this);
192
- /** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
193
- setGutenbergExperiments = import_gutenberg_experiments.setGutenbergExperiments.bind(this);
194
- };
195
- // Annotate the CommonJS export names for ESM import in node:
196
- 0 && (module.exports = {
197
- RequestUtils
198
- });
199
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
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 { createRecord } from './records';\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// .bind() drops the generic types. Re-casting it to keep the type signature.\n\tcreateRecord: typeof createRecord = createRecord.bind(\n\t\tthis\n\t) as typeof createRecord;\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": "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",
6
- "names": []
7
- }