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;
24 cy.on('uncaught:exception', (err, runnable) => {console.error(err)});
27 beforeEach(function () {
29 cy.clearLocalStorage();
32 it('should re-show the banner', () => {
33 setupTheEnvironment();
35 cy.loginAs(adminUser);
39 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
41 cy.get('[title=Notifications]').click();
42 cy.get('li').contains('Restore Banner').click();
46 cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
50 it('should show tooltips and remove tooltips as localStorage key is present', () => {
51 setupTheEnvironment();
53 cy.loginAs(adminUser);
57 cy.get('[data-cy=side-panel-tree]').then(($el) => {
58 const el = $el.get(0) //native DOM element
59 expect(el._tippy).to.exist;
64 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
66 cy.get('[title=Notifications]').click();
67 cy.get('li').contains('Disable tooltips').click();
69 cy.get('[data-cy=side-panel-tree]').then(($el) => {
70 const el = $el.get(0) //native DOM element
71 expect(el._tippy).to.be.undefined;
75 const setupTheEnvironment = () => {
76 cy.createCollection(adminUser.token, {
77 name: `BannerTooltipTest${Math.floor(Math.random() * 999999)}`,
78 owner_uuid: adminUser.user.uuid,
79 }).as('bannerCollection');
81 cy.getAll('@bannerCollection')
82 .then(function ([bannerCollection]) {
84 collectionUUID=bannerCollection.uuid;
86 cy.loginAs(adminUser);
88 cy.goToPath(`/collections/${bannerCollection.uuid}`);
90 cy.get('[data-cy=upload-button]').click();
92 cy.fixture('files/banner.html').as('banner');
93 cy.fixture('files/tooltips.txt').as('tooltips');
95 cy.getAll('@banner', '@tooltips')
96 .then(([banner, tooltips]) => {
97 cy.get('[data-cy=drag-and-drop]').upload(banner, 'banner.html', false);
98 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
101 cy.get('[data-cy=form-submit-btn]').click();
102 cy.get('[data-cy=form-submit-btn]').should('not.exist');
103 cy.get('[data-cy=collection-files-right-panel]')
104 .contains('banner.html').should('exist');
105 cy.get('[data-cy=collection-files-right-panel]')
106 .contains('tooltips.json').should('exist');
108 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
110 res.body.Workbench.BannerUUID = collectionUUID;