@wordpress/e2e-test-utils-playwright 1.36.1-next.738bb1424.0 → 1.37.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 (227) hide show
  1. package/build/admin/create-new-post.js +48 -28
  2. package/build/admin/create-new-post.js.map +7 -1
  3. package/build/admin/edit-post.js +37 -17
  4. package/build/admin/edit-post.js.map +7 -1
  5. package/build/admin/get-page-error.js +33 -23
  6. package/build/admin/get-page-error.js.map +7 -1
  7. package/build/admin/index.js +58 -36
  8. package/build/admin/index.js.map +7 -1
  9. package/build/admin/visit-admin-page.js +44 -29
  10. package/build/admin/visit-admin-page.js.map +7 -1
  11. package/build/admin/visit-site-editor.js +73 -64
  12. package/build/admin/visit-site-editor.js.map +7 -1
  13. package/build/config.js +43 -11
  14. package/build/config.js.map +7 -1
  15. package/build/editor/click-block-options-menu-item.js +31 -14
  16. package/build/editor/click-block-options-menu-item.js.map +7 -1
  17. package/build/editor/click-block-toolbar-button.js +35 -13
  18. package/build/editor/click-block-toolbar-button.js.map +7 -1
  19. package/build/editor/get-blocks.js +61 -43
  20. package/build/editor/get-blocks.js.map +7 -1
  21. package/build/editor/get-edited-post-content.js +33 -12
  22. package/build/editor/get-edited-post-content.js.map +7 -1
  23. package/build/editor/index.js +96 -74
  24. package/build/editor/index.js.map +7 -1
  25. package/build/editor/insert-block.js +52 -21
  26. package/build/editor/insert-block.js.map +7 -1
  27. package/build/editor/open-document-settings-sidebar.js +39 -24
  28. package/build/editor/open-document-settings-sidebar.js.map +7 -1
  29. package/build/editor/preview.js +39 -18
  30. package/build/editor/preview.js.map +7 -1
  31. package/build/editor/publish-post.js +44 -42
  32. package/build/editor/publish-post.js.map +7 -1
  33. package/build/editor/save-draft.js +31 -15
  34. package/build/editor/save-draft.js.map +7 -1
  35. package/build/editor/select-blocks.js +48 -25
  36. package/build/editor/select-blocks.js.map +7 -1
  37. package/build/editor/set-content.js +36 -14
  38. package/build/editor/set-content.js.map +7 -1
  39. package/build/editor/set-is-fixed-toolbar.js +33 -15
  40. package/build/editor/set-is-fixed-toolbar.js.map +7 -1
  41. package/build/editor/set-preferences.js +40 -18
  42. package/build/editor/set-preferences.js.map +7 -1
  43. package/build/editor/show-block-toolbar.js +32 -16
  44. package/build/editor/show-block-toolbar.js.map +7 -1
  45. package/build/editor/site-editor.js +48 -41
  46. package/build/editor/site-editor.js.map +7 -1
  47. package/build/editor/switch-editor-tool.js +44 -30
  48. package/build/editor/switch-editor-tool.js.map +7 -1
  49. package/build/editor/switch-to-legacy-canvas.js +35 -14
  50. package/build/editor/switch-to-legacy-canvas.js.map +7 -1
  51. package/build/editor/transform-block-to.js +43 -21
  52. package/build/editor/transform-block-to.js.map +7 -1
  53. package/build/index.js +53 -18
  54. package/build/index.js.map +7 -1
  55. package/build/lighthouse/index.js +93 -55
  56. package/build/lighthouse/index.js.map +7 -1
  57. package/build/metrics/index.js +302 -251
  58. package/build/metrics/index.js.map +7 -1
  59. package/build/page-utils/drag-files.js +136 -112
  60. package/build/page-utils/drag-files.js.map +7 -1
  61. package/build/page-utils/emulate-network-conditions.js +95 -67
  62. package/build/page-utils/emulate-network-conditions.js.map +7 -1
  63. package/build/page-utils/index.js +58 -36
  64. package/build/page-utils/index.js.map +7 -1
  65. package/build/page-utils/is-current-url.js +33 -18
  66. package/build/page-utils/is-current-url.js.map +7 -1
  67. package/build/page-utils/keycodes.js +53 -39
  68. package/build/page-utils/keycodes.js.map +7 -1
  69. package/build/page-utils/press-keys.js +153 -130
  70. package/build/page-utils/press-keys.js.map +7 -1
  71. package/build/page-utils/set-browser-viewport.js +35 -42
  72. package/build/page-utils/set-browser-viewport.js.map +7 -1
  73. package/build/request-utils/blocks.js +51 -40
  74. package/build/request-utils/blocks.js.map +7 -1
  75. package/build/request-utils/comments.js +59 -45
  76. package/build/request-utils/comments.js.map +7 -1
  77. package/build/request-utils/gutenberg-experiments.js +63 -38
  78. package/build/request-utils/gutenberg-experiments.js.map +7 -1
  79. package/build/request-utils/index.js +191 -155
  80. package/build/request-utils/index.js.map +7 -1
  81. package/build/request-utils/login.js +45 -18
  82. package/build/request-utils/login.js.map +7 -1
  83. package/build/request-utils/media.js +74 -64
  84. package/build/request-utils/media.js.map +7 -1
  85. package/build/request-utils/menus.js +121 -109
  86. package/build/request-utils/menus.js.map +7 -1
  87. package/build/request-utils/pages.js +63 -50
  88. package/build/request-utils/pages.js.map +7 -1
  89. package/build/request-utils/patterns.js +41 -24
  90. package/build/request-utils/patterns.js.map +7 -1
  91. package/build/request-utils/plugins.js +70 -74
  92. package/build/request-utils/plugins.js.map +7 -1
  93. package/build/request-utils/posts.js +55 -41
  94. package/build/request-utils/posts.js.map +7 -1
  95. package/build/request-utils/preferences.js +38 -17
  96. package/build/request-utils/preferences.js.map +7 -1
  97. package/build/request-utils/rest.js +155 -129
  98. package/build/request-utils/rest.js.map +7 -1
  99. package/build/request-utils/site-settings.js +40 -28
  100. package/build/request-utils/site-settings.js.map +7 -1
  101. package/build/request-utils/templates.js +60 -46
  102. package/build/request-utils/templates.js.map +7 -1
  103. package/build/request-utils/themes.js +80 -53
  104. package/build/request-utils/themes.js.map +7 -1
  105. package/build/request-utils/users.js +74 -72
  106. package/build/request-utils/users.js.map +7 -1
  107. package/build/request-utils/widgets.js +73 -55
  108. package/build/request-utils/widgets.js.map +7 -1
  109. package/build/test.js +130 -146
  110. package/build/test.js.map +7 -1
  111. package/build/types.js +18 -2
  112. package/build/types.js.map +7 -1
  113. package/build-types/index.d.ts +1 -1
  114. package/build-types/index.d.ts.map +1 -1
  115. package/package.json +2 -2
  116. package/build/admin/create-new-post.cjs +0 -51
  117. package/build/admin/create-new-post.cjs.map +0 -7
  118. package/build/admin/edit-post.cjs +0 -40
  119. package/build/admin/edit-post.cjs.map +0 -7
  120. package/build/admin/get-page-error.cjs +0 -36
  121. package/build/admin/get-page-error.cjs.map +0 -7
  122. package/build/admin/index.cjs +0 -59
  123. package/build/admin/index.cjs.map +0 -7
  124. package/build/admin/visit-admin-page.cjs +0 -47
  125. package/build/admin/visit-admin-page.cjs.map +0 -7
  126. package/build/admin/visit-site-editor.cjs +0 -77
  127. package/build/admin/visit-site-editor.cjs.map +0 -7
  128. package/build/config.cjs +0 -45
  129. package/build/config.cjs.map +0 -7
  130. package/build/editor/click-block-options-menu-item.cjs +0 -34
  131. package/build/editor/click-block-options-menu-item.cjs.map +0 -7
  132. package/build/editor/click-block-toolbar-button.cjs +0 -38
  133. package/build/editor/click-block-toolbar-button.cjs.map +0 -7
  134. package/build/editor/get-blocks.cjs +0 -64
  135. package/build/editor/get-blocks.cjs.map +0 -7
  136. package/build/editor/get-edited-post-content.cjs +0 -36
  137. package/build/editor/get-edited-post-content.cjs.map +0 -7
  138. package/build/editor/index.cjs +0 -97
  139. package/build/editor/index.cjs.map +0 -7
  140. package/build/editor/insert-block.cjs +0 -55
  141. package/build/editor/insert-block.cjs.map +0 -7
  142. package/build/editor/open-document-settings-sidebar.cjs +0 -42
  143. package/build/editor/open-document-settings-sidebar.cjs.map +0 -7
  144. package/build/editor/preview.cjs +0 -42
  145. package/build/editor/preview.cjs.map +0 -7
  146. package/build/editor/publish-post.cjs +0 -47
  147. package/build/editor/publish-post.cjs.map +0 -7
  148. package/build/editor/save-draft.cjs +0 -34
  149. package/build/editor/save-draft.cjs.map +0 -7
  150. package/build/editor/select-blocks.cjs +0 -51
  151. package/build/editor/select-blocks.cjs.map +0 -7
  152. package/build/editor/set-content.cjs +0 -39
  153. package/build/editor/set-content.cjs.map +0 -7
  154. package/build/editor/set-is-fixed-toolbar.cjs +0 -36
  155. package/build/editor/set-is-fixed-toolbar.cjs.map +0 -7
  156. package/build/editor/set-preferences.cjs +0 -43
  157. package/build/editor/set-preferences.cjs.map +0 -7
  158. package/build/editor/show-block-toolbar.cjs +0 -35
  159. package/build/editor/show-block-toolbar.cjs.map +0 -7
  160. package/build/editor/site-editor.cjs +0 -51
  161. package/build/editor/site-editor.cjs.map +0 -7
  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-to-legacy-canvas.cjs +0 -39
  165. package/build/editor/switch-to-legacy-canvas.cjs.map +0 -7
  166. package/build/editor/transform-block-to.cjs +0 -46
  167. package/build/editor/transform-block-to.cjs.map +0 -7
  168. package/build/index.cjs +0 -51
  169. package/build/index.cjs.map +0 -7
  170. package/build/lighthouse/index.cjs +0 -96
  171. package/build/lighthouse/index.cjs.map +0 -7
  172. package/build/metrics/index.cjs +0 -309
  173. package/build/metrics/index.cjs.map +0 -7
  174. package/build/page-utils/drag-files.cjs +0 -143
  175. package/build/page-utils/drag-files.cjs.map +0 -7
  176. package/build/page-utils/emulate-network-conditions.cjs +0 -99
  177. package/build/page-utils/emulate-network-conditions.cjs.map +0 -7
  178. package/build/page-utils/index.cjs +0 -59
  179. package/build/page-utils/index.cjs.map +0 -7
  180. package/build/page-utils/is-current-url.cjs +0 -36
  181. package/build/page-utils/is-current-url.cjs.map +0 -7
  182. package/build/page-utils/keycodes.cjs +0 -55
  183. package/build/page-utils/keycodes.cjs.map +0 -7
  184. package/build/page-utils/press-keys.cjs +0 -165
  185. package/build/page-utils/press-keys.cjs.map +0 -7
  186. package/build/page-utils/set-browser-viewport.cjs +0 -39
  187. package/build/page-utils/set-browser-viewport.cjs.map +0 -7
  188. package/build/request-utils/blocks.cjs +0 -56
  189. package/build/request-utils/blocks.cjs.map +0 -7
  190. package/build/request-utils/comments.cjs +0 -66
  191. package/build/request-utils/comments.cjs.map +0 -7
  192. package/build/request-utils/gutenberg-experiments.cjs +0 -66
  193. package/build/request-utils/gutenberg-experiments.cjs.map +0 -7
  194. package/build/request-utils/index.cjs +0 -194
  195. package/build/request-utils/index.cjs.map +0 -7
  196. package/build/request-utils/login.cjs +0 -48
  197. package/build/request-utils/login.cjs.map +0 -7
  198. package/build/request-utils/media.cjs +0 -83
  199. package/build/request-utils/media.cjs.map +0 -7
  200. package/build/request-utils/menus.cjs +0 -132
  201. package/build/request-utils/menus.cjs.map +0 -7
  202. package/build/request-utils/pages.cjs +0 -71
  203. package/build/request-utils/pages.cjs.map +0 -7
  204. package/build/request-utils/patterns.cjs +0 -44
  205. package/build/request-utils/patterns.cjs.map +0 -7
  206. package/build/request-utils/plugins.cjs +0 -81
  207. package/build/request-utils/plugins.cjs.map +0 -7
  208. package/build/request-utils/posts.cjs +0 -61
  209. package/build/request-utils/posts.cjs.map +0 -7
  210. package/build/request-utils/preferences.cjs +0 -41
  211. package/build/request-utils/preferences.cjs.map +0 -7
  212. package/build/request-utils/rest.cjs +0 -174
  213. package/build/request-utils/rest.cjs.map +0 -7
  214. package/build/request-utils/site-settings.cjs +0 -45
  215. package/build/request-utils/site-settings.cjs.map +0 -7
  216. package/build/request-utils/templates.cjs +0 -68
  217. package/build/request-utils/templates.cjs.map +0 -7
  218. package/build/request-utils/themes.cjs +0 -89
  219. package/build/request-utils/themes.cjs.map +0 -7
  220. package/build/request-utils/users.cjs +0 -83
  221. package/build/request-utils/users.cjs.map +0 -7
  222. package/build/request-utils/widgets.cjs +0 -79
  223. package/build/request-utils/widgets.cjs.map +0 -7
  224. package/build/test.cjs +0 -136
  225. package/build/test.cjs.map +0 -7
  226. package/build/types.cjs +0 -19
  227. package/build/types.cjs.map +0 -7
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/media.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport * as fs from 'fs';\n\n/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface Media {\n\tid: number;\n\ttitle: {\n\t\traw: string;\n\t\trendered: string;\n\t};\n\tsource_url: string;\n\tslug: string;\n\talt_text: string;\n\tcaption: { rendered: string };\n\tlink: string;\n}\n\n/**\n * List all media files.\n *\n * @see https://developer.wordpress.org/rest-api/reference/media/#list-media\n * @param this\n */\nasync function listMedia( this: RequestUtils ) {\n\tconst response = await this.rest< Media[] >( {\n\t\tmethod: 'GET',\n\t\tpath: '/wp/v2/media',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t},\n\t} );\n\n\treturn response;\n}\n\n/**\n * Upload a media file.\n *\n * @see https://developer.wordpress.org/rest-api/reference/media/#create-a-media-item\n * @param this\n * @param filePathOrData The path or data of the file being uploaded.\n */\nasync function uploadMedia(\n\tthis: RequestUtils,\n\tfilePathOrData: string | fs.ReadStream\n) {\n\tconst file =\n\t\ttypeof filePathOrData === 'string'\n\t\t\t? fs.createReadStream( filePathOrData )\n\t\t\t: filePathOrData;\n\n\tconst response = await this.rest< Media >( {\n\t\tmethod: 'POST',\n\t\tpath: '/wp/v2/media',\n\t\tmultipart: {\n\t\t\tfile,\n\t\t},\n\t} );\n\n\treturn response;\n}\n\n/**\n * delete a media file.\n *\n * @see https://developer.wordpress.org/rest-api/reference/media/#delete-a-media-item\n * @param this\n * @param mediaId The ID of the media file.\n */\nasync function deleteMedia( this: RequestUtils, mediaId: number ) {\n\tconst response = await this.rest( {\n\t\tmethod: 'DELETE',\n\t\tpath: `/wp/v2/media/${ mediaId }`,\n\t\tparams: { force: true },\n\t} );\n\n\treturn response;\n}\n\n/**\n * delete all media files.\n *\n * @param this\n */\nasync function deleteAllMedia( this: RequestUtils ) {\n\tconst files = await this.listMedia();\n\n\t// The media endpoint doesn't support batch request yet.\n\tconst responses = await Promise.all(\n\t\tfiles.map( ( media ) => this.deleteMedia( media.id ) )\n\t);\n\n\treturn responses;\n}\n\nexport { listMedia, uploadMedia, deleteMedia, deleteAllMedia };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAoB;AA0BpB,eAAe,YAAgC;AAC9C,QAAM,WAAW,MAAM,KAAK,KAAiB;AAAA,IAC5C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,IACX;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AASA,eAAe,YAEd,gBACC;AACD,QAAM,OACL,OAAO,mBAAmB,WACpB,oBAAkB,cAAe,IACpC;AAEJ,QAAM,WAAW,MAAM,KAAK,KAAe;AAAA,IAC1C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,WAAW;AAAA,MACV;AAAA,IACD;AAAA,EACD,CAAE;AAEF,SAAO;AACR;AASA,eAAe,YAAiC,SAAkB;AACjE,QAAM,WAAW,MAAM,KAAK,KAAM;AAAA,IACjC,QAAQ;AAAA,IACR,MAAM,gBAAiB,OAAQ;AAAA,IAC/B,QAAQ,EAAE,OAAO,KAAK;AAAA,EACvB,CAAE;AAEF,SAAO;AACR;AAOA,eAAe,iBAAqC;AACnD,QAAM,QAAQ,MAAM,KAAK,UAAU;AAGnC,QAAM,YAAY,MAAM,QAAQ;AAAA,IAC/B,MAAM,IAAK,CAAE,UAAW,KAAK,YAAa,MAAM,EAAG,CAAE;AAAA,EACtD;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,132 +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/menus.ts
21
- var menus_exports = {};
22
- __export(menus_exports, {
23
- createClassicMenu: () => createClassicMenu,
24
- createNavigationMenu: () => createNavigationMenu,
25
- deleteAllMenus: () => deleteAllMenus,
26
- getNavigationMenus: () => getNavigationMenus
27
- });
28
- module.exports = __toCommonJS(menus_exports);
29
- async function createClassicMenu(name) {
30
- const menuItems = [
31
- {
32
- title: "Custom link",
33
- url: "http://localhost:8889/",
34
- type: "custom",
35
- menu_order: 1
36
- }
37
- ];
38
- const menu = await this.rest({
39
- method: "POST",
40
- path: `/wp/v2/menus/`,
41
- data: {
42
- name
43
- }
44
- });
45
- await this.batchRest(
46
- menuItems.map((menuItem) => ({
47
- method: "POST",
48
- path: `/wp/v2/menu-items`,
49
- body: {
50
- menus: menu.id,
51
- object_id: void 0,
52
- ...menuItem,
53
- parent: void 0
54
- }
55
- }))
56
- );
57
- return menu;
58
- }
59
- async function createNavigationMenu(menuData) {
60
- return this.rest({
61
- method: "POST",
62
- path: `/wp/v2/navigation/`,
63
- data: {
64
- status: "publish",
65
- ...menuData
66
- }
67
- });
68
- }
69
- async function deleteAllMenus() {
70
- const navMenus = await this.rest({
71
- path: `/wp/v2/navigation/`,
72
- data: {
73
- status: [
74
- "publish",
75
- "pending",
76
- "draft",
77
- "auto-draft",
78
- "future",
79
- "private",
80
- "inherit",
81
- "trash"
82
- ]
83
- }
84
- });
85
- if (navMenus.length) {
86
- await this.batchRest(
87
- navMenus.map((menu) => ({
88
- method: "DELETE",
89
- path: `/wp/v2/navigation/${menu.id}?force=true`
90
- }))
91
- );
92
- }
93
- const classicMenus = await this.rest({
94
- path: `/wp/v2/menus/`,
95
- data: {
96
- status: [
97
- "publish",
98
- "pending",
99
- "draft",
100
- "auto-draft",
101
- "future",
102
- "private",
103
- "inherit",
104
- "trash"
105
- ]
106
- }
107
- });
108
- if (classicMenus.length) {
109
- await this.batchRest(
110
- classicMenus.map((menu) => ({
111
- method: "DELETE",
112
- path: `/wp/v2/menus/${menu.id}?force=true`
113
- }))
114
- );
115
- }
116
- }
117
- async function getNavigationMenus(args) {
118
- const navigationMenus = await this.rest({
119
- method: "GET",
120
- path: `/wp/v2/navigation/`,
121
- data: args
122
- });
123
- return navigationMenus;
124
- }
125
- // Annotate the CommonJS export names for ESM import in node:
126
- 0 && (module.exports = {
127
- createClassicMenu,
128
- createNavigationMenu,
129
- deleteAllMenus,
130
- getNavigationMenus
131
- });
132
- //# sourceMappingURL=menus.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/menus.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface MenuData {\n\ttitle: string;\n\tcontent: string;\n}\nexport interface NavigationMenu {\n\tid: number;\n\tcontent: string;\n\tstatus: 'publish' | 'future' | 'draft' | 'pending' | 'private';\n}\n\n/**\n * Create a classic menu\n *\n * @param name Menu name.\n * @return Menu content.\n */\nexport async function createClassicMenu( this: RequestUtils, name: string ) {\n\tconst menuItems = [\n\t\t{\n\t\t\ttitle: 'Custom link',\n\t\t\turl: 'http://localhost:8889/',\n\t\t\ttype: 'custom',\n\t\t\tmenu_order: 1,\n\t\t},\n\t];\n\n\tconst menu = await this.rest< NavigationMenu >( {\n\t\tmethod: 'POST',\n\t\tpath: `/wp/v2/menus/`,\n\t\tdata: {\n\t\t\tname,\n\t\t},\n\t} );\n\n\tawait this.batchRest(\n\t\tmenuItems.map( ( menuItem ) => ( {\n\t\t\tmethod: 'POST',\n\t\t\tpath: `/wp/v2/menu-items`,\n\t\t\tbody: {\n\t\t\t\tmenus: menu.id,\n\t\t\t\tobject_id: undefined,\n\t\t\t\t...menuItem,\n\t\t\t\tparent: undefined,\n\t\t\t},\n\t\t} ) )\n\t);\n\n\treturn menu;\n}\n\n/**\n * Create a navigation menu\n *\n * @param menuData navigation menu post data.\n * @return Menu content.\n */\nexport async function createNavigationMenu(\n\tthis: RequestUtils,\n\tmenuData: MenuData\n) {\n\treturn this.rest( {\n\t\tmethod: 'POST',\n\t\tpath: `/wp/v2/navigation/`,\n\t\tdata: {\n\t\t\tstatus: 'publish',\n\t\t\t...menuData,\n\t\t},\n\t} );\n}\n\n/**\n * Delete all navigation and classic menus\n *\n */\nexport async function deleteAllMenus( this: RequestUtils ) {\n\tconst navMenus = await this.rest< NavigationMenu[] >( {\n\t\tpath: `/wp/v2/navigation/`,\n\t\tdata: {\n\t\t\tstatus: [\n\t\t\t\t'publish',\n\t\t\t\t'pending',\n\t\t\t\t'draft',\n\t\t\t\t'auto-draft',\n\t\t\t\t'future',\n\t\t\t\t'private',\n\t\t\t\t'inherit',\n\t\t\t\t'trash',\n\t\t\t],\n\t\t},\n\t} );\n\n\tif ( navMenus.length ) {\n\t\tawait this.batchRest(\n\t\t\tnavMenus.map( ( menu ) => ( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\tpath: `/wp/v2/navigation/${ menu.id }?force=true`,\n\t\t\t} ) )\n\t\t);\n\t}\n\n\tconst classicMenus = await this.rest< NavigationMenu[] >( {\n\t\tpath: `/wp/v2/menus/`,\n\t\tdata: {\n\t\t\tstatus: [\n\t\t\t\t'publish',\n\t\t\t\t'pending',\n\t\t\t\t'draft',\n\t\t\t\t'auto-draft',\n\t\t\t\t'future',\n\t\t\t\t'private',\n\t\t\t\t'inherit',\n\t\t\t\t'trash',\n\t\t\t],\n\t\t},\n\t} );\n\n\tif ( classicMenus.length ) {\n\t\tawait this.batchRest(\n\t\t\tclassicMenus.map( ( menu ) => ( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\tpath: `/wp/v2/menus/${ menu.id }?force=true`,\n\t\t\t} ) )\n\t\t);\n\t}\n}\n\n/**\n * Get latest navigation menus\n *\n * @param args\n * @param args.status\n * @return {string} Menu content.\n */\nexport async function getNavigationMenus(\n\tthis: RequestUtils,\n\targs: { status: 'publish' }\n) {\n\tconst navigationMenus = await this.rest< NavigationMenu[] >( {\n\t\tmethod: 'GET',\n\t\tpath: `/wp/v2/navigation/`,\n\t\tdata: args,\n\t} );\n\treturn navigationMenus;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,eAAsB,kBAAuC,MAAe;AAC3E,QAAM,YAAY;AAAA,IACjB;AAAA,MACC,OAAO;AAAA,MACP,KAAK;AAAA,MACL,MAAM;AAAA,MACN,YAAY;AAAA,IACb;AAAA,EACD;AAEA,QAAM,OAAO,MAAM,KAAK,KAAwB;AAAA,IAC/C,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,MACL;AAAA,IACD;AAAA,EACD,CAAE;AAEF,QAAM,KAAK;AAAA,IACV,UAAU,IAAK,CAAE,cAAgB;AAAA,MAChC,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,MAAM;AAAA,QACL,OAAO,KAAK;AAAA,QACZ,WAAW;AAAA,QACX,GAAG;AAAA,QACH,QAAQ;AAAA,MACT;AAAA,IACD,EAAI;AAAA,EACL;AAEA,SAAO;AACR;AAQA,eAAsB,qBAErB,UACC;AACD,SAAO,KAAK,KAAM;AAAA,IACjB,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,MACL,QAAQ;AAAA,MACR,GAAG;AAAA,IACJ;AAAA,EACD,CAAE;AACH;AAMA,eAAsB,iBAAqC;AAC1D,QAAM,WAAW,MAAM,KAAK,KAA0B;AAAA,IACrD,MAAM;AAAA,IACN,MAAM;AAAA,MACL,QAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AAEF,MAAK,SAAS,QAAS;AACtB,UAAM,KAAK;AAAA,MACV,SAAS,IAAK,CAAE,UAAY;AAAA,QAC3B,QAAQ;AAAA,QACR,MAAM,qBAAsB,KAAK,EAAG;AAAA,MACrC,EAAI;AAAA,IACL;AAAA,EACD;AAEA,QAAM,eAAe,MAAM,KAAK,KAA0B;AAAA,IACzD,MAAM;AAAA,IACN,MAAM;AAAA,MACL,QAAQ;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD,CAAE;AAEF,MAAK,aAAa,QAAS;AAC1B,UAAM,KAAK;AAAA,MACV,aAAa,IAAK,CAAE,UAAY;AAAA,QAC/B,QAAQ;AAAA,QACR,MAAM,gBAAiB,KAAK,EAAG;AAAA,MAChC,EAAI;AAAA,IACL;AAAA,EACD;AACD;AASA,eAAsB,mBAErB,MACC;AACD,QAAM,kBAAkB,MAAM,KAAK,KAA0B;AAAA,IAC5D,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,EACP,CAAE;AACF,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,71 +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/pages.ts
21
- var pages_exports = {};
22
- __export(pages_exports, {
23
- createPage: () => createPage,
24
- deleteAllPages: () => deleteAllPages,
25
- deletePage: () => deletePage
26
- });
27
- module.exports = __toCommonJS(pages_exports);
28
- var PAGE_STATUS = [
29
- "publish",
30
- "future",
31
- "draft",
32
- "pending",
33
- "private",
34
- "trash"
35
- ];
36
- async function deletePage(id) {
37
- return await this.rest({
38
- method: "DELETE",
39
- path: `/wp/v2/pages/${id}`,
40
- params: {
41
- force: true
42
- }
43
- });
44
- }
45
- async function deleteAllPages() {
46
- const pages = await this.rest({
47
- path: "/wp/v2/pages",
48
- params: {
49
- per_page: 100,
50
- status: PAGE_STATUS.join(",")
51
- }
52
- });
53
- await Promise.all(
54
- pages.map((page) => deletePage.call(this, page.id))
55
- );
56
- }
57
- async function createPage(payload) {
58
- const page = await this.rest({
59
- method: "POST",
60
- path: `/wp/v2/pages`,
61
- data: { ...payload }
62
- });
63
- return page;
64
- }
65
- // Annotate the CommonJS export names for ESM import in node:
66
- 0 && (module.exports = {
67
- createPage,
68
- deleteAllPages,
69
- deletePage
70
- });
71
- //# sourceMappingURL=pages.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/pages.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nconst PAGE_STATUS = [\n\t'publish',\n\t'future',\n\t'draft',\n\t'pending',\n\t'private',\n\t'trash',\n] as const;\n\nexport type Page = {\n\tid: number;\n\tstatus: ( typeof PAGE_STATUS )[ number ];\n};\n\nexport type CreatePagePayload = {\n\ttitle?: string;\n\tcontent?: string;\n\tstatus: ( typeof PAGE_STATUS )[ number ];\n\tdate?: string;\n\tdate_gmt?: string;\n};\n\nexport async function deletePage( this: RequestUtils, id: number ) {\n\t// https://developer.wordpress.org/rest-api/reference/pages/#delete-a-page\n\treturn await this.rest( {\n\t\tmethod: 'DELETE',\n\t\tpath: `/wp/v2/pages/${ id }`,\n\t\tparams: {\n\t\t\tforce: true,\n\t\t},\n\t} );\n}\n\n/**\n * Delete all pages using REST API.\n *\n * @param this\n */\nexport async function deleteAllPages( this: RequestUtils ) {\n\t// List all pages.\n\t// https://developer.wordpress.org/rest-api/reference/pages/#list-pages\n\tconst pages = await this.rest< Page[] >( {\n\t\tpath: '/wp/v2/pages',\n\t\tparams: {\n\t\t\tper_page: 100,\n\n\t\t\tstatus: PAGE_STATUS.join( ',' ),\n\t\t},\n\t} );\n\n\t// Delete all pages one by one.\n\t// \"/wp/v2/pages\" not yet supports batch requests.\n\tawait Promise.all(\n\t\tpages.map( ( page ) => deletePage.call( this, page.id ) )\n\t);\n}\n\n/**\n * Create a new page.\n *\n * @param this\n * @param payload The page payload.\n */\nexport async function createPage(\n\tthis: RequestUtils,\n\tpayload: CreatePagePayload\n) {\n\t// https://developer.wordpress.org/rest-api/reference/pages/#create-a-page\n\tconst page = await this.rest< Page >( {\n\t\tmethod: 'POST',\n\t\tpath: `/wp/v2/pages`,\n\t\tdata: { ...payload },\n\t} );\n\n\treturn page;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAM,cAAc;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAeA,eAAsB,WAAgC,IAAa;AAElE,SAAO,MAAM,KAAK,KAAM;AAAA,IACvB,QAAQ;AAAA,IACR,MAAM,gBAAiB,EAAG;AAAA,IAC1B,QAAQ;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACD,CAAE;AACH;AAOA,eAAsB,iBAAqC;AAG1D,QAAM,QAAQ,MAAM,KAAK,KAAgB;AAAA,IACxC,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,MAEV,QAAQ,YAAY,KAAM,GAAI;AAAA,IAC/B;AAAA,EACD,CAAE;AAIF,QAAM,QAAQ;AAAA,IACb,MAAM,IAAK,CAAE,SAAU,WAAW,KAAM,MAAM,KAAK,EAAG,CAAE;AAAA,EACzD;AACD;AAQA,eAAsB,WAErB,SACC;AAED,QAAM,OAAO,MAAM,KAAK,KAAc;AAAA,IACrC,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM,EAAE,GAAG,QAAQ;AAAA,EACpB,CAAE;AAEF,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,44 +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/patterns.ts
21
- var patterns_exports = {};
22
- __export(patterns_exports, {
23
- deleteAllPatternCategories: () => deleteAllPatternCategories
24
- });
25
- module.exports = __toCommonJS(patterns_exports);
26
- async function deleteAllPatternCategories() {
27
- const categories = await this.rest({
28
- path: "/wp/v2/wp_pattern_category",
29
- params: {
30
- per_page: 100
31
- }
32
- });
33
- await this.batchRest(
34
- categories.map((category) => ({
35
- method: "DELETE",
36
- path: `/wp/v2/wp_pattern_category/${category.id}?force=true`
37
- }))
38
- );
39
- }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- deleteAllPatternCategories
43
- });
44
- //# sourceMappingURL=patterns.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/patterns.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Delete all pattern categories using REST API.\n *\n * @see https://developer.wordpress.org/rest-api/reference/categories/#list-categories\n * @param this\n */\nexport async function deleteAllPatternCategories( this: RequestUtils ) {\n\t// List all pattern categories.\n\t// https://developer.wordpress.org/rest-api/reference/categories/#list-categories\n\tconst categories = await this.rest( {\n\t\tpath: '/wp/v2/wp_pattern_category',\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t},\n\t} );\n\n\t// Delete pattern categories.\n\t// https://developer.wordpress.org/rest-api/reference/categories/#delete-a-category\n\t// \"/wp/v2/category\" does not yet supports batch requests.\n\tawait this.batchRest(\n\t\tcategories.map( ( category: { id: number } ) => ( {\n\t\t\tmethod: 'DELETE',\n\t\t\tpath: `/wp/v2/wp_pattern_category/${ category.id }?force=true`,\n\t\t} ) )\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,eAAsB,6BAAiD;AAGtE,QAAM,aAAa,MAAM,KAAK,KAAM;AAAA,IACnC,MAAM;AAAA,IACN,QAAQ;AAAA,MACP,UAAU;AAAA,IACX;AAAA,EACD,CAAE;AAKF,QAAM,KAAK;AAAA,IACV,WAAW,IAAK,CAAE,cAAgC;AAAA,MACjD,QAAQ;AAAA,MACR,MAAM,8BAA+B,SAAS,EAAG;AAAA,IAClD,EAAI;AAAA,EACL;AACD;",
6
- "names": []
7
- }
@@ -1,81 +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/plugins.ts
21
- var plugins_exports = {};
22
- __export(plugins_exports, {
23
- activatePlugin: () => activatePlugin,
24
- deactivatePlugin: () => deactivatePlugin,
25
- getPluginsMap: () => getPluginsMap
26
- });
27
- module.exports = __toCommonJS(plugins_exports);
28
- var import_change_case = require("change-case");
29
- async function getPluginsMap(forceRefetch = false) {
30
- if (!forceRefetch && this.pluginsMap) {
31
- return this.pluginsMap;
32
- }
33
- const plugins = await this.rest({
34
- path: "/wp/v2/plugins"
35
- });
36
- this.pluginsMap = {};
37
- for (const plugin of plugins) {
38
- const slug = (0, import_change_case.paramCase)(plugin.name.toLowerCase());
39
- this.pluginsMap[slug] = plugin.plugin;
40
- }
41
- return this.pluginsMap;
42
- }
43
- function getPluginFromMap(slug, pluginsMap) {
44
- const plugin = pluginsMap[slug];
45
- if (!plugin) {
46
- for (const key of Object.keys(pluginsMap)) {
47
- if (key.toLowerCase().replace(/-/g, "") === slug.toLowerCase().replace(/-/g, "")) {
48
- throw new Error(
49
- `The plugin "${slug}" isn't installed. Did you perhaps mean "${key}"?`
50
- );
51
- }
52
- }
53
- throw new Error(`The plugin "${slug}" isn't installed`);
54
- }
55
- return plugin;
56
- }
57
- async function activatePlugin(slug) {
58
- const pluginsMap = await this.getPluginsMap();
59
- const plugin = getPluginFromMap(slug, pluginsMap);
60
- await this.rest({
61
- method: "PUT",
62
- path: `/wp/v2/plugins/${plugin}`,
63
- data: { status: "active" }
64
- });
65
- }
66
- async function deactivatePlugin(slug) {
67
- const pluginsMap = await this.getPluginsMap();
68
- const plugin = getPluginFromMap(slug, pluginsMap);
69
- await this.rest({
70
- method: "PUT",
71
- path: `/wp/v2/plugins/${plugin}`,
72
- data: { status: "inactive" }
73
- });
74
- }
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- activatePlugin,
78
- deactivatePlugin,
79
- getPluginsMap
80
- });
81
- //# sourceMappingURL=plugins.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/plugins.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Fetch the plugins from API and cache them in memory,\n * since they are unlikely to change during testing.\n *\n * @param this\n * @param forceRefetch Force refetch the installed plugins to update the cache.\n */\nasync function getPluginsMap( this: RequestUtils, forceRefetch = false ) {\n\tif ( ! forceRefetch && this.pluginsMap ) {\n\t\treturn this.pluginsMap;\n\t}\n\n\tconst plugins = await this.rest( {\n\t\tpath: '/wp/v2/plugins',\n\t} );\n\tthis.pluginsMap = {};\n\tfor ( const plugin of plugins ) {\n\t\t// Ideally, we should be using sanitize_title() in PHP rather than kebabCase(),\n\t\t// but we don't have the exact port of it in JS.\n\t\t// This is a good approximation though.\n\t\tconst slug = kebabCase( plugin.name.toLowerCase() );\n\t\tthis.pluginsMap[ slug ] = plugin.plugin;\n\t}\n\treturn this.pluginsMap;\n}\n\n/**\n * Finds a plugin in the plugin map.\n *\n * Attempts to provide a helpful error message if not found.\n *\n * @param slug Plugin slug.\n * @param pluginsMap Plugins map.\n */\nfunction getPluginFromMap(\n\tslug: string,\n\tpluginsMap: Record< string, string >\n) {\n\tconst plugin = pluginsMap[ slug ];\n\n\tif ( ! plugin ) {\n\t\tfor ( const key of Object.keys( pluginsMap ) ) {\n\t\t\tif (\n\t\t\t\tkey.toLowerCase().replace( /-/g, '' ) ===\n\t\t\t\tslug.toLowerCase().replace( /-/g, '' )\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The plugin \"${ slug }\" isn't installed. Did you perhaps mean \"${ key }\"?`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error( `The plugin \"${ slug }\" isn't installed` );\n\t}\n\n\treturn plugin;\n}\n\n/**\n * Activates an installed plugin.\n *\n * @param this RequestUtils.\n * @param slug Plugin slug.\n */\nasync function activatePlugin( this: RequestUtils, slug: string ) {\n\tconst pluginsMap = await this.getPluginsMap();\n\tconst plugin = getPluginFromMap( slug, pluginsMap );\n\n\tawait this.rest( {\n\t\tmethod: 'PUT',\n\t\tpath: `/wp/v2/plugins/${ plugin }`,\n\t\tdata: { status: 'active' },\n\t} );\n}\n\n/**\n * Deactivates an active plugin.\n *\n * @param this RequestUtils.\n * @param slug Plugin slug.\n */\nasync function deactivatePlugin( this: RequestUtils, slug: string ) {\n\tconst pluginsMap = await this.getPluginsMap();\n\tconst plugin = getPluginFromMap( slug, pluginsMap );\n\n\tawait this.rest( {\n\t\tmethod: 'PUT',\n\t\tpath: `/wp/v2/plugins/${ plugin }`,\n\t\tdata: { status: 'inactive' },\n\t} );\n}\n\nexport { getPluginsMap, activatePlugin, deactivatePlugin };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAuC;AAcvC,eAAe,cAAmC,eAAe,OAAQ;AACxE,MAAK,CAAE,gBAAgB,KAAK,YAAa;AACxC,WAAO,KAAK;AAAA,EACb;AAEA,QAAM,UAAU,MAAM,KAAK,KAAM;AAAA,IAChC,MAAM;AAAA,EACP,CAAE;AACF,OAAK,aAAa,CAAC;AACnB,aAAY,UAAU,SAAU;AAI/B,UAAM,WAAO,mBAAAA,WAAW,OAAO,KAAK,YAAY,CAAE;AAClD,SAAK,WAAY,IAAK,IAAI,OAAO;AAAA,EAClC;AACA,SAAO,KAAK;AACb;AAUA,SAAS,iBACR,MACA,YACC;AACD,QAAM,SAAS,WAAY,IAAK;AAEhC,MAAK,CAAE,QAAS;AACf,eAAY,OAAO,OAAO,KAAM,UAAW,GAAI;AAC9C,UACC,IAAI,YAAY,EAAE,QAAS,MAAM,EAAG,MACpC,KAAK,YAAY,EAAE,QAAS,MAAM,EAAG,GACpC;AACD,cAAM,IAAI;AAAA,UACT,eAAgB,IAAK,4CAA6C,GAAI;AAAA,QACvE;AAAA,MACD;AAAA,IACD;AAEA,UAAM,IAAI,MAAO,eAAgB,IAAK,mBAAoB;AAAA,EAC3D;AAEA,SAAO;AACR;AAQA,eAAe,eAAoC,MAAe;AACjE,QAAM,aAAa,MAAM,KAAK,cAAc;AAC5C,QAAM,SAAS,iBAAkB,MAAM,UAAW;AAElD,QAAM,KAAK,KAAM;AAAA,IAChB,QAAQ;AAAA,IACR,MAAM,kBAAmB,MAAO;AAAA,IAChC,MAAM,EAAE,QAAQ,SAAS;AAAA,EAC1B,CAAE;AACH;AAQA,eAAe,iBAAsC,MAAe;AACnE,QAAM,aAAa,MAAM,KAAK,cAAc;AAC5C,QAAM,SAAS,iBAAkB,MAAM,UAAW;AAElD,QAAM,KAAK,KAAM;AAAA,IAChB,QAAQ;AAAA,IACR,MAAM,kBAAmB,MAAO;AAAA,IAChC,MAAM,EAAE,QAAQ,WAAW;AAAA,EAC5B,CAAE;AACH;",
6
- "names": ["kebabCase"]
7
- }
@@ -1,61 +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/posts.ts
21
- var posts_exports = {};
22
- __export(posts_exports, {
23
- createPost: () => createPost,
24
- deleteAllPosts: () => deleteAllPosts
25
- });
26
- module.exports = __toCommonJS(posts_exports);
27
- async function deleteAllPosts(postType = "posts") {
28
- const posts = await this.rest({
29
- path: `/wp/v2/${postType}`,
30
- params: {
31
- per_page: 100,
32
- // All possible statuses.
33
- status: "publish,future,draft,pending,private,trash"
34
- }
35
- });
36
- await Promise.all(
37
- posts.map(
38
- (post) => this.rest({
39
- method: "DELETE",
40
- path: `/wp/v2/${postType}/${post.id}`,
41
- params: {
42
- force: true
43
- }
44
- })
45
- )
46
- );
47
- }
48
- async function createPost(payload) {
49
- const post = await this.rest({
50
- method: "POST",
51
- path: `/wp/v2/posts`,
52
- data: { ...payload }
53
- });
54
- return post;
55
- }
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- createPost,
59
- deleteAllPosts
60
- });
61
- //# sourceMappingURL=posts.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/posts.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface Post {\n\tid: number;\n\tcontent: string;\n\tstatus: 'publish' | 'future' | 'draft' | 'pending' | 'private';\n\tlink: string;\n}\n\nexport interface CreatePostPayload {\n\ttitle?: string;\n\tcontent?: string;\n\tstatus: 'publish' | 'future' | 'draft' | 'pending' | 'private';\n\tdate?: string;\n\tdate_gmt: string;\n}\n\n/**\n * Delete all posts using REST API.\n *\n * @param this\n * @param postType The type of post to delete. Defaults to 'posts'.\n */\nexport async function deleteAllPosts(\n\tthis: RequestUtils,\n\tpostType: string = 'posts'\n) {\n\t// List all posts.\n\t// https://developer.wordpress.org/rest-api/reference/posts/#list-posts\n\tconst posts = await this.rest< Post[] >( {\n\t\tpath: `/wp/v2/${ postType }`,\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t\t// All possible statuses.\n\t\t\tstatus: 'publish,future,draft,pending,private,trash',\n\t\t},\n\t} );\n\n\t// Delete all posts one by one.\n\t// https://developer.wordpress.org/rest-api/reference/posts/#delete-a-post\n\t// \"/wp/v2/posts\" not yet supports batch requests.\n\tawait Promise.all(\n\t\tposts.map( ( post ) =>\n\t\t\tthis.rest( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\tpath: `/wp/v2/${ postType }/${ post.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\n/**\n * Creates a new post using the REST API.\n *\n * @param this\n * @param payload Post attributes.\n */\nexport async function createPost(\n\tthis: RequestUtils,\n\tpayload: CreatePostPayload\n) {\n\tconst post = await this.rest< Post >( {\n\t\tmethod: 'POST',\n\t\tpath: `/wp/v2/posts`,\n\t\tdata: { ...payload },\n\t} );\n\n\treturn post;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,eAAsB,eAErB,WAAmB,SAClB;AAGD,QAAM,QAAQ,MAAM,KAAK,KAAgB;AAAA,IACxC,MAAM,UAAW,QAAS;AAAA,IAC1B,QAAQ;AAAA,MACP,UAAU;AAAA;AAAA,MAEV,QAAQ;AAAA,IACT;AAAA,EACD,CAAE;AAKF,QAAM,QAAQ;AAAA,IACb,MAAM;AAAA,MAAK,CAAE,SACZ,KAAK,KAAM;AAAA,QACV,QAAQ;AAAA,QACR,MAAM,UAAW,QAAS,IAAK,KAAK,EAAG;AAAA,QACvC,QAAQ;AAAA,UACP,OAAO;AAAA,QACR;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AACD;AAQA,eAAsB,WAErB,SACC;AACD,QAAM,OAAO,MAAM,KAAK,KAAc;AAAA,IACrC,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM,EAAE,GAAG,QAAQ;AAAA,EACpB,CAAE;AAEF,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/e2e-test-utils-playwright/src/request-utils/preferences.ts
21
- var preferences_exports = {};
22
- __export(preferences_exports, {
23
- resetPreferences: () => resetPreferences
24
- });
25
- module.exports = __toCommonJS(preferences_exports);
26
- async function resetPreferences() {
27
- await this.rest({
28
- path: "/wp/v2/users/me",
29
- method: "PUT",
30
- data: {
31
- meta: {
32
- persisted_preferences: {}
33
- }
34
- }
35
- });
36
- }
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- resetPreferences
40
- });
41
- //# sourceMappingURL=preferences.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/preferences.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Reset user preferences\n *\n * @param this Request utils.\n */\nexport async function resetPreferences( this: RequestUtils ) {\n\tawait this.rest( {\n\t\tpath: '/wp/v2/users/me',\n\t\tmethod: 'PUT',\n\t\tdata: {\n\t\t\tmeta: {\n\t\t\t\tpersisted_preferences: {},\n\t\t\t},\n\t\t},\n\t} );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAsB,mBAAuC;AAC5D,QAAM,KAAK,KAAM;AAAA,IAChB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,MAAM;AAAA,QACL,uBAAuB,CAAC;AAAA,MACzB;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
6
- "names": []
7
- }