@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,85 +1,81 @@
1
1
  "use strict";
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
- */
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");
17
29
  async function getPluginsMap(forceRefetch = false) {
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
- }
30
+ if (!forceRefetch && this.pluginsMap) {
32
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;
33
42
  }
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
- */
42
43
  function getPluginFromMap(slug, pluginsMap) {
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`);
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
52
  }
53
- return plugin;
53
+ throw new Error(`The plugin "${slug}" isn't installed`);
54
+ }
55
+ return plugin;
54
56
  }
55
- /**
56
- * Activates an installed plugin.
57
- *
58
- * @param this RequestUtils.
59
- * @param slug Plugin slug.
60
- */
61
57
  async function activatePlugin(slug) {
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
- });
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
+ });
69
65
  }
70
- /**
71
- * Deactivates an active plugin.
72
- *
73
- * @param this RequestUtils.
74
- * @param slug Plugin slug.
75
- */
76
66
  async function deactivatePlugin(slug) {
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
- });
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
+ });
84
74
  }
85
- //# sourceMappingURL=plugins.js.map
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
@@ -1 +1,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"}
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,47 +1,61 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteAllPosts = deleteAllPosts;
4
- exports.createPost = createPost;
5
- /**
6
- * Delete all posts using REST API.
7
- *
8
- * @param this
9
- * @param postType The type of post to delete. Defaults to 'posts'.
10
- */
11
- async function deleteAllPosts(postType = 'posts') {
12
- // List all posts.
13
- // https://developer.wordpress.org/rest-api/reference/posts/#list-posts
14
- const posts = await this.rest({
15
- path: `/wp/v2/${postType}`,
16
- params: {
17
- per_page: 100,
18
- // All possible statuses.
19
- status: 'publish,future,draft,pending,private,trash',
20
- },
21
- });
22
- // Delete all posts one by one.
23
- // https://developer.wordpress.org/rest-api/reference/posts/#delete-a-post
24
- // "/wp/v2/posts" not yet supports batch requests.
25
- await Promise.all(posts.map((post) => this.rest({
26
- method: 'DELETE',
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",
27
40
  path: `/wp/v2/${postType}/${post.id}`,
28
41
  params: {
29
- force: true,
30
- },
31
- })));
42
+ force: true
43
+ }
44
+ })
45
+ )
46
+ );
32
47
  }
33
- /**
34
- * Creates a new post using the REST API.
35
- *
36
- * @param this
37
- * @param payload Post attributes.
38
- */
39
48
  async function createPost(payload) {
40
- const post = await this.rest({
41
- method: 'POST',
42
- path: `/wp/v2/posts`,
43
- data: { ...payload },
44
- });
45
- return post;
49
+ const post = await this.rest({
50
+ method: "POST",
51
+ path: `/wp/v2/posts`,
52
+ data: { ...payload }
53
+ });
54
+ return post;
46
55
  }
47
- //# sourceMappingURL=posts.js.map
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ createPost,
59
+ deleteAllPosts
60
+ });
61
+ //# sourceMappingURL=posts.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"posts.js","sourceRoot":"","sources":["../../src/request-utils/posts.ts"],"names":[],"mappings":";;AA0BA,wCA6BC;AAQD,gCAWC;AAtDD;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAEnC,WAAmB,OAAO;IAE1B,kBAAkB;IAClB,uEAAuE;IACvE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAY;QACxC,IAAI,EAAE,UAAW,QAAS,EAAE;QAC5B,MAAM,EAAE;YACP,QAAQ,EAAE,GAAG;YACb,yBAAyB;YACzB,MAAM,EAAE,4CAA4C;SACpD;KACD,CAAE,CAAC;IAEJ,+BAA+B;IAC/B,0EAA0E;IAC1E,kDAAkD;IAClD,MAAM,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,GAAG,CAAE,CAAE,IAAI,EAAG,EAAE,CACrB,IAAI,CAAC,IAAI,CAAE;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,UAAW,QAAS,IAAK,IAAI,CAAC,EAAG,EAAE;QACzC,MAAM,EAAE;YACP,KAAK,EAAE,IAAI;SACX;KACD,CAAE,CACH,CACD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,UAAU,CAE/B,OAA0B;IAE1B,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"}
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,20 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resetPreferences = resetPreferences;
4
- /**
5
- * Reset user preferences
6
- *
7
- * @param this Request utils.
8
- */
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);
9
26
  async function resetPreferences() {
10
- await this.rest({
11
- path: '/wp/v2/users/me',
12
- method: 'PUT',
13
- data: {
14
- meta: {
15
- persisted_preferences: {},
16
- },
17
- },
18
- });
27
+ await this.rest({
28
+ path: "/wp/v2/users/me",
29
+ method: "PUT",
30
+ data: {
31
+ meta: {
32
+ persisted_preferences: {}
33
+ }
34
+ }
35
+ });
19
36
  }
20
- //# sourceMappingURL=preferences.js.map
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ resetPreferences
40
+ });
41
+ //# sourceMappingURL=preferences.js.map
@@ -1 +1,7 @@
1
- {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../src/request-utils/preferences.ts"],"names":[],"mappings":";;AAUA,4CAUC;AAfD;;;;GAIG;AACI,KAAK,UAAU,gBAAgB;IACrC,MAAM,IAAI,CAAC,IAAI,CAAE;QAChB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE;YACL,IAAI,EAAE;gBACL,qBAAqB,EAAE,EAAE;aACzB;SACD;KACD,CAAE,CAAC;AACL,CAAC"}
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
+ }