1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 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.getUser('collectionuser1', 'Collection', 'User', false, true)
20 .as('activeUser').then(function () {
21 activeUser = this.activeUser;
25 beforeEach(function () {
26 cy.on('uncaught:exception', (err, runnable, promise) => {
27 Cypress.log({ message: `Application Error: ${err}`});
33 cy.createCollection(adminUser.token, {
34 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
35 owner_uuid: adminUser.user.uuid,
36 }).as('bannerCollection');
38 cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
39 collectionUUID=bannerCollection.uuid;
41 cy.loginAs(adminUser);
43 cy.goToPath(`/collections/${bannerCollection.uuid}`);
45 cy.get('[data-cy=upload-button]').click();
47 cy.fixture('files/banner.html').as('banner');
48 cy.fixture('files/tooltips.txt').as('tooltips');
50 cy.getAll('@banner', '@tooltips').then(([banner, tooltips]) => {
51 cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
52 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
55 cy.get('[data-cy=form-submit-btn]').click();
56 cy.get('[data-cy=form-submit-btn]').should('not.exist');
57 cy.get('[data-cy=collection-files-right-panel]')
58 .should('contain', 'banner.html');
59 cy.get('[data-cy=collection-files-right-panel]')
60 .should('contain', 'tooltips.json');
62 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
64 res.body.Workbench.BannerUUID = collectionUUID;
70 it.only('should re-show the banner', () => {
71 cy.loginAs(adminUser);
73 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
75 cy.get('[title=Notifications]').click({ force: true });
77 cy.get('li').contains('Restore Banner').click({ force: true });
79 cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
83 it.only('should show tooltips and remove tooltips as localStorage key is present', () => {
84 cy.loginAs(adminUser);
86 cy.get('[data-cy=side-panel-tree]').then(($el) => {
87 const el = $el.get(0) //native DOM element
88 expect(el._tippy).to.exist;
91 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
93 cy.get('[title=Notifications]').click();
94 cy.get('li').contains('Disable tooltips').click();
96 cy.get('[data-cy=side-panel-tree]').then(($el) => {
97 const el = $el.get(0) //native DOM element
98 expect(el._tippy).to.be.undefined;