1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Collection panel 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;
20 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
21 .as('activeUser').then(function () {
22 activeUser = this.activeUser;
26 cy.getAll('@adminUser')
27 .then(function([adminUser]) {
28 cy.createCollection(adminUser.token, {
29 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
30 owner_uuid: adminUser.user.uuid,
31 }).as('bannerCollection');
33 cy.getAll('@bannerCollection')
34 .then(function ([bannerCollection]) {
36 collectionUUID=bannerCollection.uuid;
38 cy.loginAs(adminUser);
40 cy.goToPath(`/collections/${bannerCollection.uuid}`);
42 cy.get('[data-cy=upload-button]').click();
44 cy.fixture('files/banner.html').as('banner');
45 cy.fixture('files/tooltips.txt').as('tooltips');
47 cy.getAll('@banner', '@tooltips')
48 .then(([banner, tooltips]) => {
50 cy.get('[data-cy=drag-and-drop]').upload(btoa(banner), 'banner.html');
51 cy.get('[data-cy=drag-and-drop]').upload(btoa(tooltips), 'tooltips.json');
54 cy.get('[data-cy=form-submit-btn]').click();
57 cy.on('uncaught:exception', (err, runnable) => {console.error(err)});
60 beforeEach(function () {
62 cy.clearLocalStorage();
63 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
65 res.body.Workbench.BannerUUID = collectionUUID;
70 it('should re-show the banner', () => {
71 cy.loginAs(adminUser);
75 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
77 cy.get('[title=Notifications]').click();
78 cy.get('li').contains('Restore Banner').click();
82 cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
86 it('should show tooltips and remove tooltips as localStorage key is present', () => {
87 cy.loginAs(adminUser);
91 cy.get('[data-cy=side-panel-tree]').then(($el) => {
92 const el = $el.get(0) //native DOM element
93 expect(el._tippy).to.exist;
98 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
100 cy.get('[title=Notifications]').click();
101 cy.get('li').contains('Disable tooltips').click();
103 cy.get('[data-cy=side-panel-tree]').then(($el) => {
104 const el = $el.get(0) //native DOM element
105 expect(el._tippy).to.be.undefined;