2 // Copyright (C) The Arvados Authors. All rights reserved.
4 // SPDX-License-Identifier: AGPL-3.0
6 describe('Banner / tooltip tests', function () {
11 // Only set up common users once. These aren't set up as aliases because
12 // aliases are cleaned up after every test. Also it doesn't make sense
13 // to set the same users on beforeEach() over and over again, so we
14 // separate a little from Cypress' 'Best Practices' here.
15 cy.getUser('admin', 'Admin', 'User', true, true)
16 .as('adminUser').then(function () {
17 adminUser = this.adminUser;
19 cy.getAll('@adminUser').then(([adminUser]) => {
20 // This collection will not be deleted after each test, we'll
21 // clean it up manually.
22 cy.createCollection(adminUser.token, {
23 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
24 owner_uuid: adminUser.user.uuid,
25 }, true).as('bannerCollection');
28 cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
29 collectionUUID = bannerCollection.uuid;
31 cy.loginAs(adminUser);
33 cy.goToPath(`/collections/${bannerCollection.uuid}`);
35 cy.get('[data-cy=upload-button]').click();
37 cy.fixture('files/banner.html').as('banner');
38 cy.fixture('files/tooltips.txt').as('tooltips');
40 cy.getAll('@banner', '@tooltips').then(([banner, tooltips]) => {
41 cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
42 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
45 cy.get('[data-cy=form-submit-btn]').click();
46 cy.get('[data-cy=form-submit-btn]').should('not.exist');
47 cy.get('[data-cy=collection-files-right-panel]')
48 .should('contain', 'banner.html');
49 cy.get('[data-cy=collection-files-right-panel]')
50 .should('contain', 'tooltips.json');
54 beforeEach(function () {
55 cy.on('uncaught:exception', (err, runnable, promise) => {
56 Cypress.log({ message: `Application Error: ${err}`});
62 //login here instead of in specific tests to preserve localStorage and intercept listener
63 cy.loginAs(adminUser);
65 //must be in localstorage to have banner option in notifications menu
66 //it doesn't matter what the value is, as long as it's truthy
67 window.localStorage.setItem('bannerFileData', 'foo');
69 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
70 req.on('response', (res) => {
71 res.body.Workbench.BannerUUID = collectionUUID;
77 // Delete banner collection after all test used it.
78 cy.deleteResource(adminUser.token, "collections", collectionUUID);
81 it('should re-show the banner', () => {
82 //reload instead of cy.loginAs() to preserve localStorage and intercept listener
83 //logged in as adminUser
87 //check that banner appears on reload
88 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible');
89 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
90 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
92 //check that banner appears on toggle
93 cy.get('[title=Notifications]').click();
94 cy.get('li').contains('Restore Banner').click();
96 cy.waitForDom().get('[data-cy=confirmation-dialog-ok-btn]', {timeout: 10000}).should('be.visible');
97 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
98 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
102 it('should show tooltips and remove tooltips as localStorage key is present', () => {
103 //reload instead of cy.loginAs() to preserve localStorage and intercept listener
104 //logged in as adminUser
108 //banner appears on reload
109 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible');
110 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
111 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
113 cy.contains('This allows you to navigate through the app').should('not.exist'); // This content comes from tooltips.txt
114 cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
115 cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
116 cy.contains('This allows you to navigate through the app').should('be.visible');
118 cy.get('[title=Notifications]').click();
119 cy.get('li').contains('Disable tooltips').click();
121 cy.contains('This allows you to navigate through the app').should('not.exist');
122 cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
123 cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
124 cy.contains('This allows you to navigate through the app').should('not.exist');