@wordpress/e2e-test-utils-playwright 1.45.1-next.v.202605131032.0 → 1.47.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 (138) hide show
  1. package/build/admin/index.js +3 -0
  2. package/build/admin/index.js.map +1 -1
  3. package/build/admin/visit-site-editor.js +1 -29
  4. package/build/admin/visit-site-editor.js.map +1 -1
  5. package/build/admin/wait-for-site-editor.js +41 -0
  6. package/build/admin/wait-for-site-editor.js.map +1 -0
  7. package/build/metrics/index.js +59 -3
  8. package/build/metrics/index.js.map +1 -1
  9. package/build/request-utils/index.js +2 -0
  10. package/build/request-utils/index.js.map +1 -1
  11. package/build/request-utils/preferences.js +34 -0
  12. package/build/request-utils/preferences.js.map +1 -1
  13. package/build-types/admin/index.d.ts +3 -0
  14. package/build-types/admin/index.d.ts.map +1 -1
  15. package/build-types/admin/visit-site-editor.d.ts.map +1 -1
  16. package/build-types/admin/wait-for-site-editor.d.ts +12 -0
  17. package/build-types/admin/wait-for-site-editor.d.ts.map +1 -0
  18. package/build-types/metrics/index.d.ts +22 -5
  19. package/build-types/metrics/index.d.ts.map +1 -1
  20. package/build-types/request-utils/index.d.ts +3 -1
  21. package/build-types/request-utils/index.d.ts.map +1 -1
  22. package/build-types/request-utils/preferences.d.ts +11 -0
  23. package/build-types/request-utils/preferences.d.ts.map +1 -1
  24. package/package.json +3 -4
  25. package/build/admin/create-new-post.cjs +0 -51
  26. package/build/admin/create-new-post.cjs.map +0 -7
  27. package/build/admin/edit-post.cjs +0 -40
  28. package/build/admin/edit-post.cjs.map +0 -7
  29. package/build/admin/get-page-error.cjs +0 -36
  30. package/build/admin/get-page-error.cjs.map +0 -7
  31. package/build/admin/index.cjs +0 -59
  32. package/build/admin/index.cjs.map +0 -7
  33. package/build/admin/visit-admin-page.cjs +0 -47
  34. package/build/admin/visit-admin-page.cjs.map +0 -7
  35. package/build/admin/visit-site-editor.cjs +0 -90
  36. package/build/admin/visit-site-editor.cjs.map +0 -7
  37. package/build/config.cjs +0 -45
  38. package/build/config.cjs.map +0 -7
  39. package/build/editor/click-block-options-menu-item.cjs +0 -34
  40. package/build/editor/click-block-options-menu-item.cjs.map +0 -7
  41. package/build/editor/click-block-toolbar-button.cjs +0 -38
  42. package/build/editor/click-block-toolbar-button.cjs.map +0 -7
  43. package/build/editor/get-blocks.cjs +0 -64
  44. package/build/editor/get-blocks.cjs.map +0 -7
  45. package/build/editor/get-edited-post-content.cjs +0 -36
  46. package/build/editor/get-edited-post-content.cjs.map +0 -7
  47. package/build/editor/index.cjs +0 -97
  48. package/build/editor/index.cjs.map +0 -7
  49. package/build/editor/insert-block.cjs +0 -55
  50. package/build/editor/insert-block.cjs.map +0 -7
  51. package/build/editor/open-document-settings-sidebar.cjs +0 -42
  52. package/build/editor/open-document-settings-sidebar.cjs.map +0 -7
  53. package/build/editor/preview.cjs +0 -42
  54. package/build/editor/preview.cjs.map +0 -7
  55. package/build/editor/publish-post.cjs +0 -47
  56. package/build/editor/publish-post.cjs.map +0 -7
  57. package/build/editor/save-draft.cjs +0 -34
  58. package/build/editor/save-draft.cjs.map +0 -7
  59. package/build/editor/select-blocks.cjs +0 -51
  60. package/build/editor/select-blocks.cjs.map +0 -7
  61. package/build/editor/set-content.cjs +0 -39
  62. package/build/editor/set-content.cjs.map +0 -7
  63. package/build/editor/set-is-fixed-toolbar.cjs +0 -36
  64. package/build/editor/set-is-fixed-toolbar.cjs.map +0 -7
  65. package/build/editor/set-preferences.cjs +0 -43
  66. package/build/editor/set-preferences.cjs.map +0 -7
  67. package/build/editor/show-block-toolbar.cjs +0 -35
  68. package/build/editor/show-block-toolbar.cjs.map +0 -7
  69. package/build/editor/site-editor.cjs +0 -51
  70. package/build/editor/site-editor.cjs.map +0 -7
  71. package/build/editor/switch-editor-tool.cjs +0 -47
  72. package/build/editor/switch-editor-tool.cjs.map +0 -7
  73. package/build/editor/switch-to-legacy-canvas.cjs +0 -39
  74. package/build/editor/switch-to-legacy-canvas.cjs.map +0 -7
  75. package/build/editor/transform-block-to.cjs +0 -46
  76. package/build/editor/transform-block-to.cjs.map +0 -7
  77. package/build/index.cjs +0 -51
  78. package/build/index.cjs.map +0 -7
  79. package/build/lighthouse/index.cjs +0 -96
  80. package/build/lighthouse/index.cjs.map +0 -7
  81. package/build/metrics/index.cjs +0 -309
  82. package/build/metrics/index.cjs.map +0 -7
  83. package/build/page-utils/drag-files.cjs +0 -143
  84. package/build/page-utils/drag-files.cjs.map +0 -7
  85. package/build/page-utils/emulate-network-conditions.cjs +0 -99
  86. package/build/page-utils/emulate-network-conditions.cjs.map +0 -7
  87. package/build/page-utils/index.cjs +0 -59
  88. package/build/page-utils/index.cjs.map +0 -7
  89. package/build/page-utils/is-current-url.cjs +0 -36
  90. package/build/page-utils/is-current-url.cjs.map +0 -7
  91. package/build/page-utils/keycodes.cjs +0 -55
  92. package/build/page-utils/keycodes.cjs.map +0 -7
  93. package/build/page-utils/press-keys.cjs +0 -165
  94. package/build/page-utils/press-keys.cjs.map +0 -7
  95. package/build/page-utils/set-browser-viewport.cjs +0 -39
  96. package/build/page-utils/set-browser-viewport.cjs.map +0 -7
  97. package/build/request-utils/blocks.cjs +0 -51
  98. package/build/request-utils/blocks.cjs.map +0 -7
  99. package/build/request-utils/comments.cjs +0 -66
  100. package/build/request-utils/comments.cjs.map +0 -7
  101. package/build/request-utils/gutenberg-experiments.cjs +0 -56
  102. package/build/request-utils/gutenberg-experiments.cjs.map +0 -7
  103. package/build/request-utils/index.cjs +0 -199
  104. package/build/request-utils/index.cjs.map +0 -7
  105. package/build/request-utils/login.cjs +0 -48
  106. package/build/request-utils/login.cjs.map +0 -7
  107. package/build/request-utils/media.cjs +0 -83
  108. package/build/request-utils/media.cjs.map +0 -7
  109. package/build/request-utils/menus.cjs +0 -128
  110. package/build/request-utils/menus.cjs.map +0 -7
  111. package/build/request-utils/pages.cjs +0 -66
  112. package/build/request-utils/pages.cjs.map +0 -7
  113. package/build/request-utils/patterns.cjs +0 -44
  114. package/build/request-utils/patterns.cjs.map +0 -7
  115. package/build/request-utils/plugins.cjs +0 -81
  116. package/build/request-utils/plugins.cjs.map +0 -7
  117. package/build/request-utils/posts.cjs +0 -56
  118. package/build/request-utils/posts.cjs.map +0 -7
  119. package/build/request-utils/preferences.cjs +0 -41
  120. package/build/request-utils/preferences.cjs.map +0 -7
  121. package/build/request-utils/records.cjs +0 -37
  122. package/build/request-utils/records.cjs.map +0 -7
  123. package/build/request-utils/rest.cjs +0 -174
  124. package/build/request-utils/rest.cjs.map +0 -7
  125. package/build/request-utils/site-settings.cjs +0 -45
  126. package/build/request-utils/site-settings.cjs.map +0 -7
  127. package/build/request-utils/templates.cjs +0 -68
  128. package/build/request-utils/templates.cjs.map +0 -7
  129. package/build/request-utils/themes.cjs +0 -92
  130. package/build/request-utils/themes.cjs.map +0 -7
  131. package/build/request-utils/users.cjs +0 -83
  132. package/build/request-utils/users.cjs.map +0 -7
  133. package/build/request-utils/widgets.cjs +0 -79
  134. package/build/request-utils/widgets.cjs.map +0 -7
  135. package/build/test.cjs +0 -136
  136. package/build/test.cjs.map +0 -7
  137. package/build/types.cjs +0 -19
  138. package/build/types.cjs.map +0 -7
@@ -1,199 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/e2e-test-utils-playwright/src/request-utils/index.ts
31
- var request_utils_exports = {};
32
- __export(request_utils_exports, {
33
- RequestUtils: () => RequestUtils
34
- });
35
- module.exports = __toCommonJS(request_utils_exports);
36
- var fs = __toESM(require("fs/promises"));
37
- var path = __toESM(require("path"));
38
- var import_test = require("@playwright/test");
39
- var import_config = require("../config.cjs");
40
- var import_login = require("./login.cjs");
41
- var import_media = require("./media.cjs");
42
- var import_users = require("./users.cjs");
43
- var import_rest = require("./rest.cjs");
44
- var import_plugins = require("./plugins.cjs");
45
- var import_templates = require("./templates.cjs");
46
- var import_themes = require("./themes.cjs");
47
- var import_blocks = require("./blocks.cjs");
48
- var import_comments = require("./comments.cjs");
49
- var import_posts = require("./posts.cjs");
50
- var import_menus = require("./menus.cjs");
51
- var import_pages = require("./pages.cjs");
52
- var import_records = require("./records.cjs");
53
- var import_preferences = require("./preferences.cjs");
54
- var import_site_settings = require("./site-settings.cjs");
55
- var import_widgets = require("./widgets.cjs");
56
- var import_patterns = require("./patterns.cjs");
57
- var import_gutenberg_experiments = require("./gutenberg-experiments.cjs");
58
- var RequestUtils = class {
59
- request;
60
- user;
61
- maxBatchSize;
62
- storageState;
63
- storageStatePath;
64
- baseURL;
65
- pluginsMap = null;
66
- static async setup({
67
- user,
68
- storageStatePath,
69
- baseURL = import_config.WP_BASE_URL
70
- }) {
71
- let storageState;
72
- if (storageStatePath) {
73
- await fs.mkdir(path.dirname(storageStatePath), {
74
- recursive: true
75
- });
76
- try {
77
- storageState = JSON.parse(
78
- await fs.readFile(storageStatePath, "utf-8")
79
- );
80
- } catch (error) {
81
- if (error instanceof Error && error.code === "ENOENT") {
82
- } else {
83
- throw error;
84
- }
85
- }
86
- }
87
- const requestContext = await import_test.request.newContext({
88
- baseURL,
89
- storageState: storageState && {
90
- cookies: storageState.cookies,
91
- origins: []
92
- }
93
- });
94
- const requestUtils = new this(requestContext, {
95
- user,
96
- storageState,
97
- storageStatePath,
98
- baseURL
99
- });
100
- return requestUtils;
101
- }
102
- constructor(requestContext, {
103
- user = import_config.WP_ADMIN_USER,
104
- storageState,
105
- storageStatePath,
106
- baseURL = import_config.WP_BASE_URL
107
- } = {}) {
108
- this.user = user;
109
- this.request = requestContext;
110
- this.storageStatePath = storageStatePath;
111
- this.storageState = storageState;
112
- this.baseURL = baseURL;
113
- }
114
- /** @borrows login as this.login */
115
- login = import_login.login.bind(this);
116
- /** @borrows setupRest as this.setupRest */
117
- setupRest = import_rest.setupRest.bind(this);
118
- // .bind() drops the generic types. Re-casting it to keep the type signature.
119
- rest = import_rest.rest.bind(this);
120
- /** @borrows getMaxBatchSize as this.getMaxBatchSize */
121
- getMaxBatchSize = import_rest.getMaxBatchSize.bind(this);
122
- // .bind() drops the generic types. Re-casting it to keep the type signature.
123
- batchRest = import_rest.batchRest.bind(this);
124
- // .bind() drops the generic types. Re-casting it to keep the type signature.
125
- createRecord = import_records.createRecord.bind(
126
- this
127
- );
128
- /** @borrows getPluginsMap as this.getPluginsMap */
129
- getPluginsMap = import_plugins.getPluginsMap.bind(this);
130
- /** @borrows activatePlugin as this.activatePlugin */
131
- activatePlugin = import_plugins.activatePlugin.bind(this);
132
- /** @borrows deactivatePlugin as this.deactivatePlugin */
133
- deactivatePlugin = import_plugins.deactivatePlugin.bind(this);
134
- /** @borrows activateTheme as this.activateTheme */
135
- activateTheme = import_themes.activateTheme.bind(this);
136
- /** @borrows createBlock as this.createBlock */
137
- createBlock = import_blocks.createBlock.bind(this);
138
- /** @borrows deleteAllBlocks as this.deleteAllBlocks */
139
- deleteAllBlocks = import_blocks.deleteAllBlocks.bind(this);
140
- /** @borrows createPost as this.createPost */
141
- createPost = import_posts.createPost.bind(this);
142
- /** @borrows deleteAllPosts as this.deleteAllPosts */
143
- deleteAllPosts = import_posts.deleteAllPosts.bind(this);
144
- /** @borrows createClassicMenu as this.createClassicMenu */
145
- createClassicMenu = import_menus.createClassicMenu.bind(this);
146
- /** @borrows createNavigationMenu as this.createNavigationMenu */
147
- createNavigationMenu = import_menus.createNavigationMenu.bind(this);
148
- /** @borrows deleteAllMenus as this.deleteAllMenus */
149
- deleteAllMenus = import_menus.deleteAllMenus.bind(this);
150
- /** @borrows getNavigationMenus as this.getNavigationMenus */
151
- getNavigationMenus = import_menus.getNavigationMenus.bind(this);
152
- /** @borrows createComment as this.createComment */
153
- createComment = import_comments.createComment.bind(this);
154
- /** @borrows deleteAllComments as this.deleteAllComments */
155
- deleteAllComments = import_comments.deleteAllComments.bind(this);
156
- /** @borrows deleteAllWidgets as this.deleteAllWidgets */
157
- deleteAllWidgets = import_widgets.deleteAllWidgets.bind(this);
158
- /** @borrows addWidgetBlock as this.addWidgetBlock */
159
- addWidgetBlock = import_widgets.addWidgetBlock.bind(this);
160
- /** @borrows deleteAllTemplates as this.deleteAllTemplates */
161
- deleteAllTemplates = import_templates.deleteAllTemplates.bind(this);
162
- /** @borrows createTemplate as this.createTemplate */
163
- createTemplate = import_templates.createTemplate.bind(this);
164
- /** @borrows resetPreferences as this.resetPreferences */
165
- resetPreferences = import_preferences.resetPreferences.bind(this);
166
- /** @borrows listMedia as this.listMedia */
167
- listMedia = import_media.listMedia.bind(this);
168
- /** @borrows uploadMedia as this.uploadMedia */
169
- uploadMedia = import_media.uploadMedia.bind(this);
170
- /** @borrows deleteMedia as this.deleteMedia */
171
- deleteMedia = import_media.deleteMedia.bind(this);
172
- /** @borrows deleteAllMedia as this.deleteAllMedia */
173
- deleteAllMedia = import_media.deleteAllMedia.bind(this);
174
- /** @borrows createUser as this.createUser */
175
- createUser = import_users.createUser.bind(this);
176
- /** @borrows deleteAllUsers as this.deleteAllUsers */
177
- deleteAllUsers = import_users.deleteAllUsers.bind(this);
178
- /** @borrows getSiteSettings as this.getSiteSettings */
179
- getSiteSettings = import_site_settings.getSiteSettings.bind(this);
180
- /** @borrows updateSiteSettings as this.updateSiteSettings */
181
- updateSiteSettings = import_site_settings.updateSiteSettings.bind(this);
182
- /** @borrows deleteAllPages as this.deleteAllPages */
183
- deleteAllPages = import_pages.deleteAllPages.bind(this);
184
- /** @borrows createPage as this.createPage */
185
- createPage = import_pages.createPage.bind(this);
186
- /** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */
187
- getCurrentThemeGlobalStylesPostId = import_themes.getCurrentThemeGlobalStylesPostId.bind(this);
188
- /** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */
189
- getThemeGlobalStylesRevisions = import_themes.getThemeGlobalStylesRevisions.bind(this);
190
- /** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */
191
- deleteAllPatternCategories = import_patterns.deleteAllPatternCategories.bind(this);
192
- /** @borrows setGutenbergExperiments as this.setGutenbergExperiments */
193
- setGutenbergExperiments = import_gutenberg_experiments.setGutenbergExperiments.bind(this);
194
- };
195
- // Annotate the CommonJS export names for ESM import in node:
196
- 0 && (module.exports = {
197
- RequestUtils
198
- });
199
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/index.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { request } from '@playwright/test';\nimport type { APIRequestContext, Cookie } from '@playwright/test';\n\n/**\n * Internal dependencies\n */\nimport { WP_ADMIN_USER, WP_BASE_URL } from '../config';\nimport type { User } from './login';\nimport { login } from './login';\nimport { listMedia, uploadMedia, deleteMedia, deleteAllMedia } from './media';\nimport { createUser, deleteAllUsers } from './users';\nimport { setupRest, rest, getMaxBatchSize, batchRest } from './rest';\nimport { getPluginsMap, activatePlugin, deactivatePlugin } from './plugins';\nimport { deleteAllTemplates, createTemplate } from './templates';\nimport {\n\tactivateTheme,\n\tgetCurrentThemeGlobalStylesPostId,\n\tgetThemeGlobalStylesRevisions,\n} from './themes';\nimport { createBlock, deleteAllBlocks } from './blocks';\nimport { createComment, deleteAllComments } from './comments';\nimport { createPost, deleteAllPosts } from './posts';\nimport {\n\tcreateClassicMenu,\n\tcreateNavigationMenu,\n\tdeleteAllMenus,\n\tgetNavigationMenus,\n} from './menus';\nimport { deleteAllPages, createPage } from './pages';\nimport { createRecord } from './records';\nimport { resetPreferences } from './preferences';\nimport { getSiteSettings, updateSiteSettings } from './site-settings';\nimport { deleteAllWidgets, addWidgetBlock } from './widgets';\nimport { deleteAllPatternCategories } from './patterns';\nimport { setGutenbergExperiments } from './gutenberg-experiments';\n\ninterface StorageState {\n\tcookies: Cookie[];\n\tnonce: string;\n\trootURL: string;\n}\n\nclass RequestUtils {\n\trequest: APIRequestContext;\n\tuser: User;\n\tmaxBatchSize?: number;\n\tstorageState?: StorageState;\n\tstorageStatePath?: string;\n\tbaseURL?: string;\n\n\tpluginsMap: Record< string, string > | null = null;\n\n\tstatic async setup( {\n\t\tuser,\n\t\tstorageStatePath,\n\t\tbaseURL = WP_BASE_URL,\n\t}: {\n\t\tuser?: User;\n\t\tstorageStatePath?: string;\n\t\tbaseURL?: string;\n\t} ) {\n\t\tlet storageState: StorageState | undefined;\n\t\tif ( storageStatePath ) {\n\t\t\tawait fs.mkdir( path.dirname( storageStatePath ), {\n\t\t\t\trecursive: true,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tstorageState = JSON.parse(\n\t\t\t\t\tawait fs.readFile( storageStatePath, 'utf-8' )\n\t\t\t\t);\n\t\t\t} catch ( error ) {\n\t\t\t\tif (\n\t\t\t\t\terror instanceof Error &&\n\t\t\t\t\t( error as NodeJS.ErrnoException ).code === 'ENOENT'\n\t\t\t\t) {\n\t\t\t\t\t// Ignore errors if the state is not found.\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst requestContext = await request.newContext( {\n\t\t\tbaseURL,\n\t\t\tstorageState: storageState && {\n\t\t\t\tcookies: storageState.cookies,\n\t\t\t\torigins: [],\n\t\t\t},\n\t\t} );\n\n\t\tconst requestUtils = new this( requestContext, {\n\t\t\tuser,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL,\n\t\t} );\n\n\t\treturn requestUtils;\n\t}\n\n\tconstructor(\n\t\trequestContext: APIRequestContext,\n\t\t{\n\t\t\tuser = WP_ADMIN_USER,\n\t\t\tstorageState,\n\t\t\tstorageStatePath,\n\t\t\tbaseURL = WP_BASE_URL,\n\t\t}: {\n\t\t\tuser?: User;\n\t\t\tstorageState?: StorageState;\n\t\t\tstorageStatePath?: string;\n\t\t\tbaseURL?: string;\n\t\t} = {}\n\t) {\n\t\tthis.user = user;\n\t\tthis.request = requestContext;\n\t\tthis.storageStatePath = storageStatePath;\n\t\tthis.storageState = storageState;\n\t\tthis.baseURL = baseURL;\n\t}\n\n\t/** @borrows login as this.login */\n\tlogin: typeof login = login.bind( this );\n\t/** @borrows setupRest as this.setupRest */\n\tsetupRest: typeof setupRest = setupRest.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\trest: typeof rest = rest.bind( this ) as typeof rest;\n\t/** @borrows getMaxBatchSize as this.getMaxBatchSize */\n\tgetMaxBatchSize: typeof getMaxBatchSize = getMaxBatchSize.bind( this );\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\tbatchRest: typeof batchRest = batchRest.bind( this ) as typeof batchRest;\n\t// .bind() drops the generic types. Re-casting it to keep the type signature.\n\tcreateRecord: typeof createRecord = createRecord.bind(\n\t\tthis\n\t) as typeof createRecord;\n\t/** @borrows getPluginsMap as this.getPluginsMap */\n\tgetPluginsMap: typeof getPluginsMap = getPluginsMap.bind( this );\n\t/** @borrows activatePlugin as this.activatePlugin */\n\tactivatePlugin: typeof activatePlugin = activatePlugin.bind( this );\n\t/** @borrows deactivatePlugin as this.deactivatePlugin */\n\tdeactivatePlugin: typeof deactivatePlugin = deactivatePlugin.bind( this );\n\t/** @borrows activateTheme as this.activateTheme */\n\tactivateTheme: typeof activateTheme = activateTheme.bind( this );\n\t/** @borrows createBlock as this.createBlock */\n\tcreateBlock: typeof createBlock = createBlock.bind( this );\n\t/** @borrows deleteAllBlocks as this.deleteAllBlocks */\n\tdeleteAllBlocks = deleteAllBlocks.bind( this );\n\t/** @borrows createPost as this.createPost */\n\tcreatePost: typeof createPost = createPost.bind( this );\n\t/** @borrows deleteAllPosts as this.deleteAllPosts */\n\tdeleteAllPosts: typeof deleteAllPosts = deleteAllPosts.bind( this );\n\t/** @borrows createClassicMenu as this.createClassicMenu */\n\tcreateClassicMenu: typeof createClassicMenu =\n\t\tcreateClassicMenu.bind( this );\n\t/** @borrows createNavigationMenu as this.createNavigationMenu */\n\tcreateNavigationMenu: typeof createNavigationMenu =\n\t\tcreateNavigationMenu.bind( this );\n\t/** @borrows deleteAllMenus as this.deleteAllMenus */\n\tdeleteAllMenus: typeof deleteAllMenus = deleteAllMenus.bind( this );\n\t/** @borrows getNavigationMenus as this.getNavigationMenus */\n\tgetNavigationMenus: typeof getNavigationMenus =\n\t\tgetNavigationMenus.bind( this );\n\t/** @borrows createComment as this.createComment */\n\tcreateComment: typeof createComment = createComment.bind( this );\n\t/** @borrows deleteAllComments as this.deleteAllComments */\n\tdeleteAllComments: typeof deleteAllComments =\n\t\tdeleteAllComments.bind( this );\n\t/** @borrows deleteAllWidgets as this.deleteAllWidgets */\n\tdeleteAllWidgets: typeof deleteAllWidgets = deleteAllWidgets.bind( this );\n\t/** @borrows addWidgetBlock as this.addWidgetBlock */\n\taddWidgetBlock: typeof addWidgetBlock = addWidgetBlock.bind( this );\n\t/** @borrows deleteAllTemplates as this.deleteAllTemplates */\n\tdeleteAllTemplates: typeof deleteAllTemplates =\n\t\tdeleteAllTemplates.bind( this );\n\t/** @borrows createTemplate as this.createTemplate */\n\tcreateTemplate: typeof createTemplate = createTemplate.bind( this );\n\t/** @borrows resetPreferences as this.resetPreferences */\n\tresetPreferences: typeof resetPreferences = resetPreferences.bind( this );\n\t/** @borrows listMedia as this.listMedia */\n\tlistMedia: typeof listMedia = listMedia.bind( this );\n\t/** @borrows uploadMedia as this.uploadMedia */\n\tuploadMedia: typeof uploadMedia = uploadMedia.bind( this );\n\t/** @borrows deleteMedia as this.deleteMedia */\n\tdeleteMedia: typeof deleteMedia = deleteMedia.bind( this );\n\t/** @borrows deleteAllMedia as this.deleteAllMedia */\n\tdeleteAllMedia: typeof deleteAllMedia = deleteAllMedia.bind( this );\n\t/** @borrows createUser as this.createUser */\n\tcreateUser: typeof createUser = createUser.bind( this );\n\t/** @borrows deleteAllUsers as this.deleteAllUsers */\n\tdeleteAllUsers: typeof deleteAllUsers = deleteAllUsers.bind( this );\n\t/** @borrows getSiteSettings as this.getSiteSettings */\n\tgetSiteSettings: typeof getSiteSettings = getSiteSettings.bind( this );\n\t/** @borrows updateSiteSettings as this.updateSiteSettings */\n\tupdateSiteSettings: typeof updateSiteSettings =\n\t\tupdateSiteSettings.bind( this );\n\t/** @borrows deleteAllPages as this.deleteAllPages */\n\tdeleteAllPages: typeof deleteAllPages = deleteAllPages.bind( this );\n\t/** @borrows createPage as this.createPage */\n\tcreatePage: typeof createPage = createPage.bind( this );\n\t/** @borrows getCurrentThemeGlobalStylesPostId as this.getCurrentThemeGlobalStylesPostId */\n\tgetCurrentThemeGlobalStylesPostId: typeof getCurrentThemeGlobalStylesPostId =\n\t\tgetCurrentThemeGlobalStylesPostId.bind( this );\n\t/** @borrows getThemeGlobalStylesRevisions as this.getThemeGlobalStylesRevisions */\n\tgetThemeGlobalStylesRevisions: typeof getThemeGlobalStylesRevisions =\n\t\tgetThemeGlobalStylesRevisions.bind( this );\n\t/** @borrows deleteAllPatternCategories as this.deleteAllPatternCategories */\n\tdeleteAllPatternCategories = deleteAllPatternCategories.bind( this );\n\t/** @borrows setGutenbergExperiments as this.setGutenbergExperiments */\n\tsetGutenbergExperiments: typeof setGutenbergExperiments =\n\t\tsetGutenbergExperiments.bind( this );\n}\n\nexport type { StorageState };\nexport { RequestUtils };\n"],
5
- "mappings": "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",
6
- "names": []
7
- }
@@ -1,48 +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/login.ts
21
- var login_exports = {};
22
- __export(login_exports, {
23
- login: () => login
24
- });
25
- module.exports = __toCommonJS(login_exports);
26
- async function login(user = this.user) {
27
- let response = await this.request.post("wp-login.php", {
28
- failOnStatusCode: true,
29
- form: {
30
- log: user.username,
31
- pwd: user.password
32
- }
33
- });
34
- await response.dispose();
35
- response = await this.request.get(
36
- "wp-admin/admin-ajax.php?action=rest-nonce",
37
- {
38
- failOnStatusCode: true
39
- }
40
- );
41
- const nonce = await response.text();
42
- return nonce;
43
- }
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- login
47
- });
48
- //# sourceMappingURL=login.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/request-utils/login.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\nexport interface User {\n\tusername: string;\n\tpassword: string;\n}\n\nasync function login( this: RequestUtils, user: User = this.user ) {\n\t// Login to admin using request context.\n\tlet response = await this.request.post( 'wp-login.php', {\n\t\tfailOnStatusCode: true,\n\t\tform: {\n\t\t\tlog: user.username,\n\t\t\tpwd: user.password,\n\t\t},\n\t} );\n\tawait response.dispose();\n\n\t// Get the nonce.\n\tresponse = await this.request.get(\n\t\t'wp-admin/admin-ajax.php?action=rest-nonce',\n\t\t{\n\t\t\tfailOnStatusCode: true,\n\t\t}\n\t);\n\tconst nonce = await response.text();\n\n\treturn nonce;\n}\n\nexport { login };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,eAAe,MAA2B,OAAa,KAAK,MAAO;AAElE,MAAI,WAAW,MAAM,KAAK,QAAQ,KAAM,gBAAgB;AAAA,IACvD,kBAAkB;AAAA,IAClB,MAAM;AAAA,MACL,KAAK,KAAK;AAAA,MACV,KAAK,KAAK;AAAA,IACX;AAAA,EACD,CAAE;AACF,QAAM,SAAS,QAAQ;AAGvB,aAAW,MAAM,KAAK,QAAQ;AAAA,IAC7B;AAAA,IACA;AAAA,MACC,kBAAkB;AAAA,IACnB;AAAA,EACD;AACA,QAAM,QAAQ,MAAM,SAAS,KAAK;AAElC,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/e2e-test-utils-playwright/src/request-utils/media.ts
31
- var media_exports = {};
32
- __export(media_exports, {
33
- deleteAllMedia: () => deleteAllMedia,
34
- deleteMedia: () => deleteMedia,
35
- listMedia: () => listMedia,
36
- uploadMedia: () => uploadMedia
37
- });
38
- module.exports = __toCommonJS(media_exports);
39
- var fs = __toESM(require("fs"));
40
- async function listMedia() {
41
- const response = await this.rest({
42
- method: "GET",
43
- path: "/wp/v2/media",
44
- params: {
45
- per_page: 100
46
- }
47
- });
48
- return response;
49
- }
50
- async function uploadMedia(filePathOrData) {
51
- const file = typeof filePathOrData === "string" ? fs.createReadStream(filePathOrData) : filePathOrData;
52
- const response = await this.rest({
53
- method: "POST",
54
- path: "/wp/v2/media",
55
- multipart: {
56
- file
57
- }
58
- });
59
- return response;
60
- }
61
- async function deleteMedia(mediaId) {
62
- const response = await this.rest({
63
- method: "DELETE",
64
- path: `/wp/v2/media/${mediaId}`,
65
- params: { force: true }
66
- });
67
- return response;
68
- }
69
- async function deleteAllMedia() {
70
- const files = await this.listMedia();
71
- const responses = await Promise.all(
72
- files.map((media) => this.deleteMedia(media.id))
73
- );
74
- return responses;
75
- }
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- deleteAllMedia,
79
- deleteMedia,
80
- listMedia,
81
- uploadMedia
82
- });
83
- //# sourceMappingURL=media.cjs.map
@@ -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,128 +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.createRecord("navigation", {
61
- status: "publish",
62
- ...menuData
63
- });
64
- }
65
- async function deleteAllMenus() {
66
- const navMenus = await this.rest({
67
- path: `/wp/v2/navigation/`,
68
- data: {
69
- status: [
70
- "publish",
71
- "pending",
72
- "draft",
73
- "auto-draft",
74
- "future",
75
- "private",
76
- "inherit",
77
- "trash"
78
- ]
79
- }
80
- });
81
- if (navMenus.length) {
82
- await this.batchRest(
83
- navMenus.map((menu) => ({
84
- method: "DELETE",
85
- path: `/wp/v2/navigation/${menu.id}?force=true`
86
- }))
87
- );
88
- }
89
- const classicMenus = await this.rest({
90
- path: `/wp/v2/menus/`,
91
- data: {
92
- status: [
93
- "publish",
94
- "pending",
95
- "draft",
96
- "auto-draft",
97
- "future",
98
- "private",
99
- "inherit",
100
- "trash"
101
- ]
102
- }
103
- });
104
- if (classicMenus.length) {
105
- await this.batchRest(
106
- classicMenus.map((menu) => ({
107
- method: "DELETE",
108
- path: `/wp/v2/menus/${menu.id}?force=true`
109
- }))
110
- );
111
- }
112
- }
113
- async function getNavigationMenus(args) {
114
- const navigationMenus = await this.rest({
115
- method: "GET",
116
- path: `/wp/v2/navigation/`,
117
- data: args
118
- });
119
- return navigationMenus;
120
- }
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- createClassicMenu,
124
- createNavigationMenu,
125
- deleteAllMenus,
126
- getNavigationMenus
127
- });
128
- //# 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.createRecord< NavigationMenu >( 'navigation', {\n\t\tstatus: 'publish',\n\t\t...menuData,\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,aAAgC,cAAc;AAAA,IACzD,QAAQ;AAAA,IACR,GAAG;AAAA,EACJ,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,66 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/e2e-test-utils-playwright/src/request-utils/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
- return this.createRecord("pages", { ...payload });
59
- }
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- createPage,
63
- deleteAllPages,
64
- deletePage
65
- });
66
- //# 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\treturn this.createRecord< Page >( 'pages', { ...payload } );\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,SAAO,KAAK,aAAsB,SAAS,EAAE,GAAG,QAAQ,CAAE;AAC3D;",
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