@wordpress/e2e-test-utils-playwright 1.37.0 → 1.37.1-next.06ee73755.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 (228) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/admin/create-new-post.cjs +51 -0
  3. package/build/admin/create-new-post.cjs.map +7 -0
  4. package/build/admin/create-new-post.js +28 -48
  5. package/build/admin/create-new-post.js.map +1 -7
  6. package/build/admin/edit-post.cjs +40 -0
  7. package/build/admin/edit-post.cjs.map +7 -0
  8. package/build/admin/edit-post.js +17 -37
  9. package/build/admin/edit-post.js.map +1 -7
  10. package/build/admin/get-page-error.cjs +36 -0
  11. package/build/admin/get-page-error.cjs.map +7 -0
  12. package/build/admin/get-page-error.js +23 -33
  13. package/build/admin/get-page-error.js.map +1 -7
  14. package/build/admin/index.cjs +59 -0
  15. package/build/admin/index.cjs.map +7 -0
  16. package/build/admin/index.js +36 -58
  17. package/build/admin/index.js.map +1 -7
  18. package/build/admin/visit-admin-page.cjs +47 -0
  19. package/build/admin/visit-admin-page.cjs.map +7 -0
  20. package/build/admin/visit-admin-page.js +29 -44
  21. package/build/admin/visit-admin-page.js.map +1 -7
  22. package/build/admin/visit-site-editor.cjs +77 -0
  23. package/build/admin/visit-site-editor.cjs.map +7 -0
  24. package/build/admin/visit-site-editor.js +64 -73
  25. package/build/admin/visit-site-editor.js.map +1 -7
  26. package/build/config.cjs +45 -0
  27. package/build/config.cjs.map +7 -0
  28. package/build/config.js +11 -43
  29. package/build/config.js.map +1 -7
  30. package/build/editor/click-block-options-menu-item.cjs +34 -0
  31. package/build/editor/click-block-options-menu-item.cjs.map +7 -0
  32. package/build/editor/click-block-options-menu-item.js +14 -31
  33. package/build/editor/click-block-options-menu-item.js.map +1 -7
  34. package/build/editor/click-block-toolbar-button.cjs +38 -0
  35. package/build/editor/click-block-toolbar-button.cjs.map +7 -0
  36. package/build/editor/click-block-toolbar-button.js +13 -35
  37. package/build/editor/click-block-toolbar-button.js.map +1 -7
  38. package/build/editor/get-blocks.cjs +64 -0
  39. package/build/editor/get-blocks.cjs.map +7 -0
  40. package/build/editor/get-blocks.js +43 -61
  41. package/build/editor/get-blocks.js.map +1 -7
  42. package/build/editor/get-edited-post-content.cjs +36 -0
  43. package/build/editor/get-edited-post-content.cjs.map +7 -0
  44. package/build/editor/get-edited-post-content.js +12 -33
  45. package/build/editor/get-edited-post-content.js.map +1 -7
  46. package/build/editor/index.cjs +97 -0
  47. package/build/editor/index.cjs.map +7 -0
  48. package/build/editor/index.js +74 -96
  49. package/build/editor/index.js.map +1 -7
  50. package/build/editor/insert-block.cjs +55 -0
  51. package/build/editor/insert-block.cjs.map +7 -0
  52. package/build/editor/insert-block.js +21 -52
  53. package/build/editor/insert-block.js.map +1 -7
  54. package/build/editor/open-document-settings-sidebar.cjs +42 -0
  55. package/build/editor/open-document-settings-sidebar.cjs.map +7 -0
  56. package/build/editor/open-document-settings-sidebar.js +24 -39
  57. package/build/editor/open-document-settings-sidebar.js.map +1 -7
  58. package/build/editor/preview.cjs +42 -0
  59. package/build/editor/preview.cjs.map +7 -0
  60. package/build/editor/preview.js +18 -39
  61. package/build/editor/preview.js.map +1 -7
  62. package/build/editor/publish-post.cjs +47 -0
  63. package/build/editor/publish-post.cjs.map +7 -0
  64. package/build/editor/publish-post.js +42 -44
  65. package/build/editor/publish-post.js.map +1 -7
  66. package/build/editor/save-draft.cjs +34 -0
  67. package/build/editor/save-draft.cjs.map +7 -0
  68. package/build/editor/save-draft.js +15 -31
  69. package/build/editor/save-draft.js.map +1 -7
  70. package/build/editor/select-blocks.cjs +51 -0
  71. package/build/editor/select-blocks.cjs.map +7 -0
  72. package/build/editor/select-blocks.js +25 -48
  73. package/build/editor/select-blocks.js.map +1 -7
  74. package/build/editor/set-content.cjs +39 -0
  75. package/build/editor/set-content.cjs.map +7 -0
  76. package/build/editor/set-content.js +14 -36
  77. package/build/editor/set-content.js.map +1 -7
  78. package/build/editor/set-is-fixed-toolbar.cjs +36 -0
  79. package/build/editor/set-is-fixed-toolbar.cjs.map +7 -0
  80. package/build/editor/set-is-fixed-toolbar.js +15 -33
  81. package/build/editor/set-is-fixed-toolbar.js.map +1 -7
  82. package/build/editor/set-preferences.cjs +43 -0
  83. package/build/editor/set-preferences.cjs.map +7 -0
  84. package/build/editor/set-preferences.js +18 -40
  85. package/build/editor/set-preferences.js.map +1 -7
  86. package/build/editor/show-block-toolbar.cjs +35 -0
  87. package/build/editor/show-block-toolbar.cjs.map +7 -0
  88. package/build/editor/show-block-toolbar.js +16 -32
  89. package/build/editor/show-block-toolbar.js.map +1 -7
  90. package/build/editor/site-editor.cjs +51 -0
  91. package/build/editor/site-editor.cjs.map +7 -0
  92. package/build/editor/site-editor.js +41 -48
  93. package/build/editor/site-editor.js.map +1 -7
  94. package/build/editor/switch-editor-tool.cjs +47 -0
  95. package/build/editor/switch-editor-tool.cjs.map +7 -0
  96. package/build/editor/switch-editor-tool.js +30 -44
  97. package/build/editor/switch-editor-tool.js.map +1 -7
  98. package/build/editor/switch-to-legacy-canvas.cjs +39 -0
  99. package/build/editor/switch-to-legacy-canvas.cjs.map +7 -0
  100. package/build/editor/switch-to-legacy-canvas.js +14 -35
  101. package/build/editor/switch-to-legacy-canvas.js.map +1 -7
  102. package/build/editor/transform-block-to.cjs +46 -0
  103. package/build/editor/transform-block-to.cjs.map +7 -0
  104. package/build/editor/transform-block-to.js +21 -43
  105. package/build/editor/transform-block-to.js.map +1 -7
  106. package/build/index.cjs +51 -0
  107. package/build/index.cjs.map +7 -0
  108. package/build/index.js +18 -53
  109. package/build/index.js.map +1 -7
  110. package/build/lighthouse/index.cjs +96 -0
  111. package/build/lighthouse/index.cjs.map +7 -0
  112. package/build/lighthouse/index.js +55 -93
  113. package/build/lighthouse/index.js.map +1 -7
  114. package/build/metrics/index.cjs +309 -0
  115. package/build/metrics/index.cjs.map +7 -0
  116. package/build/metrics/index.js +251 -302
  117. package/build/metrics/index.js.map +1 -7
  118. package/build/page-utils/drag-files.cjs +143 -0
  119. package/build/page-utils/drag-files.cjs.map +7 -0
  120. package/build/page-utils/drag-files.js +112 -136
  121. package/build/page-utils/drag-files.js.map +1 -7
  122. package/build/page-utils/emulate-network-conditions.cjs +99 -0
  123. package/build/page-utils/emulate-network-conditions.cjs.map +7 -0
  124. package/build/page-utils/emulate-network-conditions.js +67 -95
  125. package/build/page-utils/emulate-network-conditions.js.map +1 -7
  126. package/build/page-utils/index.cjs +59 -0
  127. package/build/page-utils/index.cjs.map +7 -0
  128. package/build/page-utils/index.js +36 -58
  129. package/build/page-utils/index.js.map +1 -7
  130. package/build/page-utils/is-current-url.cjs +36 -0
  131. package/build/page-utils/is-current-url.cjs.map +7 -0
  132. package/build/page-utils/is-current-url.js +18 -33
  133. package/build/page-utils/is-current-url.js.map +1 -7
  134. package/build/page-utils/keycodes.cjs +55 -0
  135. package/build/page-utils/keycodes.cjs.map +7 -0
  136. package/build/page-utils/keycodes.js +39 -53
  137. package/build/page-utils/keycodes.js.map +1 -7
  138. package/build/page-utils/press-keys.cjs +165 -0
  139. package/build/page-utils/press-keys.cjs.map +7 -0
  140. package/build/page-utils/press-keys.js +130 -153
  141. package/build/page-utils/press-keys.js.map +1 -7
  142. package/build/page-utils/set-browser-viewport.cjs +39 -0
  143. package/build/page-utils/set-browser-viewport.cjs.map +7 -0
  144. package/build/page-utils/set-browser-viewport.js +42 -35
  145. package/build/page-utils/set-browser-viewport.js.map +1 -7
  146. package/build/request-utils/blocks.cjs +56 -0
  147. package/build/request-utils/blocks.cjs.map +7 -0
  148. package/build/request-utils/blocks.js +40 -51
  149. package/build/request-utils/blocks.js.map +1 -7
  150. package/build/request-utils/comments.cjs +66 -0
  151. package/build/request-utils/comments.cjs.map +7 -0
  152. package/build/request-utils/comments.js +45 -59
  153. package/build/request-utils/comments.js.map +1 -7
  154. package/build/request-utils/gutenberg-experiments.cjs +66 -0
  155. package/build/request-utils/gutenberg-experiments.cjs.map +7 -0
  156. package/build/request-utils/gutenberg-experiments.js +38 -63
  157. package/build/request-utils/gutenberg-experiments.js.map +1 -7
  158. package/build/request-utils/index.cjs +194 -0
  159. package/build/request-utils/index.cjs.map +7 -0
  160. package/build/request-utils/index.js +155 -191
  161. package/build/request-utils/index.js.map +1 -7
  162. package/build/request-utils/login.cjs +48 -0
  163. package/build/request-utils/login.cjs.map +7 -0
  164. package/build/request-utils/login.js +18 -45
  165. package/build/request-utils/login.js.map +1 -7
  166. package/build/request-utils/media.cjs +83 -0
  167. package/build/request-utils/media.cjs.map +7 -0
  168. package/build/request-utils/media.js +64 -74
  169. package/build/request-utils/media.js.map +1 -7
  170. package/build/request-utils/menus.cjs +132 -0
  171. package/build/request-utils/menus.cjs.map +7 -0
  172. package/build/request-utils/menus.js +109 -121
  173. package/build/request-utils/menus.js.map +1 -7
  174. package/build/request-utils/pages.cjs +71 -0
  175. package/build/request-utils/pages.cjs.map +7 -0
  176. package/build/request-utils/pages.js +50 -63
  177. package/build/request-utils/pages.js.map +1 -7
  178. package/build/request-utils/patterns.cjs +44 -0
  179. package/build/request-utils/patterns.cjs.map +7 -0
  180. package/build/request-utils/patterns.js +24 -41
  181. package/build/request-utils/patterns.js.map +1 -7
  182. package/build/request-utils/plugins.cjs +81 -0
  183. package/build/request-utils/plugins.cjs.map +7 -0
  184. package/build/request-utils/plugins.js +74 -70
  185. package/build/request-utils/plugins.js.map +1 -7
  186. package/build/request-utils/posts.cjs +61 -0
  187. package/build/request-utils/posts.cjs.map +7 -0
  188. package/build/request-utils/posts.js +41 -55
  189. package/build/request-utils/posts.js.map +1 -7
  190. package/build/request-utils/preferences.cjs +41 -0
  191. package/build/request-utils/preferences.cjs.map +7 -0
  192. package/build/request-utils/preferences.js +17 -38
  193. package/build/request-utils/preferences.js.map +1 -7
  194. package/build/request-utils/rest.cjs +174 -0
  195. package/build/request-utils/rest.cjs.map +7 -0
  196. package/build/request-utils/rest.js +129 -155
  197. package/build/request-utils/rest.js.map +1 -7
  198. package/build/request-utils/site-settings.cjs +45 -0
  199. package/build/request-utils/site-settings.cjs.map +7 -0
  200. package/build/request-utils/site-settings.js +28 -40
  201. package/build/request-utils/site-settings.js.map +1 -7
  202. package/build/request-utils/templates.cjs +68 -0
  203. package/build/request-utils/templates.cjs.map +7 -0
  204. package/build/request-utils/templates.js +46 -60
  205. package/build/request-utils/templates.js.map +1 -7
  206. package/build/request-utils/themes.cjs +89 -0
  207. package/build/request-utils/themes.cjs.map +7 -0
  208. package/build/request-utils/themes.js +53 -80
  209. package/build/request-utils/themes.js.map +1 -7
  210. package/build/request-utils/users.cjs +83 -0
  211. package/build/request-utils/users.cjs.map +7 -0
  212. package/build/request-utils/users.js +72 -74
  213. package/build/request-utils/users.js.map +1 -7
  214. package/build/request-utils/widgets.cjs +79 -0
  215. package/build/request-utils/widgets.cjs.map +7 -0
  216. package/build/request-utils/widgets.js +55 -73
  217. package/build/request-utils/widgets.js.map +1 -7
  218. package/build/test.cjs +136 -0
  219. package/build/test.cjs.map +7 -0
  220. package/build/test.js +146 -130
  221. package/build/test.js.map +1 -7
  222. package/build/types.cjs +19 -0
  223. package/build/types.cjs.map +7 -0
  224. package/build/types.js +2 -18
  225. package/build/types.js.map +1 -7
  226. package/build-types/index.d.ts +1 -1
  227. package/build-types/index.d.ts.map +1 -1
  228. package/package.json +9 -5
@@ -0,0 +1,7 @@
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,71 +1,58 @@
1
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"
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deletePage = deletePage;
4
+ exports.deleteAllPages = deleteAllPages;
5
+ exports.createPage = createPage;
6
+ const PAGE_STATUS = [
7
+ 'publish',
8
+ 'future',
9
+ 'draft',
10
+ 'pending',
11
+ 'private',
12
+ 'trash',
35
13
  ];
36
14
  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
- });
15
+ // https://developer.wordpress.org/rest-api/reference/pages/#delete-a-page
16
+ return await this.rest({
17
+ method: 'DELETE',
18
+ path: `/wp/v2/pages/${id}`,
19
+ params: {
20
+ force: true,
21
+ },
22
+ });
44
23
  }
24
+ /**
25
+ * Delete all pages using REST API.
26
+ *
27
+ * @param this
28
+ */
45
29
  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
- );
30
+ // List all pages.
31
+ // https://developer.wordpress.org/rest-api/reference/pages/#list-pages
32
+ const pages = await this.rest({
33
+ path: '/wp/v2/pages',
34
+ params: {
35
+ per_page: 100,
36
+ status: PAGE_STATUS.join(','),
37
+ },
38
+ });
39
+ // Delete all pages one by one.
40
+ // "/wp/v2/pages" not yet supports batch requests.
41
+ await Promise.all(pages.map((page) => deletePage.call(this, page.id)));
56
42
  }
43
+ /**
44
+ * Create a new page.
45
+ *
46
+ * @param this
47
+ * @param payload The page payload.
48
+ */
57
49
  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;
50
+ // https://developer.wordpress.org/rest-api/reference/pages/#create-a-page
51
+ const page = await this.rest({
52
+ method: 'POST',
53
+ path: `/wp/v2/pages`,
54
+ data: { ...payload },
55
+ });
56
+ return page;
64
57
  }
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.js.map
58
+ //# sourceMappingURL=pages.js.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"pages.js","sourceRoot":"","sources":["../../src/request-utils/pages.ts"],"names":[],"mappings":";;AA2BA,gCASC;AAOD,wCAiBC;AAQD,gCAYC;AA3ED,MAAM,WAAW,GAAG;IACnB,SAAS;IACT,QAAQ;IACR,OAAO;IACP,SAAS;IACT,SAAS;IACT,OAAO;CACE,CAAC;AAeJ,KAAK,UAAU,UAAU,CAAsB,EAAU;IAC/D,0EAA0E;IAC1E,OAAO,MAAM,IAAI,CAAC,IAAI,CAAE;QACvB,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,gBAAiB,EAAG,EAAE;QAC5B,MAAM,EAAE;YACP,KAAK,EAAE,IAAI;SACX;KACD,CAAE,CAAC;AACL,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,cAAc;IACnC,kBAAkB;IAClB,uEAAuE;IACvE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAY;QACxC,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;YAEb,MAAM,EAAE,WAAW,CAAC,IAAI,CAAE,GAAG,CAAE;SAC/B;KACD,CAAE,CAAC;IAEJ,+BAA+B;IAC/B,kDAAkD;IAClD,MAAM,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAE,CAAE,IAAI,EAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAE,CAAE,CACzD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAE/B,OAA0B;IAE1B,0EAA0E;IAC1E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAU;QACrC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE;KACpB,CAAE,CAAC;IAEJ,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,44 @@
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
@@ -0,0 +1,7 @@
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,44 +1,27 @@
1
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);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteAllPatternCategories = deleteAllPatternCategories;
4
+ /**
5
+ * Delete all pattern categories using REST API.
6
+ *
7
+ * @see https://developer.wordpress.org/rest-api/reference/categories/#list-categories
8
+ * @param this
9
+ */
26
10
  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
- );
11
+ // List all pattern categories.
12
+ // https://developer.wordpress.org/rest-api/reference/categories/#list-categories
13
+ const categories = await this.rest({
14
+ path: '/wp/v2/wp_pattern_category',
15
+ params: {
16
+ per_page: 100,
17
+ },
18
+ });
19
+ // Delete pattern categories.
20
+ // https://developer.wordpress.org/rest-api/reference/categories/#delete-a-category
21
+ // "/wp/v2/category" does not yet supports batch requests.
22
+ await this.batchRest(categories.map((category) => ({
23
+ method: 'DELETE',
24
+ path: `/wp/v2/wp_pattern_category/${category.id}?force=true`,
25
+ })));
39
26
  }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- deleteAllPatternCategories
43
- });
44
- //# sourceMappingURL=patterns.js.map
27
+ //# sourceMappingURL=patterns.js.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../src/request-utils/patterns.ts"],"names":[],"mappings":";;AAWA,gEAmBC;AAzBD;;;;;GAKG;AACI,KAAK,UAAU,0BAA0B;IAC/C,+BAA+B;IAC/B,iFAAiF;IACjF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QACnC,IAAI,EAAE,4BAA4B;QAClC,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;SACb;KACD,CAAE,CAAC;IAEJ,6BAA6B;IAC7B,mFAAmF;IACnF,0DAA0D;IAC1D,MAAM,IAAI,CAAC,SAAS,CACnB,UAAU,CAAC,GAAG,CAAE,CAAE,QAAwB,EAAG,EAAE,CAAC,CAAE;QACjD,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,8BAA+B,QAAQ,CAAC,EAAG,aAAa;KAC9D,CAAE,CAAE,CACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,81 @@
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
@@ -0,0 +1,7 @@
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,81 +1,85 @@
1
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");
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPluginsMap = getPluginsMap;
4
+ exports.activatePlugin = activatePlugin;
5
+ exports.deactivatePlugin = deactivatePlugin;
6
+ /**
7
+ * External dependencies
8
+ */
9
+ const change_case_1 = require("change-case");
10
+ /**
11
+ * Fetch the plugins from API and cache them in memory,
12
+ * since they are unlikely to change during testing.
13
+ *
14
+ * @param this
15
+ * @param forceRefetch Force refetch the installed plugins to update the cache.
16
+ */
29
17
  async function getPluginsMap(forceRefetch = false) {
30
- if (!forceRefetch && this.pluginsMap) {
18
+ if (!forceRefetch && this.pluginsMap) {
19
+ return this.pluginsMap;
20
+ }
21
+ const plugins = await this.rest({
22
+ path: '/wp/v2/plugins',
23
+ });
24
+ this.pluginsMap = {};
25
+ for (const plugin of plugins) {
26
+ // Ideally, we should be using sanitize_title() in PHP rather than kebabCase(),
27
+ // but we don't have the exact port of it in JS.
28
+ // This is a good approximation though.
29
+ const slug = (0, change_case_1.paramCase)(plugin.name.toLowerCase());
30
+ this.pluginsMap[slug] = plugin.plugin;
31
+ }
31
32
  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
33
  }
34
+ /**
35
+ * Finds a plugin in the plugin map.
36
+ *
37
+ * Attempts to provide a helpful error message if not found.
38
+ *
39
+ * @param slug Plugin slug.
40
+ * @param pluginsMap Plugins map.
41
+ */
43
42
  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
- }
43
+ const plugin = pluginsMap[slug];
44
+ if (!plugin) {
45
+ for (const key of Object.keys(pluginsMap)) {
46
+ if (key.toLowerCase().replace(/-/g, '') ===
47
+ slug.toLowerCase().replace(/-/g, '')) {
48
+ throw new Error(`The plugin "${slug}" isn't installed. Did you perhaps mean "${key}"?`);
49
+ }
50
+ }
51
+ throw new Error(`The plugin "${slug}" isn't installed`);
52
52
  }
53
- throw new Error(`The plugin "${slug}" isn't installed`);
54
- }
55
- return plugin;
53
+ return plugin;
56
54
  }
55
+ /**
56
+ * Activates an installed plugin.
57
+ *
58
+ * @param this RequestUtils.
59
+ * @param slug Plugin slug.
60
+ */
57
61
  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
- });
62
+ const pluginsMap = await this.getPluginsMap();
63
+ const plugin = getPluginFromMap(slug, pluginsMap);
64
+ await this.rest({
65
+ method: 'PUT',
66
+ path: `/wp/v2/plugins/${plugin}`,
67
+ data: { status: 'active' },
68
+ });
65
69
  }
70
+ /**
71
+ * Deactivates an active plugin.
72
+ *
73
+ * @param this RequestUtils.
74
+ * @param slug Plugin slug.
75
+ */
66
76
  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
- });
77
+ const pluginsMap = await this.getPluginsMap();
78
+ const plugin = getPluginFromMap(slug, pluginsMap);
79
+ await this.rest({
80
+ method: 'PUT',
81
+ path: `/wp/v2/plugins/${plugin}`,
82
+ data: { status: 'inactive' },
83
+ });
74
84
  }
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.js.map
85
+ //# sourceMappingURL=plugins.js.map
@@ -1,7 +1 @@
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
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/request-utils/plugins.ts"],"names":[],"mappings":";;AAsGS,sCAAa;AAAE,wCAAc;AAAE,4CAAgB;AAtGxD;;GAEG;AACH,6CAAqD;AAOrD;;;;;;GAMG;AACH,KAAK,UAAU,aAAa,CAAsB,YAAY,GAAG,KAAK;IACrE,IAAK,CAAE,YAAY,IAAI,IAAI,CAAC,UAAU,EAAG,CAAC;QACzC,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAE;QAChC,IAAI,EAAE,gBAAgB;KACtB,CAAE,CAAC;IACJ,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACrB,KAAM,MAAM,MAAM,IAAI,OAAO,EAAG,CAAC;QAChC,+EAA+E;QAC/E,gDAAgD;QAChD,uCAAuC;QACvC,MAAM,IAAI,GAAG,IAAA,uBAAS,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAE,CAAC;QACpD,IAAI,CAAC,UAAU,CAAE,IAAI,CAAE,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC,UAAU,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,gBAAgB,CACxB,IAAY,EACZ,UAAoC;IAEpC,MAAM,MAAM,GAAG,UAAU,CAAE,IAAI,CAAE,CAAC;IAElC,IAAK,CAAE,MAAM,EAAG,CAAC;QAChB,KAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAE,UAAU,CAAE,EAAG,CAAC;YAC/C,IACC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAE,IAAI,EAAE,EAAE,CAAE;gBACrC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAE,IAAI,EAAE,EAAE,CAAE,EACrC,CAAC;gBACF,MAAM,IAAI,KAAK,CACd,eAAgB,IAAK,4CAA6C,GAAI,IAAI,CAC1E,CAAC;YACH,CAAC;QACF,CAAC;QAED,MAAM,IAAI,KAAK,CAAE,eAAgB,IAAK,mBAAmB,CAAE,CAAC;IAC7D,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,cAAc,CAAsB,IAAY;IAC9D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAE,IAAI,EAAE,UAAU,CAAE,CAAC;IAEpD,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAmB,MAAO,EAAE;QAClC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;KAC1B,CAAE,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,gBAAgB,CAAsB,IAAY;IAChE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;IAC9C,MAAM,MAAM,GAAG,gBAAgB,CAAE,IAAI,EAAE,UAAU,CAAE,CAAC;IAEpD,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAmB,MAAO,EAAE;QAClC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;KAC5B,CAAE,CAAC;AACL,CAAC"}
@@ -0,0 +1,61 @@
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
@@ -0,0 +1,7 @@
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
+ }