Yuken Tezuka 3 лет назад
Родитель
Сommit
ee43da51f0

+ 56 - 0
packages/app/test/cypress/integration/20-basic-features/20-basic-features--access-to-page.spec.ts

@@ -68,6 +68,62 @@ context('Access to page', () => {
     cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
   })
 
+  it('View and Edit contents are successfully loaded', () => {
+    const body1 = 'hello';
+    cy.visit('/Sandbox/testForUseEditingMarkdown');
+
+    cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
+    cy.waitUntil(() => {
+      // do
+      cy.get('@pageEditorModeManager').within(() => {
+        cy.get('button:nth-child(2)').click();
+      });
+      // until
+      return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
+    })
+
+    cy.get('.grw-editor-navbar-bottom').should('be.visible');
+
+    // check edited contents after save
+    cy.get('.CodeMirror').type(body1);
+    cy.get('.CodeMirror').contains(body1);
+    cy.get('.page-editor-preview-body').contains(body1);
+    cy.getByTestid('page-editor').should('be.visible');
+    cy.getByTestid('save-page-btn').click();
+    cy.get('.wiki').should('be.visible');
+    cy.get('.wiki').children().first().should('have.text', body1);
+  })
+
+  it('Editing contents are successfully loaded with shortcut key', () => {
+    const body2 = ' world!';
+    const savePageShortcutKey = '{ctrl+s}';
+
+    cy.visit('/Sandbox/testForUseEditingMarkdown');
+
+    cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
+    cy.waitUntil(() => {
+      // do
+      cy.get('@pageEditorModeManager').within(() => {
+        cy.get('button:nth-child(2)').click();
+      });
+      // until
+      return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
+    })
+
+    cy.get('.grw-editor-navbar-bottom').should('be.visible');
+
+    // check editing contents with shortcut key
+    cy.get('. CodeMirror-line ').children().first().should(($elm) => {
+      const text = $elm.text()
+      cy.get('.CodeMirror').type(body2);
+      cy.get('.CodeMirror').contains(text+body2);
+      cy.get('.page-editor-preview-body').contains(text+body2);
+      cy.get('.CodeMirror').type(savePageShortcutKey);
+      cy.get('.CodeMirror').contains(text+body2);
+      cy.get('.page-editor-preview-body').contains(text+body2);
+    })
+  })
+
   it('/user/admin is successfully loaded', () => {
     cy.visit('/user/admin');