2 // Copyright (C) The Arvados Authors. All rights reserved.
4 // SPDX-License-Identifier: AGPL-3.0
6 import { BANNER_LOCAL_STORAGE_KEY } from '../../src/views-components/baner/banner';
8 describe('Banner / tooltip tests', function () {
13 // Only set up common users once. These aren't set up as aliases because
14 // aliases are cleaned up after every test. Also it doesn't make sense
15 // to set the same users on beforeEach() over and over again, so we
16 // separate a little from Cypress' 'Best Practices' here.
17 cy.getUser('admin', 'Admin', 'User', true, true)
18 .as('adminUser').then(function () {
19 adminUser = this.adminUser;
21 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
22 .as('activeUser').then(function () {
23 activeUser = this.activeUser;
27 beforeEach(function () {
28 cy.on('uncaught:exception', (err, runnable, promise) => {
29 Cypress.log({ message: `Application Error: ${err}`});
36 it('should re-show the banner', () => {
37 cy.loginAs(adminUser);
39 cy.getAll('@adminUser').then(([adminUser]) => {
40 cy.createCollection(adminUser.token, {
41 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
42 owner_uuid: adminUser.user.uuid,
43 }, true).as('bannerCollection');
46 cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
47 cy.intercept({ method: 'GET', hostname: "127.0.0.1", url: '**/arvados/v1/config?nocache=*' }, (req) => {
48 req.continue((res) => {
49 if (res.body.Workbench) res.body.Workbench.BannerUUID = bannerCollection.uuid;
53 cy.goToPath(`/collections/${bannerCollection.uuid}`);
55 cy.get('[data-cy=upload-button]').click();
57 cy.fixture('files/banner.html').as('banner');
58 cy.fixture('files/tooltips.txt').as('tooltips');
60 cy.getAll('@banner', '@tooltips').then(([banner, tooltips]) => {
61 cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
62 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
65 cy.get('[data-cy=form-submit-btn]').click();
66 cy.get('[data-cy=form-submit-btn]').should('not.exist');
67 cy.get('[data-cy=collection-files-right-panel]')
68 .should('contain', 'banner.html');
69 cy.get('[data-cy=collection-files-right-panel]')
70 .should('contain', 'tooltips.json');
72 cy.getAll('@bannerCollection').then((bannerCollection)=>{
73 console.log('bannerCollection', bannerCollection[0]);
74 window.localStorage.setItem(BANNER_LOCAL_STORAGE_KEY, bannerCollection)});
76 //manual reload instead of loginAs() to preserve localstorage
80 //check that banner appears on reload
81 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible');
82 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
83 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
85 //check that banner appears on "Restore Banner"
86 cy.get('[title=Notifications]').click();
87 cy.get('li').contains('Restore Banner').click();
89 cy.waitForDom().get('[data-cy=confirmation-dialog-ok-btn]', {timeout: 10000}).should('be.visible');
90 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('be.visible');
91 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
92 cy.waitForDom().get('[data-cy=confirmation-dialog]', {timeout: 10000}).should('not.exist');
96 it('should show tooltips and remove tooltips as localStorage key is present', () => {
97 cy.loginAs(adminUser);
100 cy.getAll('@adminUser').then(([adminUser]) => {
101 cy.createCollection(adminUser.token, {
102 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
103 owner_uuid: adminUser.user.uuid,
104 }, true).as('bannerCollection');
107 cy.contains('This allows you to navigate through the app').should('not.exist'); // This content comes from tooltips.txt
108 cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
109 cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
110 cy.contains('This allows you to navigate through the app').should('be.visible');
112 cy.get('[title=Notifications]').click();
113 cy.get('li').contains('Disable tooltips').click();
115 cy.contains('This allows you to navigate through the app').should('not.exist');
116 cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
117 cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
118 cy.contains('This allows you to navigate through the app').should('not.exist');