@wordpress/e2e-test-utils-playwright 0.1.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.
- package/LICENSE.md +788 -0
- package/README.md +89 -0
- package/build/admin/create-new-post.js +49 -0
- package/build/admin/create-new-post.js.map +1 -0
- package/build/admin/get-page-error.js +27 -0
- package/build/admin/get-page-error.js.map +1 -0
- package/build/admin/index.js +32 -0
- package/build/admin/index.js.map +1 -0
- package/build/admin/visit-admin-page.js +33 -0
- package/build/admin/visit-admin-page.js.map +1 -0
- package/build/admin/visit-site-editor.js +42 -0
- package/build/admin/visit-site-editor.js.map +1 -0
- package/build/config.js +13 -0
- package/build/config.js.map +1 -0
- package/build/editor/click-block-options-menu-item.js +17 -0
- package/build/editor/click-block-options-menu-item.js.map +1 -0
- package/build/editor/click-block-toolbar-button.js +17 -0
- package/build/editor/click-block-toolbar-button.js.map +1 -0
- package/build/editor/get-blocks.js +23 -0
- package/build/editor/get-blocks.js.map +1 -0
- package/build/editor/get-edited-post-content.js +15 -0
- package/build/editor/get-edited-post-content.js.map +1 -0
- package/build/editor/index.js +63 -0
- package/build/editor/index.js.map +1 -0
- package/build/editor/insert-block.js +20 -0
- package/build/editor/insert-block.js.map +1 -0
- package/build/editor/open-document-settings-sidebar.js +27 -0
- package/build/editor/open-document-settings-sidebar.js.map +1 -0
- package/build/editor/preview.js +22 -0
- package/build/editor/preview.js.map +1 -0
- package/build/editor/publish-post.js +30 -0
- package/build/editor/publish-post.js.map +1 -0
- package/build/editor/select-blocks.js +29 -0
- package/build/editor/select-blocks.js.map +1 -0
- package/build/editor/set-content.js +17 -0
- package/build/editor/set-content.js.map +1 -0
- package/build/editor/set-is-fixed-toolbar.js +20 -0
- package/build/editor/set-is-fixed-toolbar.js.map +1 -0
- package/build/editor/show-block-toolbar.js +20 -0
- package/build/editor/show-block-toolbar.js.map +1 -0
- package/build/editor/site-editor.js +19 -0
- package/build/editor/site-editor.js.map +1 -0
- package/build/editor/transform-block-to.js +24 -0
- package/build/editor/transform-block-to.js.map +1 -0
- package/build/index.js +30 -0
- package/build/index.js.map +1 -0
- package/build/page-utils/drag-files.js +115 -0
- package/build/page-utils/drag-files.js.map +1 -0
- package/build/page-utils/index.js +32 -0
- package/build/page-utils/index.js.map +1 -0
- package/build/page-utils/is-current-url.js +22 -0
- package/build/page-utils/is-current-url.js.map +1 -0
- package/build/page-utils/press-keys.js +123 -0
- package/build/page-utils/press-keys.js.map +1 -0
- package/build/page-utils/set-browser-viewport.js +47 -0
- package/build/page-utils/set-browser-viewport.js.map +1 -0
- package/build/request-utils/blocks.js +30 -0
- package/build/request-utils/blocks.js.map +1 -0
- package/build/request-utils/comments.js +52 -0
- package/build/request-utils/comments.js.map +1 -0
- package/build/request-utils/index.js +148 -0
- package/build/request-utils/index.js.map +1 -0
- package/build/request-utils/login.js +22 -0
- package/build/request-utils/login.js.map +1 -0
- package/build/request-utils/media.js +74 -0
- package/build/request-utils/media.js.map +1 -0
- package/build/request-utils/menus.js +121 -0
- package/build/request-utils/menus.js.map +1 -0
- package/build/request-utils/pages.js +59 -0
- package/build/request-utils/pages.js.map +1 -0
- package/build/request-utils/plugins.js +69 -0
- package/build/request-utils/plugins.js.map +1 -0
- package/build/request-utils/posts.js +47 -0
- package/build/request-utils/posts.js.map +1 -0
- package/build/request-utils/preferences.js +21 -0
- package/build/request-utils/preferences.js.map +1 -0
- package/build/request-utils/rest.js +130 -0
- package/build/request-utils/rest.js.map +1 -0
- package/build/request-utils/site-settings.js +34 -0
- package/build/request-utils/site-settings.js.map +1 -0
- package/build/request-utils/templates.js +39 -0
- package/build/request-utils/templates.js.map +1 -0
- package/build/request-utils/themes.js +56 -0
- package/build/request-utils/themes.js.map +1 -0
- package/build/request-utils/users.js +82 -0
- package/build/request-utils/users.js.map +1 -0
- package/build/request-utils/widgets.js +62 -0
- package/build/request-utils/widgets.js.map +1 -0
- package/build/test.js +122 -0
- package/build/test.js.map +1 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/build-types/admin/create-new-post.d.ts +19 -0
- package/build-types/admin/create-new-post.d.ts.map +1 -0
- package/build-types/admin/get-page-error.d.ts +17 -0
- package/build-types/admin/get-page-error.d.ts.map +1 -0
- package/build-types/admin/index.d.ts +33 -0
- package/build-types/admin/index.d.ts.map +1 -0
- package/build-types/admin/visit-admin-page.d.ts +13 -0
- package/build-types/admin/visit-admin-page.d.ts.map +1 -0
- package/build-types/admin/visit-site-editor.d.ts +19 -0
- package/build-types/admin/visit-site-editor.d.ts.map +1 -0
- package/build-types/config.d.ts +7 -0
- package/build-types/config.d.ts.map +1 -0
- package/build-types/editor/click-block-options-menu-item.d.ts +12 -0
- package/build-types/editor/click-block-options-menu-item.d.ts.map +1 -0
- package/build-types/editor/click-block-toolbar-button.d.ts +12 -0
- package/build-types/editor/click-block-toolbar-button.d.ts.map +1 -0
- package/build-types/editor/get-blocks.d.ts +13 -0
- package/build-types/editor/get-blocks.d.ts.map +1 -0
- package/build-types/editor/get-edited-post-content.d.ts +13 -0
- package/build-types/editor/get-edited-post-content.d.ts.map +1 -0
- package/build-types/editor/index.d.ts +61 -0
- package/build-types/editor/index.d.ts.map +1 -0
- package/build-types/editor/insert-block.d.ts +19 -0
- package/build-types/editor/insert-block.d.ts.map +1 -0
- package/build-types/editor/open-document-settings-sidebar.d.ts +12 -0
- package/build-types/editor/open-document-settings-sidebar.d.ts.map +1 -0
- package/build-types/editor/preview.d.ts +17 -0
- package/build-types/editor/preview.d.ts.map +1 -0
- package/build-types/editor/publish-post.d.ts +12 -0
- package/build-types/editor/publish-post.d.ts.map +1 -0
- package/build-types/editor/select-blocks.d.ts +10 -0
- package/build-types/editor/select-blocks.d.ts.map +1 -0
- package/build-types/editor/set-content.d.ts +13 -0
- package/build-types/editor/set-content.d.ts.map +1 -0
- package/build-types/editor/set-is-fixed-toolbar.d.ts +12 -0
- package/build-types/editor/set-is-fixed-toolbar.d.ts.map +1 -0
- package/build-types/editor/show-block-toolbar.d.ts +12 -0
- package/build-types/editor/show-block-toolbar.d.ts.map +1 -0
- package/build-types/editor/site-editor.d.ts +11 -0
- package/build-types/editor/site-editor.d.ts.map +1 -0
- package/build-types/editor/transform-block-to.d.ts +12 -0
- package/build-types/editor/transform-block-to.d.ts.map +1 -0
- package/build-types/index.d.ts +7 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/page-utils/drag-files.d.ts +40 -0
- package/build-types/page-utils/drag-files.d.ts.map +1 -0
- package/build-types/page-utils/index.d.ts +32 -0
- package/build-types/page-utils/index.d.ts.map +1 -0
- package/build-types/page-utils/is-current-url.d.ts +11 -0
- package/build-types/page-utils/is-current-url.d.ts.map +1 -0
- package/build-types/page-utils/press-keys.d.ts +25 -0
- package/build-types/page-utils/press-keys.d.ts.map +1 -0
- package/build-types/page-utils/set-browser-viewport.d.ts +34 -0
- package/build-types/page-utils/set-browser-viewport.d.ts.map +1 -0
- package/build-types/request-utils/blocks.d.ts +8 -0
- package/build-types/request-utils/blocks.d.ts.map +1 -0
- package/build-types/request-utils/comments.d.ts +31 -0
- package/build-types/request-utils/comments.d.ts.map +1 -0
- package/build-types/request-utils/index.d.ts +111 -0
- package/build-types/request-utils/index.d.ts.map +1 -0
- package/build-types/request-utils/login.d.ts +11 -0
- package/build-types/request-utils/login.d.ts.map +1 -0
- package/build-types/request-utils/media.d.ts +54 -0
- package/build-types/request-utils/media.d.ts.map +1 -0
- package/build-types/request-utils/menus.d.ts +43 -0
- package/build-types/request-utils/menus.d.ts.map +1 -0
- package/build-types/request-utils/pages.d.ts +32 -0
- package/build-types/request-utils/pages.d.ts.map +1 -0
- package/build-types/request-utils/plugins.d.ts +28 -0
- package/build-types/request-utils/plugins.d.ts.map +1 -0
- package/build-types/request-utils/posts.d.ts +30 -0
- package/build-types/request-utils/posts.d.ts.map +1 -0
- package/build-types/request-utils/preferences.d.ts +11 -0
- package/build-types/request-utils/preferences.d.ts.map +1 -0
- package/build-types/request-utils/rest.d.ts +24 -0
- package/build-types/request-utils/rest.d.ts.map +1 -0
- package/build-types/request-utils/site-settings.d.ts +40 -0
- package/build-types/request-utils/site-settings.d.ts.map +1 -0
- package/build-types/request-utils/templates.d.ts +14 -0
- package/build-types/request-utils/templates.d.ts.map +1 -0
- package/build-types/request-utils/themes.d.ts +15 -0
- package/build-types/request-utils/themes.d.ts.map +1 -0
- package/build-types/request-utils/users.d.ts +40 -0
- package/build-types/request-utils/users.d.ts.map +1 -0
- package/build-types/request-utils/widgets.d.ts +15 -0
- package/build-types/request-utils/widgets.d.ts.map +1 -0
- package/build-types/test.d.ts +15 -0
- package/build-types/test.d.ts.map +1 -0
- package/build-types/types.d.ts +7 -0
- package/build-types/types.d.ts.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# E2E Test Utils
|
|
2
|
+
|
|
3
|
+
End-To-End (E2E) Playwright test utils for WordPress.
|
|
4
|
+
|
|
5
|
+
_It works properly with the minimum version of Gutenberg `9.2.0` or the minimum version of WordPress `5.6.0`._
|
|
6
|
+
|
|
7
|
+
<div class="callout callout-alert">
|
|
8
|
+
This package is still under active development. Documentation might not be up-to-date, and the <code>v0.x</code> version can introduce breaking changes without a detailed migration guide. Early adopters are encouraged to use a <a href="https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json">lock file</a> to prevent unexpected breakages.
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the module
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @wordpress/e2e-test-utils-playwright --save-dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Note**: This package requires Node.js 12.0.0 or later. It is not compatible with older versions.
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### test
|
|
24
|
+
|
|
25
|
+
The extended Playwright's [test](https://playwright.dev/docs/api/class-test) module with the `admin`, `editor`, `pageUtils` and the `requestUtils` fixtures.
|
|
26
|
+
|
|
27
|
+
### expect
|
|
28
|
+
|
|
29
|
+
The Playwright/Jest's [expect](https://jestjs.io/docs/expect) function.
|
|
30
|
+
|
|
31
|
+
### Admin
|
|
32
|
+
|
|
33
|
+
End to end test utilities for WordPress admin's user interface.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
const admin = new Admin( { page, pageUtils } );
|
|
37
|
+
await admin.visitAdminPage( 'options-general.php' );
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Editor
|
|
41
|
+
|
|
42
|
+
End to end test utilities for the WordPress Block Editor.
|
|
43
|
+
|
|
44
|
+
To use these utilities, instantiate them within each test file:
|
|
45
|
+
```js
|
|
46
|
+
test.use( {
|
|
47
|
+
editor: async ( { page }, use ) => {
|
|
48
|
+
await use( new Editor( { page } ) );
|
|
49
|
+
},
|
|
50
|
+
} );
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Within a test or test utility, use the `canvas` property to select elements within the iframe canvas:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
await editor.canvas.locator( 'role=document[name="Paragraph block"i]' )
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### PageUtils
|
|
60
|
+
|
|
61
|
+
Generic Playwright utilities for interacting with web pages.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const pageUtils = new PageUtils( { page } );
|
|
65
|
+
await pageUtils.pressKeys( 'primary+a' );
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### RequestUtils
|
|
69
|
+
|
|
70
|
+
Playwright utilities for interacting with the WordPress REST API.
|
|
71
|
+
|
|
72
|
+
Create a request utils instance.
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const requestUtils = await RequestUtils.setup( {
|
|
76
|
+
user: {
|
|
77
|
+
username: 'admin',
|
|
78
|
+
password: 'password',
|
|
79
|
+
},
|
|
80
|
+
} );
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Contributing to this package
|
|
84
|
+
|
|
85
|
+
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
|
86
|
+
|
|
87
|
+
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
|
|
88
|
+
|
|
89
|
+
<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNewPost = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
const url_1 = require("@wordpress/url");
|
|
8
|
+
/**
|
|
9
|
+
* Creates new post.
|
|
10
|
+
*
|
|
11
|
+
* @this {import('.').Editor}
|
|
12
|
+
* @param {Object} object Object to create new post, along with tips enabling option.
|
|
13
|
+
* @param {string} [object.postType] Post type of the new post.
|
|
14
|
+
* @param {string} [object.title] Title of the new post.
|
|
15
|
+
* @param {string} [object.content] Content of the new post.
|
|
16
|
+
* @param {string} [object.excerpt] Excerpt of the new post.
|
|
17
|
+
* @param {boolean} [object.showWelcomeGuide] Whether to show the welcome guide.
|
|
18
|
+
*/
|
|
19
|
+
async function createNewPost({ postType, title, content, excerpt, showWelcomeGuide = false, } = {}) {
|
|
20
|
+
const query = (0, url_1.addQueryArgs)('', {
|
|
21
|
+
post_type: postType,
|
|
22
|
+
post_title: title,
|
|
23
|
+
content,
|
|
24
|
+
excerpt,
|
|
25
|
+
}).slice(1);
|
|
26
|
+
await this.visitAdminPage('post-new.php', query);
|
|
27
|
+
await this.page.waitForSelector('.edit-post-layout');
|
|
28
|
+
const isWelcomeGuideActive = await this.page.evaluate(() => window.wp.data
|
|
29
|
+
.select('core/edit-post')
|
|
30
|
+
.isFeatureActive('welcomeGuide'));
|
|
31
|
+
const isFullscreenMode = await this.page.evaluate(() => window.wp.data
|
|
32
|
+
.select('core/edit-post')
|
|
33
|
+
.isFeatureActive('fullscreenMode'));
|
|
34
|
+
if (showWelcomeGuide !== isWelcomeGuideActive) {
|
|
35
|
+
await this.page.evaluate(() => window.wp.data
|
|
36
|
+
.dispatch('core/edit-post')
|
|
37
|
+
.toggleFeature('welcomeGuide'));
|
|
38
|
+
await this.page.reload();
|
|
39
|
+
await this.page.waitForSelector('.edit-post-layout');
|
|
40
|
+
}
|
|
41
|
+
if (isFullscreenMode) {
|
|
42
|
+
await this.page.evaluate(() => window.wp.data
|
|
43
|
+
.dispatch('core/edit-post')
|
|
44
|
+
.toggleFeature('fullscreenMode'));
|
|
45
|
+
await this.page.waitForSelector('body:not(.is-fullscreen-mode)');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.createNewPost = createNewPost;
|
|
49
|
+
//# sourceMappingURL=create-new-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-new-post.js","sourceRoot":"","sources":["../../src/admin/create-new-post.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wCAA8C;AAE9C;;;;;;;;;;GAUG;AACI,KAAK,UAAU,aAAa,CAAE,EACpC,QAAQ,EACR,KAAK,EACL,OAAO,EACP,OAAO,EACP,gBAAgB,GAAG,KAAK,GACxB,GAAG,EAAE;IACL,MAAM,KAAK,GAAG,IAAA,kBAAY,EAAE,EAAE,EAAE;QAC/B,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,KAAK;QACjB,OAAO;QACP,OAAO;KACP,CAAE,CAAC,KAAK,CAAE,CAAC,CAAE,CAAC;IAEf,MAAM,IAAI,CAAC,cAAc,CAAE,cAAc,EAAE,KAAK,CAAE,CAAC;IAEnD,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,mBAAmB,CAAE,CAAC;IAEvD,MAAM,oBAAoB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CAC3D,MAAM,CAAC,EAAE,CAAC,IAAI;SACZ,MAAM,CAAE,gBAAgB,CAAE;SAC1B,eAAe,CAAE,cAAc,CAAE,CACnC,CAAC;IACF,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CACvD,MAAM,CAAC,EAAE,CAAC,IAAI;SACZ,MAAM,CAAE,gBAAgB,CAAE;SAC1B,eAAe,CAAE,gBAAgB,CAAE,CACrC,CAAC;IAEF,IAAK,gBAAgB,KAAK,oBAAoB,EAAG;QAChD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CAC9B,MAAM,CAAC,EAAE,CAAC,IAAI;aACZ,QAAQ,CAAE,gBAAgB,CAAE;aAC5B,aAAa,CAAE,cAAc,CAAE,CACjC,CAAC;QAEF,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,mBAAmB,CAAE,CAAC;KACvD;IAED,IAAK,gBAAgB,EAAG;QACvB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CAC9B,MAAM,CAAC,EAAE,CAAC,IAAI;aACZ,QAAQ,CAAE,gBAAgB,CAAE;aAC5B,aAAa,CAAE,gBAAgB,CAAE,CACnC,CAAC;QAEF,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe,CAAE,+BAA+B,CAAE,CAAC;KACnE;AACF,CAAC;AAjDD,sCAiDC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPageError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Regular expression matching a displayed PHP error within a markup string.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/php/php-src/blob/598175e/main/main.c#L1257-L1297
|
|
8
|
+
*/
|
|
9
|
+
const REGEXP_PHP_ERROR = /(<b>)?(Fatal error|Recoverable fatal error|Warning|Parse error|Notice|Strict Standards|Deprecated|Unknown error)(<\/b>)?: (.*?) in (.*?) on line (<b>)?\d+(<\/b>)?/;
|
|
10
|
+
/**
|
|
11
|
+
* Returns a promise resolving to one of either a string or null. A string will
|
|
12
|
+
* be resolved if an error message is present in the contents of the page. If no
|
|
13
|
+
* error is present, a null value will be resolved instead. This requires the
|
|
14
|
+
* environment be configured to display errors.
|
|
15
|
+
*
|
|
16
|
+
* @see http://php.net/manual/en/function.error-reporting.php
|
|
17
|
+
*
|
|
18
|
+
* @param this
|
|
19
|
+
* @return Promise resolving to a string or null, depending whether a page error is present.
|
|
20
|
+
*/
|
|
21
|
+
async function getPageError() {
|
|
22
|
+
const content = await this.page.content();
|
|
23
|
+
const match = content.match(REGEXP_PHP_ERROR);
|
|
24
|
+
return match ? match[0] : null;
|
|
25
|
+
}
|
|
26
|
+
exports.getPageError = getPageError;
|
|
27
|
+
//# sourceMappingURL=get-page-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-page-error.js","sourceRoot":"","sources":["../../src/admin/get-page-error.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACH,MAAM,gBAAgB,GACrB,oKAAoK,CAAC;AAEtK;;;;;;;;;;GAUG;AACI,KAAK,UAAU,YAAY;IACjC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAE,gBAAgB,CAAE,CAAC;IAChD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAE,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClC,CAAC;AAJD,oCAIC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Admin = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Internal dependencies
|
|
6
|
+
*/
|
|
7
|
+
const create_new_post_1 = require("./create-new-post");
|
|
8
|
+
const get_page_error_1 = require("./get-page-error");
|
|
9
|
+
const visit_admin_page_1 = require("./visit-admin-page");
|
|
10
|
+
const visit_site_editor_1 = require("./visit-site-editor");
|
|
11
|
+
class Admin {
|
|
12
|
+
browser;
|
|
13
|
+
page;
|
|
14
|
+
pageUtils;
|
|
15
|
+
context;
|
|
16
|
+
constructor({ page, pageUtils }) {
|
|
17
|
+
this.page = page;
|
|
18
|
+
this.context = page.context();
|
|
19
|
+
this.browser = this.context.browser();
|
|
20
|
+
this.pageUtils = pageUtils;
|
|
21
|
+
}
|
|
22
|
+
/** @borrows createNewPost as this.createNewPost */
|
|
23
|
+
createNewPost = create_new_post_1.createNewPost.bind(this);
|
|
24
|
+
/** @borrows getPageError as this.getPageError */
|
|
25
|
+
getPageError = get_page_error_1.getPageError.bind(this);
|
|
26
|
+
/** @borrows visitAdminPage as this.visitAdminPage */
|
|
27
|
+
visitAdminPage = visit_admin_page_1.visitAdminPage.bind(this);
|
|
28
|
+
/** @borrows visitSiteEditor as this.visitSiteEditor */
|
|
29
|
+
visitSiteEditor = visit_site_editor_1.visitSiteEditor.bind(this);
|
|
30
|
+
}
|
|
31
|
+
exports.Admin = Admin;
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/admin/index.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,uDAAkD;AAClD,qDAAgD;AAChD,yDAAoD;AACpD,2DAAsD;AAQtD,MAAa,KAAK;IACjB,OAAO,CAAU;IACjB,IAAI,CAAO;IACX,SAAS,CAAY;IACrB,OAAO,CAAiB;IAExB,YAAa,EAAE,IAAI,EAAE,SAAS,EAAyB;QACtD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAG,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,mDAAmD;IACnD,aAAa,GAAyB,+BAAa,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACjE,iDAAiD;IACjD,YAAY,GAAwB,6BAAY,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC9D,qDAAqD;IACrD,cAAc,GAA0B,iCAAc,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACpE,uDAAuD;IACvD,eAAe,GAA2B,mCAAe,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;CACvE;AArBD,sBAqBC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visitAdminPage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
/**
|
|
9
|
+
* Visits admin page and handle errors.
|
|
10
|
+
*
|
|
11
|
+
* @param this
|
|
12
|
+
* @param adminPath String to be serialized as pathname.
|
|
13
|
+
* @param query String to be serialized as query portion of URL.
|
|
14
|
+
*/
|
|
15
|
+
async function visitAdminPage(adminPath, query) {
|
|
16
|
+
await this.page.goto((0, path_1.join)('wp-admin', adminPath) + (query ? `?${query}` : ''));
|
|
17
|
+
// Handle upgrade required screen
|
|
18
|
+
if (this.pageUtils.isCurrentURL('wp-admin/upgrade.php')) {
|
|
19
|
+
// Click update
|
|
20
|
+
await this.page.click('.button.button-large.button-primary');
|
|
21
|
+
// Click continue
|
|
22
|
+
await this.page.click('.button.button-large');
|
|
23
|
+
}
|
|
24
|
+
if (this.pageUtils.isCurrentURL('wp-login.php')) {
|
|
25
|
+
throw new Error('Not logged in');
|
|
26
|
+
}
|
|
27
|
+
const error = await this.getPageError();
|
|
28
|
+
if (error) {
|
|
29
|
+
throw new Error('Unexpected error in page content: ' + error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.visitAdminPage = visitAdminPage;
|
|
33
|
+
//# sourceMappingURL=visit-admin-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visit-admin-page.js","sourceRoot":"","sources":["../../src/admin/visit-admin-page.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+BAA4B;AAO5B;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAEnC,SAAiB,EACjB,KAAa;IAEb,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,IAAA,WAAI,EAAE,UAAU,EAAE,SAAS,CAAE,GAAG,CAAE,KAAK,CAAC,CAAC,CAAC,IAAK,KAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAE,CAC9D,CAAC;IAEF,iCAAiC;IACjC,IAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAE,sBAAsB,CAAE,EAAG;QAC5D,eAAe;QACf,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,qCAAqC,CAAE,CAAC;QAC/D,iBAAiB;QACjB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,sBAAsB,CAAE,CAAC;KAChD;IAED,IAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAE,cAAc,CAAE,EAAG;QACpD,MAAM,IAAI,KAAK,CAAE,eAAe,CAAE,CAAC;KACnC;IAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IACxC,IAAK,KAAK,EAAG;QACZ,MAAM,IAAI,KAAK,CAAE,oCAAoC,GAAG,KAAK,CAAE,CAAC;KAChE;AACF,CAAC;AAzBD,wCAyBC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.visitSiteEditor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
const url_1 = require("@wordpress/url");
|
|
8
|
+
const CANVAS_SELECTOR = 'iframe[title="Editor canvas"i]';
|
|
9
|
+
/**
|
|
10
|
+
* Visits the Site Editor main page
|
|
11
|
+
*
|
|
12
|
+
* By default, it also skips the welcome guide. The option can be disabled if need be.
|
|
13
|
+
*
|
|
14
|
+
* @param this
|
|
15
|
+
* @param query Query params to be serialized as query portion of URL.
|
|
16
|
+
* @param skipWelcomeGuide Whether to skip the welcome guide as part of the navigation.
|
|
17
|
+
*/
|
|
18
|
+
async function visitSiteEditor(query, skipWelcomeGuide = true) {
|
|
19
|
+
const path = (0, url_1.addQueryArgs)('', {
|
|
20
|
+
...query,
|
|
21
|
+
}).slice(1);
|
|
22
|
+
await this.visitAdminPage('site-editor.php', path);
|
|
23
|
+
if (skipWelcomeGuide) {
|
|
24
|
+
await this.page.evaluate(() => {
|
|
25
|
+
window.wp.data
|
|
26
|
+
.dispatch('core/preferences')
|
|
27
|
+
.set('core/edit-site', 'welcomeGuide', false);
|
|
28
|
+
window.wp.data
|
|
29
|
+
.dispatch('core/preferences')
|
|
30
|
+
.toggle('core/edit-site', 'welcomeGuideStyles', false);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// The site editor initially loads with an empty body,
|
|
34
|
+
// we need to wait for the editor canvas to be rendered.
|
|
35
|
+
await this.page
|
|
36
|
+
.frameLocator(CANVAS_SELECTOR)
|
|
37
|
+
.locator('body > *')
|
|
38
|
+
.first()
|
|
39
|
+
.waitFor();
|
|
40
|
+
}
|
|
41
|
+
exports.visitSiteEditor = visitSiteEditor;
|
|
42
|
+
//# sourceMappingURL=visit-site-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visit-site-editor.js","sourceRoot":"","sources":["../../src/admin/visit-site-editor.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wCAA8C;AAY9C,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAEzD;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CAEpC,KAA4B,EAC5B,gBAAgB,GAAG,IAAI;IAEvB,MAAM,IAAI,GAAG,IAAA,kBAAY,EAAE,EAAE,EAAE;QAC9B,GAAG,KAAK;KACR,CAAE,CAAC,KAAK,CAAE,CAAC,CAAE,CAAC;IAEf,MAAM,IAAI,CAAC,cAAc,CAAE,iBAAiB,EAAE,IAAI,CAAE,CAAC;IAErD,IAAK,gBAAgB,EAAG;QACvB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE;YAC9B,MAAM,CAAC,EAAE,CAAC,IAAI;iBACZ,QAAQ,CAAE,kBAAkB,CAAE;iBAC9B,GAAG,CAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,CAAE,CAAC;YAEjD,MAAM,CAAC,EAAE,CAAC,IAAI;iBACZ,QAAQ,CAAE,kBAAkB,CAAE;iBAC9B,MAAM,CAAE,gBAAgB,EAAE,oBAAoB,EAAE,KAAK,CAAE,CAAC;QAC3D,CAAC,CAAE,CAAC;KACJ;IAED,sDAAsD;IACtD,wDAAwD;IACxD,MAAM,IAAI,CAAC,IAAI;SACb,YAAY,CAAE,eAAe,CAAE;SAC/B,OAAO,CAAE,UAAU,CAAE;SACrB,KAAK,EAAE;SACP,OAAO,EAAE,CAAC;AACb,CAAC;AA9BD,0CA8BC"}
|
package/build/config.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WP_BASE_URL = exports.WP_PASSWORD = exports.WP_USERNAME = exports.WP_ADMIN_USER = void 0;
|
|
4
|
+
const WP_ADMIN_USER = {
|
|
5
|
+
username: 'admin',
|
|
6
|
+
password: 'password',
|
|
7
|
+
};
|
|
8
|
+
exports.WP_ADMIN_USER = WP_ADMIN_USER;
|
|
9
|
+
const { WP_USERNAME = WP_ADMIN_USER.username, WP_PASSWORD = WP_ADMIN_USER.password, WP_BASE_URL = 'http://localhost:8889', } = process.env;
|
|
10
|
+
exports.WP_USERNAME = WP_USERNAME;
|
|
11
|
+
exports.WP_PASSWORD = WP_PASSWORD;
|
|
12
|
+
exports.WP_BASE_URL = WP_BASE_URL;
|
|
13
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,aAAa,GAAG;IACrB,QAAQ,EAAE,OAAO;IACjB,QAAQ,EAAE,UAAU;CACX,CAAC;AAQF,sCAAa;AANtB,MAAM,EACL,WAAW,GAAG,aAAa,CAAC,QAAQ,EACpC,WAAW,GAAG,aAAa,CAAC,QAAQ,EACpC,WAAW,GAAG,uBAAuB,GACrC,GAAG,OAAO,CAAC,GAAG,CAAC;AAEQ,kCAAW;AAAE,kCAAW;AAAE,kCAAW"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clickBlockOptionsMenuItem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Clicks a block toolbar button.
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
* @param label The text string of the button label.
|
|
9
|
+
*/
|
|
10
|
+
async function clickBlockOptionsMenuItem(label) {
|
|
11
|
+
await this.clickBlockToolbarButton('Options');
|
|
12
|
+
await this.page
|
|
13
|
+
.locator(`role=menu[name="Options"i] >> role=menuitem[name="${label}"i]`)
|
|
14
|
+
.click();
|
|
15
|
+
}
|
|
16
|
+
exports.clickBlockOptionsMenuItem = clickBlockOptionsMenuItem;
|
|
17
|
+
//# sourceMappingURL=click-block-options-menu-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-block-options-menu-item.js","sourceRoot":"","sources":["../../src/editor/click-block-options-menu-item.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,yBAAyB,CAAgB,KAAa;IAC3E,MAAM,IAAI,CAAC,uBAAuB,CAAE,SAAS,CAAE,CAAC;IAChD,MAAM,IAAI,CAAC,IAAI;SACb,OAAO,CACP,qDAAsD,KAAM,KAAK,CACjE;SACA,KAAK,EAAE,CAAC;AACX,CAAC;AAPD,8DAOC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clickBlockToolbarButton = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Clicks a block toolbar button.
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
* @param label The text string of the button label.
|
|
9
|
+
*/
|
|
10
|
+
async function clickBlockToolbarButton(label) {
|
|
11
|
+
await this.showBlockToolbar();
|
|
12
|
+
const blockToolbar = this.page.locator('role=toolbar[name="Block tools"i]');
|
|
13
|
+
const button = blockToolbar.locator(`role=button[name="${label}"]`);
|
|
14
|
+
await button.click();
|
|
15
|
+
}
|
|
16
|
+
exports.clickBlockToolbarButton = clickBlockToolbarButton;
|
|
17
|
+
//# sourceMappingURL=click-block-toolbar-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-block-toolbar-button.js","sourceRoot":"","sources":["../../src/editor/click-block-toolbar-button.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,uBAAuB,CAAgB,KAAa;IACzE,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAE9B,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CACrC,mCAAmC,CACnC,CAAC;IACF,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAE,qBAAsB,KAAM,IAAI,CAAE,CAAC;IAExE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;AACtB,CAAC;AATD,0DASC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBlocks = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns the edited blocks.
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
*
|
|
9
|
+
* @return The blocks.
|
|
10
|
+
*/
|
|
11
|
+
async function getBlocks() {
|
|
12
|
+
return await this.page.evaluate(() => {
|
|
13
|
+
const blocks = window.wp.data.select('core/block-editor').getBlocks();
|
|
14
|
+
// The editor might still contain an unmodified empty block even when it's technically "empty".
|
|
15
|
+
if (blocks.length === 1 &&
|
|
16
|
+
window.wp.blocks.isUnmodifiedDefaultBlock(blocks[0])) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
return blocks;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.getBlocks = getBlocks;
|
|
23
|
+
//# sourceMappingURL=get-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-blocks.js","sourceRoot":"","sources":["../../src/editor/get-blocks.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACI,KAAK,UAAU,SAAS;IAC9B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE;QACrC,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAE,mBAAmB,CAAE,CAAC,SAAS,EAAE,CAAC;QAExE,+FAA+F;QAC/F,IACC,MAAM,CAAC,MAAM,KAAK,CAAC;YACnB,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAE,MAAM,CAAE,CAAC,CAAE,CAAE,EACvD;YACD,OAAO,EAAE,CAAC;SACV;QAED,OAAO,MAAM,CAAC;IACf,CAAC,CAAE,CAAC;AACL,CAAC;AAdD,8BAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEditedPostContent = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a promise which resolves with the edited post content (HTML string).
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
*
|
|
9
|
+
* @return Promise resolving with post content markup.
|
|
10
|
+
*/
|
|
11
|
+
async function getEditedPostContent() {
|
|
12
|
+
return await this.page.evaluate(() => window.wp.data.select('core/editor').getEditedPostContent());
|
|
13
|
+
}
|
|
14
|
+
exports.getEditedPostContent = getEditedPostContent;
|
|
15
|
+
//# sourceMappingURL=get-edited-post-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-edited-post-content.js","sourceRoot":"","sources":["../../src/editor/get-edited-post-content.ts"],"names":[],"mappings":";;;AAKA;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB;IACzC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,GAAG,EAAE,CACrC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAE,aAAa,CAAE,CAAC,oBAAoB,EAAE,CAC7D,CAAC;AACH,CAAC;AAJD,oDAIC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Editor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Internal dependencies
|
|
6
|
+
*/
|
|
7
|
+
const click_block_options_menu_item_1 = require("./click-block-options-menu-item");
|
|
8
|
+
const click_block_toolbar_button_1 = require("./click-block-toolbar-button");
|
|
9
|
+
const get_blocks_1 = require("./get-blocks");
|
|
10
|
+
const get_edited_post_content_1 = require("./get-edited-post-content");
|
|
11
|
+
const insert_block_1 = require("./insert-block");
|
|
12
|
+
const open_document_settings_sidebar_1 = require("./open-document-settings-sidebar");
|
|
13
|
+
const preview_1 = require("./preview");
|
|
14
|
+
const publish_post_1 = require("./publish-post");
|
|
15
|
+
const select_blocks_1 = require("./select-blocks");
|
|
16
|
+
const set_content_1 = require("./set-content");
|
|
17
|
+
const show_block_toolbar_1 = require("./show-block-toolbar");
|
|
18
|
+
const site_editor_1 = require("./site-editor");
|
|
19
|
+
const set_is_fixed_toolbar_1 = require("./set-is-fixed-toolbar");
|
|
20
|
+
const transform_block_to_1 = require("./transform-block-to");
|
|
21
|
+
class Editor {
|
|
22
|
+
browser;
|
|
23
|
+
page;
|
|
24
|
+
context;
|
|
25
|
+
constructor({ page }) {
|
|
26
|
+
this.page = page;
|
|
27
|
+
this.context = page.context();
|
|
28
|
+
this.browser = this.context.browser();
|
|
29
|
+
}
|
|
30
|
+
get canvas() {
|
|
31
|
+
return this.page.frame('editor-canvas') || this.page;
|
|
32
|
+
}
|
|
33
|
+
/** @borrows clickBlockOptionsMenuItem as this.clickBlockOptionsMenuItem */
|
|
34
|
+
clickBlockOptionsMenuItem = click_block_options_menu_item_1.clickBlockOptionsMenuItem.bind(this);
|
|
35
|
+
/** @borrows clickBlockToolbarButton as this.clickBlockToolbarButton */
|
|
36
|
+
clickBlockToolbarButton = click_block_toolbar_button_1.clickBlockToolbarButton.bind(this);
|
|
37
|
+
/** @borrows getBlocks as this.getBlocks */
|
|
38
|
+
getBlocks = get_blocks_1.getBlocks.bind(this);
|
|
39
|
+
/** @borrows getEditedPostContent as this.getEditedPostContent */
|
|
40
|
+
getEditedPostContent = get_edited_post_content_1.getEditedPostContent.bind(this);
|
|
41
|
+
/** @borrows insertBlock as this.insertBlock */
|
|
42
|
+
insertBlock = insert_block_1.insertBlock.bind(this);
|
|
43
|
+
/** @borrows openDocumentSettingsSidebar as this.openDocumentSettingsSidebar */
|
|
44
|
+
openDocumentSettingsSidebar = open_document_settings_sidebar_1.openDocumentSettingsSidebar.bind(this);
|
|
45
|
+
/** @borrows openPreviewPage as this.openPreviewPage */
|
|
46
|
+
openPreviewPage = preview_1.openPreviewPage.bind(this);
|
|
47
|
+
/** @borrows publishPost as this.publishPost */
|
|
48
|
+
publishPost = publish_post_1.publishPost.bind(this);
|
|
49
|
+
/** @borrows saveSiteEditorEntities as this.saveSiteEditorEntities */
|
|
50
|
+
saveSiteEditorEntities = site_editor_1.saveSiteEditorEntities.bind(this);
|
|
51
|
+
/** @borrows selectBlocks as this.selectBlocks */
|
|
52
|
+
selectBlocks = select_blocks_1.selectBlocks.bind(this);
|
|
53
|
+
/** @borrows setContent as this.setContent */
|
|
54
|
+
setContent = set_content_1.setContent.bind(this);
|
|
55
|
+
/** @borrows showBlockToolbar as this.showBlockToolbar */
|
|
56
|
+
showBlockToolbar = show_block_toolbar_1.showBlockToolbar.bind(this);
|
|
57
|
+
/** @borrows setIsFixedToolbar as this.setIsFixedToolbar */
|
|
58
|
+
setIsFixedToolbar = set_is_fixed_toolbar_1.setIsFixedToolbar.bind(this);
|
|
59
|
+
/** @borrows transformBlockTo as this.transformBlockTo */
|
|
60
|
+
transformBlockTo = transform_block_to_1.transformBlockTo.bind(this);
|
|
61
|
+
}
|
|
62
|
+
exports.Editor = Editor;
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editor/index.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,mFAA4E;AAC5E,6EAAuE;AACvE,6CAAyC;AACzC,uEAAiE;AACjE,iDAA6C;AAC7C,qFAA+E;AAC/E,uCAA4C;AAC5C,iDAA6C;AAC7C,mDAA+C;AAC/C,+CAA2C;AAC3C,6DAAwD;AACxD,+CAAuD;AACvD,iEAA2D;AAC3D,6DAAwD;AAMxD,MAAa,MAAM;IAClB,OAAO,CAAU;IACjB,IAAI,CAAO;IACX,OAAO,CAAiB;IAExB,YAAa,EAAE,IAAI,EAA0B;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAG,CAAC;IACxC,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,eAAe,CAAE,IAAI,IAAI,CAAC,IAAI,CAAC;IACxD,CAAC;IAED,2EAA2E;IAC3E,yBAAyB,GACxB,yDAAyB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACxC,uEAAuE;IACvE,uBAAuB,GACtB,oDAAuB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACtC,2CAA2C;IAC3C,SAAS,GAAqB,sBAAS,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrD,iEAAiE;IACjE,oBAAoB,GACnB,8CAAoB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACnC,+CAA+C;IAC/C,WAAW,GAAuB,0BAAW,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC3D,+EAA+E;IAC/E,2BAA2B,GAC1B,4DAA2B,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC1C,uDAAuD;IACvD,eAAe,GAA2B,yBAAe,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACvE,+CAA+C;IAC/C,WAAW,GAAuB,0BAAW,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC3D,qEAAqE;IACrE,sBAAsB,GACrB,oCAAsB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACrC,iDAAiD;IACjD,YAAY,GAAwB,4BAAY,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC9D,6CAA6C;IAC7C,UAAU,GAAsB,wBAAU,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IACxD,yDAAyD;IACzD,gBAAgB,GAA4B,qCAAgB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAC1E,2DAA2D;IAC3D,iBAAiB,GAChB,wCAAiB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;IAChC,yDAAyD;IACzD,gBAAgB,GAA4B,qCAAgB,CAAC,IAAI,CAAE,IAAI,CAAE,CAAC;CAC1E;AAjDD,wBAiDC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertBlock = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Insert a block.
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
* @param blockRepresentation Inserted block representation.
|
|
9
|
+
*/
|
|
10
|
+
async function insertBlock(blockRepresentation) {
|
|
11
|
+
await this.page.evaluate((_blockRepresentation) => {
|
|
12
|
+
function recursiveCreateBlock({ name, attributes = {}, innerBlocks = [], }) {
|
|
13
|
+
return window.wp.blocks.createBlock(name, attributes, innerBlocks.map((innerBlock) => recursiveCreateBlock(innerBlock)));
|
|
14
|
+
}
|
|
15
|
+
const block = recursiveCreateBlock(_blockRepresentation);
|
|
16
|
+
window.wp.data.dispatch('core/block-editor').insertBlock(block);
|
|
17
|
+
}, blockRepresentation);
|
|
18
|
+
}
|
|
19
|
+
exports.insertBlock = insertBlock;
|
|
20
|
+
//# sourceMappingURL=insert-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-block.js","sourceRoot":"","sources":["../../src/editor/insert-block.ts"],"names":[],"mappings":";;;AAWA;;;;;GAKG;AACH,KAAK,UAAU,WAAW,CAEzB,mBAAwC;IAExC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAE,oBAAoB,EAAG,EAAE;QACpD,SAAS,oBAAoB,CAAE,EAC9B,IAAI,EACJ,UAAU,GAAG,EAAE,EACf,WAAW,GAAG,EAAE,GACK;YACrB,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAClC,IAAI,EACJ,UAAU,EACV,WAAW,CAAC,GAAG,CAAE,CAAE,UAAU,EAAG,EAAE,CACjC,oBAAoB,CAAE,UAAU,CAAE,CAClC,CACD,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,oBAAoB,CAAE,oBAAoB,CAAE,CAAC;QAE3D,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAE,mBAAmB,CAAE,CAAC,WAAW,CAAE,KAAK,CAAE,CAAC;IACrE,CAAC,EAAE,mBAAmB,CAAE,CAAC;AAC1B,CAAC;AAGQ,kCAAW"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openDocumentSettingsSidebar = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Clicks on the button in the header which opens Document Settings sidebar when
|
|
6
|
+
* it is closed.
|
|
7
|
+
*
|
|
8
|
+
* @param this
|
|
9
|
+
*/
|
|
10
|
+
async function openDocumentSettingsSidebar() {
|
|
11
|
+
const toggleButton = this.page
|
|
12
|
+
.getByRole('region', { name: 'Editor top bar' })
|
|
13
|
+
.getByRole('button', {
|
|
14
|
+
name: 'Settings',
|
|
15
|
+
disabled: false,
|
|
16
|
+
});
|
|
17
|
+
const isClosed = (await toggleButton.getAttribute('aria-expanded')) === 'false';
|
|
18
|
+
if (isClosed) {
|
|
19
|
+
await toggleButton.click();
|
|
20
|
+
await this.page
|
|
21
|
+
.getByRole('region', { name: 'Editor settings' })
|
|
22
|
+
.getByRole('button', { name: 'Close Settings' })
|
|
23
|
+
.waitFor();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.openDocumentSettingsSidebar = openDocumentSettingsSidebar;
|
|
27
|
+
//# sourceMappingURL=open-document-settings-sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-document-settings-sidebar.js","sourceRoot":"","sources":["../../src/editor/open-document-settings-sidebar.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,2BAA2B;IAChD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI;SAC5B,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,QAAQ,EAAE;QACrB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,KAAK;KACf,CAAE,CAAC;IAEL,MAAM,QAAQ,GACb,CAAE,MAAM,YAAY,CAAC,YAAY,CAAE,eAAe,CAAE,CAAE,KAAK,OAAO,CAAC;IAEpE,IAAK,QAAQ,EAAG;QACf,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,IAAI;aACb,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAE;aAClD,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;aACjD,OAAO,EAAE,CAAC;KACZ;AACF,CAAC;AAlBD,kEAkBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openPreviewPage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Opens the preview page of an edited post.
|
|
6
|
+
*
|
|
7
|
+
* @param this
|
|
8
|
+
*
|
|
9
|
+
* @return preview page.
|
|
10
|
+
*/
|
|
11
|
+
async function openPreviewPage() {
|
|
12
|
+
const editorTopBar = this.page.locator('role=region[name="Editor top bar"i]');
|
|
13
|
+
const previewButton = editorTopBar.locator('role=button[name="Preview"i]');
|
|
14
|
+
await previewButton.click();
|
|
15
|
+
const [previewPage] = await Promise.all([
|
|
16
|
+
this.context.waitForEvent('page'),
|
|
17
|
+
this.page.click('role=menuitem[name="Preview in new tab"i]'),
|
|
18
|
+
]);
|
|
19
|
+
return previewPage;
|
|
20
|
+
}
|
|
21
|
+
exports.openPreviewPage = openPreviewPage;
|
|
22
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/editor/preview.ts"],"names":[],"mappings":";;;AAUA;;;;;;GAMG;AACI,KAAK,UAAU,eAAe;IACpC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CACrC,qCAAqC,CACrC,CAAC;IACF,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CACzC,8BAA8B,CAC9B,CAAC;IAEF,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;IAE5B,MAAM,CAAE,WAAW,CAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAE;QAC1C,IAAI,CAAC,OAAO,CAAC,YAAY,CAAE,MAAM,CAAE;QACnC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,2CAA2C,CAAE;KAC9D,CAAE,CAAC;IAEJ,OAAO,WAAW,CAAC;AACpB,CAAC;AAhBD,0CAgBC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishPost = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Publishes the post, resolving once the request is complete (once a notice
|
|
6
|
+
* is displayed).
|
|
7
|
+
*
|
|
8
|
+
* @param this
|
|
9
|
+
*/
|
|
10
|
+
async function publishPost() {
|
|
11
|
+
await this.page.click('role=button[name="Publish"i]');
|
|
12
|
+
const entitiesSaveButton = this.page.locator('role=region[name="Editor publish"i] >> role=button[name="Save"i]');
|
|
13
|
+
const isEntitiesSavePanelVisible = await entitiesSaveButton.isVisible();
|
|
14
|
+
// Save any entities.
|
|
15
|
+
if (isEntitiesSavePanelVisible) {
|
|
16
|
+
// Handle saving entities.
|
|
17
|
+
await entitiesSaveButton.click();
|
|
18
|
+
}
|
|
19
|
+
// Handle saving just the post.
|
|
20
|
+
await this.page.click('role=region[name="Editor publish"i] >> role=button[name="Publish"i]');
|
|
21
|
+
const urlString = await this.page
|
|
22
|
+
.getByRole('region', { name: 'Editor publish' })
|
|
23
|
+
.getByRole('textbox', { name: 'address' })
|
|
24
|
+
.inputValue();
|
|
25
|
+
const url = new URL(urlString);
|
|
26
|
+
const postId = url.searchParams.get('p');
|
|
27
|
+
return typeof postId === 'string' ? parseInt(postId, 10) : null;
|
|
28
|
+
}
|
|
29
|
+
exports.publishPost = publishPost;
|
|
30
|
+
//# sourceMappingURL=publish-post.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-post.js","sourceRoot":"","sources":["../../src/editor/publish-post.ts"],"names":[],"mappings":";;;AAKA;;;;;GAKG;AACI,KAAK,UAAU,WAAW;IAChC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAE,8BAA8B,CAAE,CAAC;IACxD,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAC3C,kEAAkE,CAClE,CAAC;IAEF,MAAM,0BAA0B,GAAG,MAAM,kBAAkB,CAAC,SAAS,EAAE,CAAC;IAExE,qBAAqB;IACrB,IAAK,0BAA0B,EAAG;QACjC,0BAA0B;QAC1B,MAAM,kBAAkB,CAAC,KAAK,EAAE,CAAC;KACjC;IAED,+BAA+B;IAC/B,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CACpB,qEAAqE,CACrE,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI;SAC/B,SAAS,CAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAE;SACjD,SAAS,CAAE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAE;SAC3C,UAAU,EAAE,CAAC;IACf,MAAM,GAAG,GAAG,IAAI,GAAG,CAAE,SAAS,CAAE,CAAC;IACjC,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAE,GAAG,CAAE,CAAC;IAE3C,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAE,MAAM,EAAE,EAAE,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AA3BD,kCA2BC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectBlocks = void 0;
|
|
4
|
+
async function selectBlocks(startSelectorOrLocator, endSelectorOrLocator) {
|
|
5
|
+
const startBlock = typeof startSelectorOrLocator === 'string'
|
|
6
|
+
? this.canvas.locator(startSelectorOrLocator)
|
|
7
|
+
: startSelectorOrLocator;
|
|
8
|
+
const endBlock = typeof endSelectorOrLocator === 'string'
|
|
9
|
+
? this.canvas.locator(endSelectorOrLocator)
|
|
10
|
+
: endSelectorOrLocator;
|
|
11
|
+
const startClientId = await startBlock.getAttribute('data-block');
|
|
12
|
+
const endClientId = await endBlock?.getAttribute('data-block');
|
|
13
|
+
if (endClientId) {
|
|
14
|
+
await this.page.evaluate(([startId, endId]) => {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
wp.data
|
|
17
|
+
.dispatch('core/block-editor')
|
|
18
|
+
.multiSelect(startId, endId);
|
|
19
|
+
}, [startClientId, endClientId]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
await this.page.evaluate(([clientId]) => {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
wp.data.dispatch('core/block-editor').selectBlock(clientId);
|
|
25
|
+
}, [startClientId]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.selectBlocks = selectBlocks;
|
|
29
|
+
//# sourceMappingURL=select-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-blocks.js","sourceRoot":"","sources":["../../src/editor/select-blocks.ts"],"names":[],"mappings":";;;AAUO,KAAK,UAAU,YAAY,CAEjC,sBAAwC,EACxC,oBAAuC;IAEvC,MAAM,UAAU,GACf,OAAO,sBAAsB,KAAK,QAAQ;QACzC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,sBAAsB,CAAE;QAC/C,CAAC,CAAC,sBAAsB,CAAC;IAE3B,MAAM,QAAQ,GACb,OAAO,oBAAoB,KAAK,QAAQ;QACvC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAE,oBAAoB,CAAE;QAC7C,CAAC,CAAC,oBAAoB,CAAC;IAEzB,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,YAAY,CAAE,YAAY,CAAE,CAAC;IACpE,MAAM,WAAW,GAAG,MAAM,QAAQ,EAAE,YAAY,CAAE,YAAY,CAAE,CAAC;IAEjE,IAAK,WAAW,EAAG;QAClB,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,OAAO,EAAE,KAAK,CAAE,EAAG,EAAE;YACxB,aAAa;YACb,EAAE,CAAC,IAAI;iBACL,QAAQ,CAAE,mBAAmB,CAAE;iBAC/B,WAAW,CAAE,OAAO,EAAE,KAAK,CAAE,CAAC;QACjC,CAAC,EACD,CAAE,aAAa,EAAE,WAAW,CAAE,CAC9B,CAAC;KACF;SAAM;QACN,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CACvB,CAAE,CAAE,QAAQ,CAAE,EAAG,EAAE;YAClB,aAAa;YACb,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAE,mBAAmB,CAAE,CAAC,WAAW,CAAE,QAAQ,CAAE,CAAC;QACjE,CAAC,EACD,CAAE,aAAa,CAAE,CACjB,CAAC;KACF;AACF,CAAC;AArCD,oCAqCC"}
|