2 // Copyright (C) The Arvados Authors. All rights reserved.
4 // SPDX-License-Identifier: AGPL-3.0
6 describe('Banner / tooltip tests', function () {
12 // Only set up common users once. These aren't set up as aliases because
13 // aliases are cleaned up after every test. Also it doesn't make sense
14 // to set the same users on beforeEach() over and over again, so we
15 // separate a little from Cypress' 'Best Practices' here.
16 cy.getUser('admin', 'Admin', 'User', true, true)
17 .as('adminUser').then(function () {
18 adminUser = this.adminUser;
20 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
21 .as('activeUser').then(function () {
22 activeUser = this.activeUser;
25 cy.getAll('@adminUser').then(([adminUser]) => {
26 // This collection will not be deleted after each test, we'll
27 // clean it up manually.
28 cy.createCollection(adminUser.token, {
29 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
30 owner_uuid: adminUser.user.uuid,
31 }, true).as('bannerCollection');
34 cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
35 collectionUUID = bannerCollection.uuid;
37 cy.loginAs(adminUser);
39 cy.goToPath(`/collections/${bannerCollection.uuid}`);
41 cy.get('[data-cy=upload-button]').click();
43 cy.fixture('files/banner.html').as('banner');
44 cy.fixture('files/tooltips.txt').as('tooltips');
46 cy.getAll('@banner', '@tooltips').then(([banner, tooltips]) => {
47 cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
48 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
51 cy.get('[data-cy=form-submit-btn]').click();
52 cy.get('[data-cy=form-submit-btn]').should('not.exist');
53 cy.get('[data-cy=collection-files-right-panel]')
54 .should('contain', 'banner.html');
55 cy.get('[data-cy=collection-files-right-panel]')
56 .should('contain', 'tooltips.json');
60 beforeEach(function () {
61 cy.on('uncaught:exception', (err, runnable, promise) => {
62 Cypress.log({ message: `Application Error: ${err}`});
67 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
68 req.on('response', (res) => {
69 res.body.Workbench.BannerUUID = collectionUUID;
75 // Delete banner collection after all test used it.
76 cy.deleteResource(adminUser.token, "collections", collectionUUID);
79 it('should re-show the banner', () => {
80 cy.loginAs(adminUser);
83 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
85 cy.get('[data-cy=confirmation-dialog]').should('not.exist');
87 cy.get('[title=Notifications]').click();
88 cy.get('li').contains('Restore Banner').click();
90 cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
94 it('should show tooltips and remove tooltips as localStorage key is present', () => {
95 cy.loginAs(adminUser);
97 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
99 cy.contains('This allows you to navigate through the app').should('not.exist'); // This content comes from tooltips.txt
100 cy.get('[data-cy=side-panel-tree]').trigger('mouseover');
101 cy.get('[data-cy=side-panel-tree]').trigger('mouseenter');
102 cy.contains('This allows you to navigate through the app').should('be.visible');
104 cy.get('[title=Notifications]').click();
105 cy.get('li').contains('Disable tooltips').click();
107 cy.contains('This allows you to navigate through the app').should('not.exist');
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('not.exist');