File tree 2 files changed +59
-0
lines changed
ghost/core/test/e2e-browser
2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ const test = require ( '../fixtures/ghost-test' ) ;
2
+ const EditorPage = require ( '../utils/pages/EditorPage' ) ;
3
+
4
+ test . describe ( 'Editor' , ( ) => {
5
+ test ( 'should save post when title is blank and only the content is changed' , async ( { page} ) => {
6
+ const editorPage = new EditorPage ( page ) ;
7
+ await editorPage . goto ( ) ;
8
+ await editorPage . typeInBody ( 'Hello world' ) ;
9
+ await editorPage . checkPostStatus ( 'Draft' ) ;
10
+ } ) ;
11
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const { expect} = require ( '@playwright/test' ) ;
2
+
3
+ /**
4
+ * Page object model for the editor page
5
+ * https://playwright.dev/docs/pom
6
+ * @typedef {Object } EditorPageOptions
7
+ * @property {string } [type] The type of editor to open. Can be 'post' or 'page'.
8
+ */
9
+ class EditorPage {
10
+ constructor ( page ) {
11
+ this . page = page ;
12
+ }
13
+
14
+ async goto ( type = 'post' ) {
15
+ await this . page . goto ( '/ghost' ) ;
16
+ if ( type === 'post' ) {
17
+ await this . page . goto ( '/ghost/#/editor/post/' ) ;
18
+ } else if ( type === 'page' ) {
19
+ await this . page . goto ( '/ghost/#/editor/page/' ) ;
20
+ } else {
21
+ throw new Error ( `Invalid type: ${ type } ` ) ;
22
+ }
23
+
24
+ // wait for editor to be ready
25
+ await expect ( this . page . locator ( '[data-lexical-editor="true"]' ) . first ( ) ) . toBeVisible ( ) ;
26
+ }
27
+
28
+ async focusBody ( ) {
29
+ await this . page . locator ( '[data-secondary-instance="false"] [data-lexical-editor]' ) . click ( ) ;
30
+ }
31
+
32
+ async typeInBody ( text ) {
33
+ await this . focusBody ( ) ;
34
+ await this . page . keyboard . type ( text ) ;
35
+ }
36
+
37
+ async checkPostStatus ( status , hoverStatus ) {
38
+ await this . page . waitForLoadState ( 'networkidle' ) ;
39
+ await expect ( this . page . locator ( '[data-test-editor-post-status]' ) . first ( ) ) . toContainText ( status , { timeout : 5000 } ) ;
40
+
41
+ if ( hoverStatus ) {
42
+ await this . page . locator ( '[data-test-editor-post-status]' ) . first ( ) . hover ( ) ;
43
+ await expect ( this . page . locator ( '[data-test-editor-post-status]' ) . first ( ) ) . toContainText ( hoverStatus , { timeout : 5000 } ) ;
44
+ }
45
+ }
46
+ }
47
+
48
+ module . exports = EditorPage ;
You can’t perform that action at this time.
0 commit comments