21600: combined changes by Stephen and Lucas Arvados-DCO-1.1-Signed-off-by: Lisa... 21600-banner-tests
authorLisa Knox <lisaknox83@gmail.com>
Tue, 19 Mar 2024 14:52:22 +0000 (10:52 -0400)
committerLisa Knox <lisaknox83@gmail.com>
Tue, 19 Mar 2024 14:52:22 +0000 (10:52 -0400)
services/workbench2/cypress/e2e/banner-tooltip.cy.js
services/workbench2/cypress/support/commands.js

index 63d2c264d8cf0ce2a24b7682961a6f1df0cb2d21..f8100961aa26f670f5571298451a8a607eea1c29 100644 (file)
@@ -1,3 +1,4 @@
+
 // Copyright (C) The Arvados Authors. All rights reserved.
 //
 // SPDX-License-Identifier: AGPL-3.0
@@ -20,23 +21,18 @@ describe('Banner / tooltip tests', function () {
             .as('activeUser').then(function () {
                 activeUser = this.activeUser;
             });
-    });
 
-    beforeEach(function () {
-        cy.on('uncaught:exception', (err, runnable, promise) => {
-            Cypress.log({ message: `Application Error: ${err}`});
-            if (promise) {
-                return false;
-            }
+        cy.getAll('@adminUser').then(([adminUser]) => {
+            // This collection will not be deleted after each test, we'll
+            // clean it up manually.
+            cy.createCollection(adminUser.token, {
+                name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
+                owner_uuid: adminUser.user.uuid,
+            }, true).as('bannerCollection');
         });
 
-        cy.createCollection(adminUser.token, {
-            name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
-            owner_uuid: adminUser.user.uuid,
-        }).as('bannerCollection');
-
         cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
-            collectionUUID=bannerCollection.uuid;
+            collectionUUID = bannerCollection.uuid;
 
             cy.loginAs(adminUser);
 
@@ -58,15 +54,28 @@ describe('Banner / tooltip tests', function () {
                 .should('contain', 'banner.html');
             cy.get('[data-cy=collection-files-right-panel]')
                 .should('contain', 'tooltips.json');
+        });
+    });
 
-            cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
-                req.on('response', (res) => {
-                    res.body.Workbench.BannerUUID = collectionUUID;
-                });
+    beforeEach(function () {
+        cy.on('uncaught:exception', (err, runnable, promise) => {
+            Cypress.log({ message: `Application Error: ${err}`});
+            if (promise) {
+                return false;
+            }
+        });
+        cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
+            req.on('response', (res) => {
+                res.body.Workbench.BannerUUID = collectionUUID;
             });
         });
     });
 
+    after(function () {
+        // Delete banner collection after all test used it.
+        cy.deleteResource(adminUser.token, "collections", collectionUUID);
+    });
+
     it('should re-show the banner', () => {
         cy.loginAs(adminUser);
         cy.waitForDom();
@@ -84,24 +93,20 @@ describe('Banner / tooltip tests', function () {
 
     it('should show tooltips and remove tooltips as localStorage key is present', () => {
         cy.loginAs(adminUser);
-        cy.waitForDom();
-
-        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.waitForDom();
-        cy.get('[data-cy=confirmation-dialog]').should('not.exist');
+
+        cy.contains('This allows you to navigate through the app').should('not.exist'); // This content comes from tooltips.txt
+        cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
+        cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
+        cy.contains('This allows you to navigate through the app').should('be.visible');
 
         cy.get('[title=Notifications]').click();
         cy.get('li').contains('Disable tooltips').click();
-        cy.waitForDom();
 
-        cy.get('[data-cy=side-panel-tree]').then(($el) => {
-            const el = $el.get(0) //native DOM element
-            expect(el._tippy).to.be.undefined;
-        });
+        cy.contains('This allows you to navigate through the app').should('not.exist');
+        cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
+        cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
+        cy.contains('This allows you to navigate through the app').should('not.exist');
     });
 });
index da7300a43014cbefde2f3edd2842fb61d9aa8c87..529d776088886baf753b45c12f8f0a52a437480b 100644 (file)
@@ -182,11 +182,11 @@ Cypress.Commands.add("createWorkflow", (token, data) => {
     });
 });
 
-Cypress.Commands.add("createCollection", (token, data) => {
+Cypress.Commands.add("createCollection", (token, data, keep = false) => {
     return cy.createResource(token, "collections", {
         collection: JSON.stringify(data),
         ensure_unique_name: true,
-    });
+    }, keep);
 });
 
 Cypress.Commands.add("getCollection", (token, uuid) => {
@@ -321,16 +321,19 @@ Cypress.Commands.add("getResource", (token, suffix, uuid) => {
         });
 });
 
-Cypress.Commands.add("createResource", (token, suffix, data) => {
+Cypress.Commands.add("createResource", (token, suffix, data, keep = false) => {
     return cy
         .doRequest("POST", "/arvados/v1/" + suffix, data, null, token, true)
         .its("body")
         .then(function (resource) {
-            createdResources.push({ suffix, uuid: resource.uuid });
+            if (! keep) {
+                createdResources.push({ suffix, uuid: resource.uuid });
+            };
             return resource;
         });
 });
 
+
 Cypress.Commands.add("deleteResource", (token, suffix, uuid, failOnStatusCode = true) => {
     return cy
         .doRequest("DELETE", "/arvados/v1/" + suffix + "/" + uuid, null, null, token, false, true, failOnStatusCode)