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

Add sticky test for small window

https://youtrack.weseek.co.jp/issue/GW-7949
- Unify scroll top and down to single test
- Add initial scroll down for sticky when move to other page test
- Update waitUntil condition of grw-subnav-switcher class
- Add sticky test for small window
Mudana-Grune 3 лет назад
Родитель
Сommit
fc0b8cbcaf

+ 27 - 6
packages/app/test/cypress/integration/23-sticky/23-sticky--subnavigation-switcher.spec.ts

@@ -14,7 +14,8 @@ context('Access to sticky sub navigation switcher ', () => {
     cy.collapseSidebar(true);
   });
 
-  it('Sub navigation is sticky when scrolling down', () => {
+  it('Sub navigation sticky changes when scrolling down and up', () => {
+    // Sticky
     cy.waitUntil(() => {
       // do
       // Scroll the window 250px down is enough to trigger sticky effect
@@ -24,10 +25,8 @@ context('Access to sticky sub navigation switcher ', () => {
       return cy.getByTestid('grw-subnav-switcher').then($elem => !$elem.hasClass('grw-subnav-switcher-hidden'));
     });
     cy.screenshot(`${ssPrefix}is-sticky-on-scroll-down`);
-  });
-
-  it('Sub navigation is not sticky when scrolling top', () => {
 
+    // Not sticky
     cy.waitUntil(() => {
       // do
       // Scroll page to top
@@ -40,13 +39,22 @@ context('Access to sticky sub navigation switcher ', () => {
   });
 
   it('Sub navigation is not sticky when move to other pages', () => {
+    // Make the sub navigation sticky
+    cy.waitUntil(() => {
+      // do
+      // Scroll the window 250px down is enough to trigger sticky effect
+      cy.scrollTo(0, 250);
+
+      // wait until
+      return cy.getByTestid('grw-subnav-switcher').then($elem => !$elem.hasClass('grw-subnav-switcher-hidden'));
+    });
+
     // Move to /Sandbox page
     cy.visit('/Sandbox');
 
     cy.waitUntilSkeletonDisappear();
     cy.collapseSidebar(true);
 
-
     cy.getByTestid('grw-subnav-switcher').should('have.class', 'grw-subnav-switcher-hidden');
     cy.screenshot(`${ssPrefix}is-not-sticky-on-move-to-other-pages`);
   });
@@ -58,7 +66,7 @@ context('Access to sticky sub navigation switcher ', () => {
       cy.scrollTo(0, 250);
 
       // wait until
-      return cy.getByTestid('grw-subnav-switcher').then($elem => $elem.hasClass('grw-subnav-switcher-hidden'));
+      return cy.getByTestid('grw-subnav-switcher').then($elem => !$elem.hasClass('grw-subnav-switcher-hidden'));
     });
 
     cy.getByTestid('grw-subnav-switcher').within(() => {
@@ -71,4 +79,17 @@ context('Access to sticky sub navigation switcher ', () => {
     });
     cy.screenshot(`${ssPrefix}open-editor-when-sticky`);
   });
+
+  it('Sub navigation is sticky when on small window', () => {
+    cy.waitUntil(() => {
+      // do
+      // Scroll the window 250px down is enough to trigger sticky effect
+      cy.scrollTo(0, 250);
+
+      // wait until
+      return cy.getByTestid('grw-subnav-switcher').then($elem => !$elem.hasClass('grw-subnav-switcher-hidden'));
+    });
+    cy.viewport('iphone-5');
+    cy.screenshot(`${ssPrefix}is-sticky-on-small-window`);
+  });
 });