@wordpress/e2e-test-utils-playwright 1.40.0 → 1.40.1-next.v.202602200903.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.
|
@@ -65,9 +65,12 @@ async function getCurrentThemeGlobalStylesPostId() {
|
|
|
65
65
|
);
|
|
66
66
|
const globalStylesURL = currentTheme?._links?.["wp:user-global-styles"]?.[0]?.href;
|
|
67
67
|
if (globalStylesURL) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
)
|
|
68
|
+
const idMatch = globalStylesURL.match(
|
|
69
|
+
/\/wp\/v2\/global-styles\/(\d+)/
|
|
70
|
+
);
|
|
71
|
+
if (idMatch) {
|
|
72
|
+
themeGlobalStylesId = idMatch[1];
|
|
73
|
+
}
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
return themeGlobalStylesId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/request-utils/themes.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\nimport { WP_BASE_URL } from '../config';\n\nconst THEMES_URL = new URL( 'wp-admin/themes.php', WP_BASE_URL ).href;\n\nasync function activateTheme(\n\tthis: RequestUtils,\n\tthemeSlug: string\n): Promise< void > {\n\tlet response = await this.request.get( THEMES_URL );\n\tconst html = await response.text();\n\tconst optionalFolder = '([a-z0-9-]+%2F)?';\n\n\t// The `optionalFolder` regex part matches paths with a folder,\n\t// so it will return the first match, which might contain a folder.\n\t// First try to honor the included theme slug, that is, without a folder.\n\tlet matchGroup = html.match(\n\t\t`action=activate&stylesheet=${ encodeURIComponent(\n\t\t\tthemeSlug\n\t\t) }&_wpnonce=[a-z0-9]+`\n\t);\n\n\t// If the theme is not found, try to match the theme slug with a folder.\n\tif ( ! matchGroup ) {\n\t\tmatchGroup = html.match(\n\t\t\t`action=activate&stylesheet=${ optionalFolder }${ encodeURIComponent(\n\t\t\t\tthemeSlug\n\t\t\t) }&_wpnonce=[a-z0-9]+`\n\t\t);\n\t}\n\n\tif ( ! matchGroup ) {\n\t\tif ( html.includes( `data-slug=\"${ themeSlug }\"` ) ) {\n\t\t\t// The theme is already activated.\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error( `The theme \"${ themeSlug }\" is not installed` );\n\t}\n\n\tconst [ activateQuery ] = matchGroup;\n\tconst activateLink =\n\t\tTHEMES_URL + `?${ activateQuery }`.replace( /&/g, '&' );\n\n\tresponse = await this.request.get( activateLink );\n\n\tawait response.dispose();\n}\n\n// https://developer.wordpress.org/rest-api/reference/themes/#definition\nasync function getCurrentThemeGlobalStylesPostId( this: RequestUtils ) {\n\ttype ThemeItem = {\n\t\tstylesheet: string;\n\t\tstatus: string;\n\t\t_links: { 'wp:user-global-styles': { href: string }[] };\n\t};\n\tconst themes = await this.rest< ThemeItem[] >( {\n\t\tpath: '/wp/v2/themes',\n\t} );\n\tlet themeGlobalStylesId: string = '';\n\tif ( themes && themes.length ) {\n\t\tconst currentTheme: ThemeItem | undefined = themes.find(\n\t\t\t( { status } ) => status === 'active'\n\t\t);\n\n\t\tconst globalStylesURL =\n\t\t\tcurrentTheme?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]?.href;\n\t\tif ( globalStylesURL ) {\n\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA4B;AAE5B,IAAM,aAAa,IAAI,IAAK,uBAAuB,yBAAY,EAAE;AAEjE,eAAe,cAEd,WACkB;AAClB,MAAI,WAAW,MAAM,KAAK,QAAQ,IAAK,UAAW;AAClD,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAM,iBAAiB;AAKvB,MAAI,aAAa,KAAK;AAAA,IACrB,kCAAmC;AAAA,MAClC;AAAA,IACD,CAAE;AAAA,EACH;AAGA,MAAK,CAAE,YAAa;AACnB,iBAAa,KAAK;AAAA,MACjB,kCAAmC,cAAe,GAAI;AAAA,QACrD;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAEA,MAAK,CAAE,YAAa;AACnB,QAAK,KAAK,SAAU,cAAe,SAAU,GAAI,GAAI;AAEpD;AAAA,IACD;AAEA,UAAM,IAAI,MAAO,cAAe,SAAU,oBAAqB;AAAA,EAChE;AAEA,QAAM,CAAE,aAAc,IAAI;AAC1B,QAAM,eACL,aAAa,IAAK,aAAc,GAAG,QAAS,UAAU,GAAI;AAE3D,aAAW,MAAM,KAAK,QAAQ,IAAK,YAAa;AAEhD,QAAM,SAAS,QAAQ;AACxB;AAGA,eAAe,oCAAwD;AAMtE,QAAM,SAAS,MAAM,KAAK,KAAqB;AAAA,IAC9C,MAAM;AAAA,EACP,CAAE;AACF,MAAI,sBAA8B;AAClC,MAAK,UAAU,OAAO,QAAS;AAC9B,UAAM,eAAsC,OAAO;AAAA,MAClD,CAAE,EAAE,OAAO,MAAO,WAAW;AAAA,IAC9B;AAEA,UAAM,kBACL,cAAc,SAAU,uBAAwB,IAAK,CAAE,GAAG;AAC3D,QAAK,iBAAkB;
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RequestUtils } from './index';\nimport { WP_BASE_URL } from '../config';\n\nconst THEMES_URL = new URL( 'wp-admin/themes.php', WP_BASE_URL ).href;\n\nasync function activateTheme(\n\tthis: RequestUtils,\n\tthemeSlug: string\n): Promise< void > {\n\tlet response = await this.request.get( THEMES_URL );\n\tconst html = await response.text();\n\tconst optionalFolder = '([a-z0-9-]+%2F)?';\n\n\t// The `optionalFolder` regex part matches paths with a folder,\n\t// so it will return the first match, which might contain a folder.\n\t// First try to honor the included theme slug, that is, without a folder.\n\tlet matchGroup = html.match(\n\t\t`action=activate&stylesheet=${ encodeURIComponent(\n\t\t\tthemeSlug\n\t\t) }&_wpnonce=[a-z0-9]+`\n\t);\n\n\t// If the theme is not found, try to match the theme slug with a folder.\n\tif ( ! matchGroup ) {\n\t\tmatchGroup = html.match(\n\t\t\t`action=activate&stylesheet=${ optionalFolder }${ encodeURIComponent(\n\t\t\t\tthemeSlug\n\t\t\t) }&_wpnonce=[a-z0-9]+`\n\t\t);\n\t}\n\n\tif ( ! matchGroup ) {\n\t\tif ( html.includes( `data-slug=\"${ themeSlug }\"` ) ) {\n\t\t\t// The theme is already activated.\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error( `The theme \"${ themeSlug }\" is not installed` );\n\t}\n\n\tconst [ activateQuery ] = matchGroup;\n\tconst activateLink =\n\t\tTHEMES_URL + `?${ activateQuery }`.replace( /&/g, '&' );\n\n\tresponse = await this.request.get( activateLink );\n\n\tawait response.dispose();\n}\n\n// https://developer.wordpress.org/rest-api/reference/themes/#definition\nasync function getCurrentThemeGlobalStylesPostId( this: RequestUtils ) {\n\ttype ThemeItem = {\n\t\tstylesheet: string;\n\t\tstatus: string;\n\t\t_links: { 'wp:user-global-styles': { href: string }[] };\n\t};\n\tconst themes = await this.rest< ThemeItem[] >( {\n\t\tpath: '/wp/v2/themes',\n\t} );\n\tlet themeGlobalStylesId: string = '';\n\tif ( themes && themes.length ) {\n\t\tconst currentTheme: ThemeItem | undefined = themes.find(\n\t\t\t( { status } ) => status === 'active'\n\t\t);\n\n\t\tconst globalStylesURL =\n\t\t\tcurrentTheme?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]?.href;\n\t\tif ( globalStylesURL ) {\n\t\t\t// Extract the ID from the URL. The URL format depends on\n\t\t\t// the permalink structure:\n\t\t\t// - Plain: ?rest_route=/wp/v2/global-styles/123\n\t\t\t// - Pretty: /wp-json/wp/v2/global-styles/123\n\t\t\tconst idMatch = globalStylesURL.match(\n\t\t\t\t/\\/wp\\/v2\\/global-styles\\/(\\d+)/\n\t\t\t);\n\t\t\tif ( idMatch ) {\n\t\t\t\tthemeGlobalStylesId = idMatch[ 1 ];\n\t\t\t}\n\t\t}\n\t}\n\treturn themeGlobalStylesId;\n}\n\n/**\n * Deletes all post revisions using the REST API.\n *\n * @param {} this RequestUtils.\n * @param {string|number} parentId Post attributes.\n */\nasync function getThemeGlobalStylesRevisions(\n\tthis: RequestUtils,\n\tparentId: number | string\n) {\n\t// Lists all global styles revisions.\n\treturn await this.rest< Record< string, Object >[] >( {\n\t\tpath: `/wp/v2/global-styles/${ parentId }/revisions`,\n\t\tparams: {\n\t\t\tper_page: 100,\n\t\t},\n\t} );\n}\n\nexport {\n\tactivateTheme,\n\tgetCurrentThemeGlobalStylesPostId,\n\tgetThemeGlobalStylesRevisions,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAA4B;AAE5B,IAAM,aAAa,IAAI,IAAK,uBAAuB,yBAAY,EAAE;AAEjE,eAAe,cAEd,WACkB;AAClB,MAAI,WAAW,MAAM,KAAK,QAAQ,IAAK,UAAW;AAClD,QAAM,OAAO,MAAM,SAAS,KAAK;AACjC,QAAM,iBAAiB;AAKvB,MAAI,aAAa,KAAK;AAAA,IACrB,kCAAmC;AAAA,MAClC;AAAA,IACD,CAAE;AAAA,EACH;AAGA,MAAK,CAAE,YAAa;AACnB,iBAAa,KAAK;AAAA,MACjB,kCAAmC,cAAe,GAAI;AAAA,QACrD;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAEA,MAAK,CAAE,YAAa;AACnB,QAAK,KAAK,SAAU,cAAe,SAAU,GAAI,GAAI;AAEpD;AAAA,IACD;AAEA,UAAM,IAAI,MAAO,cAAe,SAAU,oBAAqB;AAAA,EAChE;AAEA,QAAM,CAAE,aAAc,IAAI;AAC1B,QAAM,eACL,aAAa,IAAK,aAAc,GAAG,QAAS,UAAU,GAAI;AAE3D,aAAW,MAAM,KAAK,QAAQ,IAAK,YAAa;AAEhD,QAAM,SAAS,QAAQ;AACxB;AAGA,eAAe,oCAAwD;AAMtE,QAAM,SAAS,MAAM,KAAK,KAAqB;AAAA,IAC9C,MAAM;AAAA,EACP,CAAE;AACF,MAAI,sBAA8B;AAClC,MAAK,UAAU,OAAO,QAAS;AAC9B,UAAM,eAAsC,OAAO;AAAA,MAClD,CAAE,EAAE,OAAO,MAAO,WAAW;AAAA,IAC9B;AAEA,UAAM,kBACL,cAAc,SAAU,uBAAwB,IAAK,CAAE,GAAG;AAC3D,QAAK,iBAAkB;AAKtB,YAAM,UAAU,gBAAgB;AAAA,QAC/B;AAAA,MACD;AACA,UAAK,SAAU;AACd,8BAAsB,QAAS,CAAE;AAAA,MAClC;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAQA,eAAe,8BAEd,UACC;AAED,SAAO,MAAM,KAAK,KAAoC;AAAA,IACrD,MAAM,wBAAyB,QAAS;AAAA,IACxC,QAAQ;AAAA,MACP,UAAU;AAAA,IACX;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -39,7 +39,14 @@ async function getCurrentThemeGlobalStylesPostId() {
|
|
|
39
39
|
const currentTheme = themes.find(({ status }) => status === 'active');
|
|
40
40
|
const globalStylesURL = currentTheme?._links?.['wp:user-global-styles']?.[0]?.href;
|
|
41
41
|
if (globalStylesURL) {
|
|
42
|
-
|
|
42
|
+
// Extract the ID from the URL. The URL format depends on
|
|
43
|
+
// the permalink structure:
|
|
44
|
+
// - Plain: ?rest_route=/wp/v2/global-styles/123
|
|
45
|
+
// - Pretty: /wp-json/wp/v2/global-styles/123
|
|
46
|
+
const idMatch = globalStylesURL.match(/\/wp\/v2\/global-styles\/(\d+)/);
|
|
47
|
+
if (idMatch) {
|
|
48
|
+
themeGlobalStylesId = idMatch[1];
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
return themeGlobalStylesId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../../src/request-utils/themes.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"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IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,MAAM,GACf,OAAO,CAAE,IAAI,CAAE,CAuCjB;AAGD,iBAAe,iCAAiC,CAAE,IAAI,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/request-utils/themes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK5C,iBAAe,aAAa,CAC3B,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,MAAM,GACf,OAAO,CAAE,IAAI,CAAE,CAuCjB;AAGD,iBAAe,iCAAiC,CAAE,IAAI,EAAE,YAAY,mBA+BnE;AAED;;;;;GAKG;AACH,iBAAe,6BAA6B,CAC3C,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,GAAG,MAAM,qCASzB;AAED,OAAO,EACN,aAAa,EACb,iCAAiC,EACjC,6BAA6B,GAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/e2e-test-utils-playwright",
|
|
3
|
-
"version": "1.40.0",
|
|
3
|
+
"version": "1.40.1-next.v.202602200903.0+06edfb869",
|
|
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",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "6e225a6505fdc8e407305851c7a68b781dee8118"
|
|
58
58
|
}
|