X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e2f4f1c30dfeff4261333fd65a4c521acc098804..0b7567c68696515d7511a0696dbe3d1c42d3a85a:/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 b894391282..bd57863c94 100644 --- a/services/workbench2/cypress/e2e/banner-tooltip.cy.js +++ b/services/workbench2/cypress/e2e/banner-tooltip.cy.js @@ -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,43 +54,68 @@ 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.reply((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.loginAs(adminUser); + 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(); + 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 }); - cy.get('[data-cy=restore-banner-li]').click({ force: true }); + 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'); }); 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(); + 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('[data-cy=disable-tooltip-toggle]').click({ force: true }); + 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'); }); -}); \ No newline at end of file +});