21461: Fixes failing banner tests.
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 23 Feb 2024 02:05:57 +0000 (23:05 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 23 Feb 2024 02:05:57 +0000 (23:05 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

services/workbench2/cypress/e2e/banner-tooltip.cy.js

index 41ca0dec4051dfbba1b857319ce9c2a1ddb9835a..3fbaba9e381413230d3fbe2a8063108674780192 100644 (file)
@@ -15,64 +15,24 @@ describe('Banner / tooltip tests', function () {
         cy.getUser('admin', 'Admin', 'User', true, true)
             .as('adminUser').then(function () {
                 adminUser = this.adminUser;
-            }
-            );
+            });
         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
             .as('activeUser').then(function () {
                 activeUser = this.activeUser;
             });
-            cy.on('uncaught:exception', (err, runnable) => {console.error(err)});
     });
 
     beforeEach(function () {
         cy.clearCookies();
         cy.clearLocalStorage();
-    });
-
-    it('should re-show the banner', () => {
-        setupTheEnvironment();
-
-        cy.loginAs(adminUser);
-
-        cy.wait(2000);
-
-        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
 
-        cy.get('[title=Notifications]').click();
-        cy.get('li').contains('Restore Banner').click();
-
-        cy.wait(2000);
-
-        cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
-    });
-
-
-    it('should show tooltips and remove tooltips as localStorage key is present', () => {
-        setupTheEnvironment();
-
-        cy.loginAs(adminUser);
-
-        cy.wait(2000);
-
-        cy.get('[data-cy=side-panel-tree]').then(($el) => {
-            const el = $el.get(0) //native DOM element
-            expect(el._tippy).to.exist;
-        });
-
-        cy.wait(2000);
-
-        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
-
-        cy.get('[title=Notifications]').click();
-        cy.get('li').contains('Disable tooltips').click();
-
-        cy.get('[data-cy=side-panel-tree]').then(($el) => {
-            const el = $el.get(0) //native DOM element
-            expect(el._tippy).to.be.undefined;
+        cy.on('uncaught:exception', (err, runnable, promise) => {
+            Cypress.log({ message: `Application Error: ${err}`});
+            if (promise) {
+                return false;
+            }
         });
-    });
 
-    const setupTheEnvironment = () => {
         cy.createCollection(adminUser.token, {
             name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
             owner_uuid: adminUser.user.uuid,
@@ -90,18 +50,17 @@ describe('Banner / tooltip tests', function () {
             cy.fixture('files/banner.html').as('banner');
             cy.fixture('files/tooltips.txt').as('tooltips');
 
-            cy.getAll('@banner', '@tooltips')
-                .then(([banner, tooltips]) => {
-                    cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
-                    cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
-                });
+            cy.getAll('@banner', '@tooltips').then(([banner, tooltips]) => {
+                cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
+                cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
+            });
 
             cy.get('[data-cy=form-submit-btn]').click();
             cy.get('[data-cy=form-submit-btn]').should('not.exist');
             cy.get('[data-cy=collection-files-right-panel]')
-                .contains('banner.html').should('exist');
+                .should('contain', 'banner.html');
             cy.get('[data-cy=collection-files-right-panel]')
-                .contains('tooltips.json').should('exist');
+                .should('contain', 'tooltips.json');
 
             cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
                 req.reply((res) => {
@@ -109,5 +68,36 @@ describe('Banner / tooltip tests', function () {
                 });
             });
         });
-    }
-});
+    });
+
+    it('should re-show the banner', () => {
+        cy.loginAs(adminUser);
+
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+
+        cy.get('[title=Notifications]').click();
+        cy.get('li').contains('Restore Banner').click();
+
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
+    });
+
+
+    it('should show tooltips and remove tooltips as localStorage key is present', () => {
+        cy.loginAs(adminUser);
+
+        cy.get('[data-cy=side-panel-tree]').then(($el) => {
+            const el = $el.get(0) //native DOM element
+            expect(el._tippy).to.exist;
+        });
+
+        cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+
+        cy.get('[title=Notifications]').click();
+        cy.get('li').contains('Disable tooltips').click();
+
+        cy.get('[data-cy=side-panel-tree]').then(($el) => {
+            const el = $el.get(0) //native DOM element
+            expect(el._tippy).to.be.undefined;
+        });
+    });
+});
\ No newline at end of file