Просмотр исходного кода

Merge pull request #7115 from weseek/fix/cypress-error-10-30-50

fix: Cypress error 10 30 50
Shun Miyazawa 3 лет назад
Родитель
Сommit
3120e8ec21

+ 11 - 8
packages/app/test/cypress/integration/10-install/10-install--install.spec.ts

@@ -3,22 +3,24 @@ describe('Install', () => {
 
   beforeEach(() => {
     cy.visit('/');
+    cy.getByTestid('installerForm').should('be.visible');
   });
 
   it('Successfully show installer', () => {
-    cy.getByTestid('installerForm').should('be.visible');
     cy.screenshot(`${ssPrefix}-redirect-to-installer-page`);
   });
 
   it('Sccessfully choose languages', () => {
-    cy.getByTestid('installerForm').should('be.visible');
     cy.getByTestid('dropdownLanguage').should('be.visible');
-    // TODO: should not use wait.
-    // eslint-disable-next-line cypress/no-unnecessary-waiting
-    cy.wait(1000); // waiting for load
 
-    cy.getByTestid('dropdownLanguage').click();
-    cy.get('.dropdown-menu').should('be.visible');
+    // open Language Dropdown, wait for language data to load
+    cy.waitUntil(() => {
+      // do
+      cy.getByTestid('dropdownLanguage').click();
+      // wati until
+      return cy.get('.dropdown-menu').then($elem => $elem.is(':visible'));
+    });
+
     cy.getByTestid('dropdownLanguageMenu-en_US').click();
     cy.get('.alert-success').should('be.visible');
     cy.screenshot(`${ssPrefix}-select-en_US`);
@@ -48,8 +50,9 @@ describe('Install', () => {
     cy.getByTestid('btnSubmit').click();
 
     // Redirects to the root page take a long time (more than 10000ms)
+    cy.getByTestid('grw-pagetree-item-container', { timeout: 20000 }).should('be.visible');
+
     cy.waitUntilSkeletonDisappear();
-    cy.getByTestid('grw-pagetree-item-container').should('be.visible');
     cy.screenshot(`${ssPrefix}-installed-redirect-to-root-page`, {
       blackout: ['[data-hide-in-vrt=true]']
     });

+ 2 - 1
packages/app/test/cypress/integration/30-search/30-search--search.spec.ts

@@ -116,6 +116,7 @@ context('Search all pages', () => {
     cy.wait(1500);
     cy.screenshot(`${ssPrefix}3-search-page-results`, { capture: 'viewport'});
 
+    // TODO: chlick three dots bottom, collapse sidebar doesn't working.
     cy.getByTestid('open-page-item-control-btn').eq(1).click();
     cy.getByTestid('search-result-content').should('be.visible');
     cy.get('.wiki').should('be.visible');
@@ -123,7 +124,7 @@ context('Search all pages', () => {
     cy.get('.search-result-content-body-container').scrollTo('top');
     cy.screenshot(`${ssPrefix}4-click-three-dots-menu`, {capture: 'viewport'});
 
-    //Add bookmark
+    // Add bookmark
     cy.getByTestid('add-remove-bookmark-btn').click({force: true});
     cy.get('.btn-bookmark.active').should('be.visible');
     cy.screenshot(`${ssPrefix}5-add-bookmark`, {capture: 'viewport'});

+ 37 - 18
packages/app/test/cypress/integration/50-sidebar/50-sidebar--access-to-side-bar.spec.ts

@@ -13,12 +13,14 @@ describe('Access to sidebar', () => {
       beforeEach(() => {
         cy.visit('/');
         cy.waitUntilSkeletonDisappear();
+        // Since this is a sidebar test, call collapseSidebar in beforeEach.
         cy.collapseSidebar(false);
       });
 
       describe('Test show/collapse button', () => {
         it('Successfully show sidebar', () => {
           cy.getByTestid('grw-pagetree-item-container').should('be.visible');
+
           cy.screenshot(`${ssPrefix}1-sidebar-shown`, {
             capture: 'viewport',
             // Blackout for recalculation of toc content hight
@@ -28,6 +30,7 @@ describe('Access to sidebar', () => {
 
         it('Successfully collapse sidebar', () => {
           cy.getByTestid('grw-navigation-resize-button').click({force: true});
+
           cy.screenshot(`${ssPrefix}2-sidebar-collapsed`, {
             capture: 'viewport',
             // Blackout for recalculation of toc content hight
@@ -40,6 +43,7 @@ describe('Access to sidebar', () => {
         it('Successfully access to page tree', () => {
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
             cy.getByTestid('grw-pagetree-item-container').should('be.visible');
+
             cy.screenshot(`${ssPrefix}page-tree-1-access-to-page-tree`);
           });
         });
@@ -49,34 +53,37 @@ describe('Access to sidebar', () => {
             cy.get('.grw-pagetree-open').should('be.visible');
 
             // hide page tree tiems
-            cy.get('.grw-pagetree-triangle-btn').eq(0).click();
+            cy.get('.grw-pagetree-triangle-btn').first().click();
+
             cy.screenshot(`${ssPrefix}page-tree-2-hide-page-tree-items`);
           });
         });
 
         it('Successfully click Add to Bookmarks button', () => {
           // click three dots
-          cy.get('.grw-pagetree-item-children').eq(0).within(() => {
-            cy.getByTestid('open-page-item-control-btn').find('button').eq(0).invoke('css','display','block').click();
+          cy.get('.grw-pagetree-item-children').first().within(() => {
+            cy.getByTestid('open-page-item-control-btn').find('button').first().invoke('css','display','block').click();
           });
 
           cy.getByTestid('page-item-control-menu').should('have.class', 'show');
+
           cy.screenshot(`${ssPrefix}page-tree-3-before-click-button`, {
             // Blackout for recalculation of toc content hight
             blackout: ['.grw-side-contents-container', '[data-hide-in-vrt=true]'],
           });
 
           // click add remove bookmark btn
-          cy.getByTestid('page-item-control-menu').should('have.class', 'show').within(() => {
-            cy.getByTestid('add-remove-bookmark-btn').click();
-          });
+          cy.getByTestid('page-item-control-menu').should('have.class', 'show')
+          cy.getByTestid('add-remove-bookmark-btn').click();
+
 
           // show dropdown again
-          cy.get('.grw-pagetree-item-children').eq(0).within(() => {
-            cy.getByTestid('open-page-item-control-btn').find('button').eq(0).invoke('css','display','block').click();
+          cy.get('.grw-pagetree-item-children').first().within(() => {
+            cy.getByTestid('open-page-item-control-btn').find('button').first().invoke('css','display','block').click();
           });
 
           cy.getByTestid('page-item-control-menu').should('have.class', 'show');
+
           cy.screenshot(`${ssPrefix}page-tree-4-after-click-button`, {
             // Blackout for recalculation of toc content hight
             blackout: ['.grw-side-contents-container', '[data-hide-in-vrt=true]'],
@@ -84,45 +91,50 @@ describe('Access to sidebar', () => {
         });
 
         it('Successfully show duplicate page modal', () => {
-          cy.get('.grw-pagetree-item-children').eq(0).within(() => {
-            cy.getByTestid('open-page-item-control-btn').find('button').eq(0).invoke('css','display','block').click();
+          cy.get('.grw-pagetree-item-children').first().within(() => {
+            cy.getByTestid('open-page-item-control-btn').find('button').first().invoke('css','display','block').click();
           });
           cy.get('.dropdown-menu.show').should('be.visible').within(() => {
             cy.getByTestid('open-page-duplicate-modal-btn').click();
           });
           cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
             cy.get('.rbt-input-main').type('_test');
+
             cy.screenshot(`${ssPrefix}page-tree-5-duplicate-page-modal`);
+
             cy.get('.modal-header > button').click();
           });
         });
 
         it('Successfully rename page', () => {
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
-            cy.get('.grw-pagetree-item-children').eq(0).within(() => {
-              cy.getByTestid('open-page-item-control-btn').find('button').eq(0).invoke('css','display','block').click()
+            cy.get('.grw-pagetree-item-children').first().within(() => {
+              cy.getByTestid('open-page-item-control-btn').find('button').first().invoke('css','display','block').click()
             });
             cy.get('.dropdown-menu.show').should('be.visible').within(() => {
               cy.getByTestid('open-page-move-rename-modal-btn').click();
             });
-            cy.get('.grw-pagetree-item-children').eq(0).within(() => {
+            cy.get('.grw-pagetree-item-children').first().within(() => {
               cy.getByTestid('closable-text-input').type('_newname');
             });
+
             cy.screenshot(`${ssPrefix}page-tree-6-rename-page`);
           });
         });
 
         it('Successfully show delete page modal', () => {
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
-            cy.get('.grw-pagetree-item-children').eq(0).within(() => {
-              cy.getByTestid('open-page-item-control-btn').find('button').eq(0).invoke('css','display','block').click()
+            cy.get('.grw-pagetree-item-children').first().within(() => {
+              cy.getByTestid('open-page-item-control-btn').find('button').first().invoke('css','display','block').click()
             });
             cy.get('.dropdown-menu.show').should('be.visible').within(() => {
               cy.getByTestid('open-page-delete-modal-btn').click();
             });
           });
           cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
+
             cy.screenshot(`${ssPrefix}page-tree-7-delete-page-modal`);
+
             cy.get('.modal-header > button').click();
           });
         });
@@ -137,6 +149,7 @@ describe('Access to sidebar', () => {
 
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
             cy.get('.grw-sidebar-content-header.h5').find('a');
+
             cy.screenshot(`${ssPrefix}custom-sidebar-1-access-to-custom-sidebar`);
           });
         });
@@ -146,7 +159,9 @@ describe('Access to sidebar', () => {
 
           cy.get('.grw-sidebar-content-header.h5').find('a').click();
           cy.get('.CodeMirror textarea').type(content, {force: true});
+
           cy.screenshot(`${ssPrefix}custom-sidebar-2-redirect-to-editor`);
+
           cy.getByTestid('save-page-btn').click();
           cy.get('.layout-root').should('not.have.class', 'editing');
         });
@@ -154,6 +169,7 @@ describe('Access to sidebar', () => {
         it('Successfully create custom sidebar content', () => {
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
             cy.get('.grw-custom-sidebar-content').should('be.visible');
+
             cy.screenshot(`${ssPrefix}custom-sidebar-3-content-created`);
           });
         });
@@ -169,7 +185,7 @@ describe('Access to sidebar', () => {
           cy.getByTestid('grw-recent-changes').should('be.visible');
           cy.get('.list-group-item').should('be.visible');
 
-          // The scope of the capture is not narrowed because the blackout is shifted
+          // The scope of the screenshot is not narrowed because the blackout is shifted
           cy.screenshot(`${ssPrefix}recent-changes-1-access-to-recent-changes`, {
             // Blackout for recalculation of toc content hight
             blackout: ['.grw-side-contents-container', '[data-hide-in-vrt=true]'],
@@ -182,7 +198,7 @@ describe('Access to sidebar', () => {
             cy.get('.list-group-item').should('be.visible');
           });
 
-          // The scope of the capture is not narrowed because the blackout is shifted
+          // The scope of the screenshot is not narrowed because the blackout is shifted
           cy.screenshot(`${ssPrefix}recent-changes-2-switch-content-size`, {
             // Blackout for recalculation of toc content hight
             blackout: ['.grw-side-contents-container', '[data-hide-in-vrt=true]'],
@@ -199,6 +215,7 @@ describe('Access to sidebar', () => {
 
           cy.getByTestid('grw-contextual-navigation-sub').within(() => {
             cy.getByTestid('grw-tags-list').should('be.visible');
+
             cy.screenshot(`${ssPrefix}tags-1-access-to-tags`);
           });
         });
@@ -207,11 +224,12 @@ describe('Access to sidebar', () => {
           cy.get('.grw-container-convertible > div > .btn-primary').click({force: true});
           cy.collapseSidebar(true);
           cy.getByTestid('grw-tags-list').should('be.visible');
+
           cy.screenshot(`${ssPrefix}tags-2-click-all-tags-button`);
         });
       });
 
-      // TODO: No Drafts pages on GROWI version 6
+      // // TODO: No Drafts pages on GROWI version 6
       // it('Successfully access to My Drafts page', () => {
       //   cy.visit('/');
       //   cy.collapseSidebar(true);
@@ -241,6 +259,7 @@ describe('Access to sidebar', () => {
 
           cy.get('.grw-page-path-hierarchical-link').should('be.visible');
           cy.get('.grw-custom-nav-tab').should('be.visible');
+
           cy.screenshot(`${ssPrefix}access-to-trash-page`);
         });
       });

+ 1 - 0
packages/app/test/cypress/integration/50-sidebar/50-sidebar--switching-sidebar-mode.spec.ts

@@ -21,6 +21,7 @@ context('Switch sidebar mode', () => {
 
   it('Switching sidebar mode', () => {
     cy.visit('/');
+    // This test uses collapseSidebar here, because this test for the sidebar.
     cy.collapseSidebar(true, true)
     cy.get('.grw-apperance-mode-dropdown').first().click();