X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9d1ff3299a57d0e820bf7975f0f3e6080b22f0a5..dd263aecac743dabaffa580767b5628806263392:/services/workbench2/cypress/e2e/banner-tooltip.cy.js diff --git a/services/workbench2/cypress/e2e/banner-tooltip.cy.js b/services/workbench2/cypress/e2e/banner-tooltip.cy.js index 0a0ac75164..7cb2bc405e 100644 --- a/services/workbench2/cypress/e2e/banner-tooltip.cy.js +++ b/services/workbench2/cypress/e2e/banner-tooltip.cy.js @@ -1,9 +1,9 @@ + // Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 describe('Banner / tooltip tests', function () { - let activeUser; let adminUser; let collectionUUID; @@ -16,27 +16,17 @@ describe('Banner / tooltip tests', function () { .as('adminUser').then(function () { adminUser = this.adminUser; }); - cy.getUser('collectionuser1', 'Collection', 'User', false, true) - .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,43 +48,79 @@ describe('Banner / tooltip tests', function () { .should('contain', 'banner.html'); cy.get('[data-cy=collection-files-right-panel]') .should('contain', 'tooltips.json'); + }); + }); + + 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; - }); + //login here instead of in specific tests to preserve localStorage and intercept listener + cy.loginAs(adminUser); + + //must be in localstorage to have banner option in notifications menu + //it doesn't matter what the value is, as long as it's truthy + window.localStorage.setItem('bannerFileData', 'foo'); + + 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); + //reload instead of cy.loginAs() to preserve localStorage and intercept listener + //logged in as adminUser + cy.reload(); + cy.waitForDom(); + //check that banner appears on reload + cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible'); cy.get('[data-cy=confirmation-dialog-ok-btn]').click(); + cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist'); - cy.get('[title=Notifications]').click({ force: true }); + //check that banner appears on toggle + cy.get('[title=Notifications]').click(); cy.get('li').contains('Restore Banner').click(); - cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible'); + cy.waitForDom().get('[data-cy=confirmation-dialog-ok-btn]', {timeout: 10000}).should('be.visible'); + cy.get('[data-cy=confirmation-dialog-ok-btn]').click(); + cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist'); }); 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; - }); + //reload instead of cy.loginAs() to preserve localStorage and intercept listener + //logged in as adminUser + cy.reload(); + cy.waitForDom(); + //banner appears on reload + cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible'); cy.get('[data-cy=confirmation-dialog-ok-btn]').click(); + cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).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.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'); }); });