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(banner, 'banner.html', false);
51 cy.get('[data-cy=drag-and-drop]').upload(tooltips, 'tooltips.json', false);
54 cy.get('[data-cy=form-submit-btn]').click();
55 cy.get('[data-cy=form-submit-btn]').should('not.exist');
56 cy.get('[data-cy=collection-files-right-panel]')
57 .contains('banner.html').should('exist');
58 cy.get('[data-cy=collection-files-right-panel]')
59 .contains('tooltips.json').should('exist');
62 cy.on('uncaught:exception', (err, runnable) => {console.error(err)});
65 beforeEach(function () {
67 cy.clearLocalStorage();
68 cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
70 res.body.Workbench.BannerUUID = collectionUUID;
75 it('should re-show the banner', () => {
76 cy.loginAs(adminUser);
80 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
82 cy.get('[title=Notifications]').click();
83 cy.get('li').contains('Restore Banner').click();
87 cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
91 it('should show tooltips and remove tooltips as localStorage key is present', () => {
92 cy.loginAs(adminUser);
96 cy.get('[data-cy=side-panel-tree]').then(($el) => {
97 const el = $el.get(0) //native DOM element
98 expect(el._tippy).to.exist;
103 cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
105 cy.get('[title=Notifications]').click();
106 cy.get('li').contains('Disable tooltips').click();
108 cy.get('[data-cy=side-panel-tree]').then(($el) => {
109 const el = $el.get(0) //native DOM element
110 expect(el._tippy).to.be.undefined;