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

Revert "Normalize Cypress test"

This reverts commit 104511ee16466e988e63e508472ceb7ae4cf0d12.
And update cypress test
Mudana-Grune 2 лет назад
Родитель
Сommit
f0eaed8bea

+ 22 - 20
apps/app/test/cypress/integration/20-basic-features/20-basic-features--access-to-page.spec.ts

@@ -263,16 +263,16 @@ context('Access to Template Editing Mode', () => {
     cy.visit('/Sandbox');
     cy.waitUntilSkeletonDisappear();
 
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
-
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-template-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      // do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      // wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
     cy.getByTestid('page-template-modal').should('be.visible');
     cy.screenshot(`${ssPrefix}-open-page-template-modal`);
 
@@ -299,16 +299,16 @@ context('Access to Template Editing Mode', () => {
     cy.visit('/Sandbox');
     cy.waitUntilSkeletonDisappear();
 
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
-
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-template-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      // do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      // Wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
     cy.getByTestid('page-template-modal').should('be.visible');
 
     cy.getByTestid('template-button-decendants').click(({force: true}))
@@ -333,16 +333,18 @@ context('Access to Template Editing Mode', () => {
   it('Template is applied to pages created from PageTree (template for descendants)', () => {
     // delete /Sandbox/_template
     cy.visit('/Sandbox/_template');
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
 
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-delete-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      //do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      // wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-delete-modal-btn').filter(':visible').click({force: true});
+
     cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
       cy.intercept('POST', '/_api/pages.remove').as('remove');
       cy.getByTestid('delete-page-button').click();

+ 23 - 21
apps/app/test/cypress/integration/20-basic-features/20-basic-features--use-tools.spec.ts

@@ -136,16 +136,17 @@ context('Modal for page operation', () => {
   it('Page Deletion and PutBack is executed successfully', { scrollBehavior: false }, () => {
     cy.visit('/Sandbox/Bootstrap4');
 
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
-
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-delete-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      // do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      //wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-delete-modal-btn').filter(':visible').click({force: true});
+
     cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
       cy.screenshot(`${ssPrefix}-delete-modal`);
       cy.getByTestid('delete-page-button').click();
@@ -168,16 +169,17 @@ context('Modal for page operation', () => {
     cy.visit('/Sandbox/Bootstrap4');
     cy.waitUntilSkeletonDisappear();
 
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
-
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-duplicate-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      // do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      // wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-duplicate-modal-btn').filter(':visible').click({force: true});
+
     cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
   });
 
@@ -185,16 +187,16 @@ context('Modal for page operation', () => {
     cy.visit('/Sandbox/Bootstrap4');
     cy.waitUntilSkeletonDisappear();
 
-    cy.get('#grw-subnav-container').within(() => {
-      cy.getByTestid('open-page-item-control-btn').click({force: true});
-    });
-
-    cy.get('body').within(() => {
-      cy.getByTestid('page-item-control-menu').filter('.show').within(() => {
-        cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
+    cy.waitUntil(() => {
+      // do
+      cy.get('#grw-subnav-container').within(() => {
+        cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
       });
+      // wait until
+      return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
     });
 
+    cy.getByTestid('open-page-move-rename-modal-btn').filter(':visible').click({force: true});
     cy.getByTestid('grw-page-rename-button').should('be.disabled');
 
     cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);