+
// 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;
.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);
.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;
+ }
+ });
+
+ //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);
+ //reload instead of cy.loginAs() to preserve localStorage and intercept listener
+ //logged in as adminUser
+ cy.reload();
+ cy.waitForDom();
- cy.get('[data-cy=side-panel-tree]').then(($el) => {
- const el = $el.get(0) //native DOM element
- expect(el._tippy).to.exist;
- });
+ //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({force: true});
+ cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
- cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+ 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');
});
-});
\ No newline at end of file
+});