@wordpress/e2e-test-utils-playwright 1.35.1-next.16d95556a.0 → 1.36.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.
@@ -29,20 +29,33 @@ async function setGutenbergExperiments(experiments) {
29
29
  );
30
30
  const html = await response.text();
31
31
  const nonce = html.match(/name="_wpnonce" value="([^"]+)"/)[1];
32
- await this.request.post("/wp-admin/options.php", {
33
- form: {
34
- option_page: "gutenberg-experiments",
35
- action: "update",
36
- _wpnonce: nonce,
37
- _wp_http_referer: "/wp-admin/admin.php?page=gutenberg-experiments",
38
- ...Object.fromEntries(
39
- experiments.map((experiment) => [
32
+ const formData = {
33
+ option_page: "gutenberg-experiments",
34
+ action: "update",
35
+ _wpnonce: nonce,
36
+ _wp_http_referer: "/wp-admin/admin.php?page=gutenberg-experiments",
37
+ submit: "Save Changes"
38
+ };
39
+ const regularExperiments = experiments.filter(
40
+ (exp) => exp !== "active_templates"
41
+ );
42
+ const hasActiveTemplates = experiments.includes("active_templates");
43
+ if (regularExperiments.length > 0) {
44
+ Object.assign(
45
+ formData,
46
+ Object.fromEntries(
47
+ regularExperiments.map((experiment) => [
40
48
  `gutenberg-experiments[${experiment}]`,
41
49
  1
42
50
  ])
43
- ),
44
- submit: "Save Changes"
45
- },
51
+ )
52
+ );
53
+ }
54
+ if (hasActiveTemplates) {
55
+ formData.active_templates = 1;
56
+ }
57
+ await this.request.post("/wp-admin/options.php", {
58
+ form: formData,
46
59
  failOnStatusCode: true
47
60
  });
48
61
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/request-utils/gutenberg-experiments.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Sets the Gutenberg experiments.\n *\n * @param this\n * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.\n */\nasync function setGutenbergExperiments(\n\tthis: RequestUtils,\n\texperiments: string[]\n) {\n\tconst response = await this.request.get(\n\t\t'/wp-admin/admin.php?page=gutenberg-experiments'\n\t);\n\tconst html = await response.text();\n\tconst nonce = html.match( /name=\"_wpnonce\" value=\"([^\"]+)\"/ )![ 1 ];\n\n\tawait this.request.post( '/wp-admin/options.php', {\n\t\tform: {\n\t\t\toption_page: 'gutenberg-experiments',\n\t\t\taction: 'update',\n\t\t\t_wpnonce: nonce,\n\t\t\t_wp_http_referer: '/wp-admin/admin.php?page=gutenberg-experiments',\n\t\t\t...Object.fromEntries(\n\t\t\t\texperiments.map( ( experiment ) => [\n\t\t\t\t\t`gutenberg-experiments[${ experiment }]`,\n\t\t\t\t\t1,\n\t\t\t\t] )\n\t\t\t),\n\t\t\tsubmit: 'Save Changes',\n\t\t},\n\t\tfailOnStatusCode: true,\n\t} );\n}\n\nexport { setGutenbergExperiments };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,eAAe,wBAEd,aACC;AACD,QAAM,WAAW,MAAM,KAAK,QAAQ;AAAA,IACnC;AAAA,EACD;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAM,QAAQ,KAAK,MAAO,iCAAkC,EAAI,CAAE;AAElE,QAAM,KAAK,QAAQ,KAAM,yBAAyB;AAAA,IACjD,MAAM;AAAA,MACL,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,kBAAkB;AAAA,MAClB,GAAG,OAAO;AAAA,QACT,YAAY,IAAK,CAAE,eAAgB;AAAA,UAClC,yBAA0B,UAAW;AAAA,UACrC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,MACA,QAAQ;AAAA,IACT;AAAA,IACA,kBAAkB;AAAA,EACnB,CAAE;AACH;",
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\n\n/**\n * Sets the Gutenberg experiments.\n *\n * @param this\n * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.\n * Use 'active_templates' for the template activation feature.\n */\nasync function setGutenbergExperiments(\n\tthis: RequestUtils,\n\texperiments: string[]\n) {\n\tconst response = await this.request.get(\n\t\t'/wp-admin/admin.php?page=gutenberg-experiments'\n\t);\n\tconst html = await response.text();\n\tconst nonce = html.match( /name=\"_wpnonce\" value=\"([^\"]+)\"/ )![ 1 ];\n\n\tconst formData: Record< string, string | number > = {\n\t\toption_page: 'gutenberg-experiments',\n\t\taction: 'update',\n\t\t_wpnonce: nonce,\n\t\t_wp_http_referer: '/wp-admin/admin.php?page=gutenberg-experiments',\n\t\tsubmit: 'Save Changes',\n\t};\n\n\t// Separate regular experiments from active_templates.\n\tconst regularExperiments = experiments.filter(\n\t\t( exp ) => exp !== 'active_templates'\n\t);\n\tconst hasActiveTemplates = experiments.includes( 'active_templates' );\n\n\t// Add regular experiments to the gutenberg-experiments array.\n\tif ( regularExperiments.length > 0 ) {\n\t\tObject.assign(\n\t\t\tformData,\n\t\t\tObject.fromEntries(\n\t\t\t\tregularExperiments.map( ( experiment ) => [\n\t\t\t\t\t`gutenberg-experiments[${ experiment }]`,\n\t\t\t\t\t1,\n\t\t\t\t] )\n\t\t\t)\n\t\t);\n\t}\n\n\t// Template activation uses the active_templates checkbox field.\n\tif ( hasActiveTemplates ) {\n\t\tformData.active_templates = 1;\n\t}\n\n\tawait this.request.post( '/wp-admin/options.php', {\n\t\tform: formData,\n\t\tfailOnStatusCode: true,\n\t} );\n}\n\nexport { setGutenbergExperiments };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,eAAe,wBAEd,aACC;AACD,QAAM,WAAW,MAAM,KAAK,QAAQ;AAAA,IACnC;AAAA,EACD;AACA,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAM,QAAQ,KAAK,MAAO,iCAAkC,EAAI,CAAE;AAElE,QAAM,WAA8C;AAAA,IACnD,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EACT;AAGA,QAAM,qBAAqB,YAAY;AAAA,IACtC,CAAE,QAAS,QAAQ;AAAA,EACpB;AACA,QAAM,qBAAqB,YAAY,SAAU,kBAAmB;AAGpE,MAAK,mBAAmB,SAAS,GAAI;AACpC,WAAO;AAAA,MACN;AAAA,MACA,OAAO;AAAA,QACN,mBAAmB,IAAK,CAAE,eAAgB;AAAA,UACzC,yBAA0B,UAAW;AAAA,UACrC;AAAA,QACD,CAAE;AAAA,MACH;AAAA,IACD;AAAA,EACD;AAGA,MAAK,oBAAqB;AACzB,aAAS,mBAAmB;AAAA,EAC7B;AAEA,QAAM,KAAK,QAAQ,KAAM,yBAAyB;AAAA,IACjD,MAAM;AAAA,IACN,kBAAkB;AAAA,EACnB,CAAE;AACH;",
6
6
  "names": []
7
7
  }
@@ -24,9 +24,9 @@ __export(posts_exports, {
24
24
  deleteAllPosts: () => deleteAllPosts
25
25
  });
26
26
  module.exports = __toCommonJS(posts_exports);
27
- async function deleteAllPosts() {
27
+ async function deleteAllPosts(postType = "posts") {
28
28
  const posts = await this.rest({
29
- path: "/wp/v2/posts",
29
+ path: `/wp/v2/${postType}`,
30
30
  params: {
31
31
  per_page: 100,
32
32
  // All possible statuses.
@@ -37,7 +37,7 @@ async function deleteAllPosts() {
37
37
  posts.map(
38
38
  (post) => this.rest({
39
39
  method: "DELETE",
40
- path: `/wp/v2/posts/${post.id}`,
40
+ path: `/wp/v2/${postType}/${post.id}`,
41
41
  params: {
42
42
  force: true
43
43
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 */\nexport async function deleteAllPosts( this: RequestUtils ) {\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/posts',\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/posts/${ 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;AAyBA,eAAsB,iBAAqC;AAG1D,QAAM,QAAQ,MAAM,KAAK,KAAgB;AAAA,IACxC,MAAM;AAAA,IACN,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,gBAAiB,KAAK,EAAG;AAAA,QAC/B,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;",
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
6
  "names": []
7
7
  }
@@ -7,6 +7,7 @@ import type { RequestUtils } from './index';
7
7
  *
8
8
  * @param this
9
9
  * @param experiments Array of experimental flags to enable. Pass in an empty array to disable all experiments.
10
+ * Use 'active_templates' for the template activation feature.
10
11
  */
11
12
  declare function setGutenbergExperiments(this: RequestUtils, experiments: string[]): Promise<void>;
12
13
  export { setGutenbergExperiments };
@@ -1 +1 @@
1
- {"version":3,"file":"gutenberg-experiments.d.ts","sourceRoot":"","sources":["../../src/request-utils/gutenberg-experiments.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;GAKG;AACH,iBAAe,uBAAuB,CACrC,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,MAAM,EAAE,iBAwBrB;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"gutenberg-experiments.d.ts","sourceRoot":"","sources":["../../src/request-utils/gutenberg-experiments.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;GAMG;AACH,iBAAe,uBAAuB,CACrC,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,MAAM,EAAE,iBA4CrB;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -19,8 +19,9 @@ export interface CreatePostPayload {
19
19
  * Delete all posts using REST API.
20
20
  *
21
21
  * @param this
22
+ * @param postType The type of post to delete. Defaults to 'posts'.
22
23
  */
23
- export declare function deleteAllPosts(this: RequestUtils): Promise<void>;
24
+ export declare function deleteAllPosts(this: RequestUtils, postType?: string): Promise<void>;
24
25
  /**
25
26
  * Creates a new post using the REST API.
26
27
  *
@@ -1 +1 @@
1
- {"version":3,"file":"posts.d.ts","sourceRoot":"","sources":["../../src/request-utils/posts.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,IAAI;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/D,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAE,IAAI,EAAE,YAAY,iBA0BvD;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC/B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,iBAAiB,iBAS1B"}
1
+ {"version":3,"file":"posts.d.ts","sourceRoot":"","sources":["../../src/request-utils/posts.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,IAAI;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/D,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CACnC,IAAI,EAAE,YAAY,EAClB,QAAQ,GAAE,MAAgB,iBA2B1B;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC/B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,iBAAiB,iBAS1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/e2e-test-utils-playwright",
3
- "version": "1.35.1-next.16d95556a.0",
3
+ "version": "1.36.0",
4
4
  "description": "End-To-End (E2E) test utils for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -50,5 +50,5 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "59a9383612bbe16e21af84d13b035bfbca7fe833"
53
+ "gitHead": "b35cf1a2dce04665e99fd6b9c2891c0b336361b9"
54
54
  }