21700: Install Bundler system-wide in Rails postinst
[arvados.git] / services / workbench2 / cypress / e2e / banner-tooltip.cy.js
1
2 // Copyright (C) The Arvados Authors. All rights reserved.
3 //
4 // SPDX-License-Identifier: AGPL-3.0
5
6 describe('Banner / tooltip tests', function () {
7     let activeUser;
8     let adminUser;
9     let collectionUUID;
10
11     before(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;
19             });
20         cy.getUser('collectionuser1', 'Collection', 'User', false, true)
21             .as('activeUser').then(function () {
22                 activeUser = this.activeUser;
23             });
24
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');
32         });
33
34         cy.getAll('@bannerCollection').then(function ([bannerCollection]) {
35             collectionUUID = bannerCollection.uuid;
36
37             cy.loginAs(adminUser);
38
39             cy.goToPath(`/collections/${bannerCollection.uuid}`);
40
41             cy.get('[data-cy=upload-button]').click();
42
43             cy.fixture('files/banner.html').as('banner');
44             cy.fixture('files/tooltips.txt').as('tooltips');
45
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);
49             });
50
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');
57         });
58     });
59
60     beforeEach(function () {
61         cy.on('uncaught:exception', (err, runnable, promise) => {
62             Cypress.log({ message: `Application Error: ${err}`});
63             if (promise) {
64                 return false;
65             }
66         });
67         cy.intercept({ method: 'GET', url: '**/arvados/v1/config?nocache=*' }, (req) => {
68             req.on('response', (res) => {
69                 res.body.Workbench.BannerUUID = collectionUUID;
70             });
71         });
72     });
73
74     after(function () {
75         // Delete banner collection after all test used it.
76         cy.deleteResource(adminUser.token, "collections", collectionUUID);
77     });
78
79     it('should re-show the banner', () => {
80         cy.loginAs(adminUser);
81         cy.waitForDom();
82
83         cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
84         cy.waitForDom();
85         cy.get('[data-cy=confirmation-dialog]').should('not.exist');
86
87         cy.get('[title=Notifications]').click();
88         cy.get('li').contains('Restore Banner').click();
89
90         cy.get('[data-cy=confirmation-dialog-ok-btn]').should('be.visible');
91     });
92
93
94     it('should show tooltips and remove tooltips as localStorage key is present', () => {
95         cy.loginAs(adminUser);
96
97         cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
98
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');
103
104         cy.get('[title=Notifications]').click();
105         cy.get('li').contains('Disable tooltips').click();
106
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');
111     });
112 });