16ef915bdbea5ecbb4a197acbed79bcd6df73f9a
[arvados-workbench2.git] / cypress / integration / login.spec.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 describe('Login tests', function() {
6     before(function() {
7         cy.resetDB();
8     })
9
10     beforeEach(function() {
11         cy.arvadosFixture('users').as('users')
12         cy.arvadosFixture('api_client_authorizations').as('client_auth')
13         cy.clearCookies()
14         cy.clearLocalStorage()
15     })
16
17     it('logs in successfully', function() {
18         const active_user = this.users['active']
19         const active_token = this.client_auth['active']['api_token']
20         cy.visit('/token/?api_token='+active_token)
21         cy.url().should('contain', '/projects/')
22         cy.get('button[title="Account Management"]').click()
23         cy.get('ul[role=menu] > li[role=menuitem]').contains(`${active_user['first_name']} ${active_user['last_name']}`)
24     })
25
26     it('fails to log in with expired token', function() {
27         const expired_token = this.client_auth['expired']['api_token']
28         cy.visit('/token/?api_token='+expired_token)
29         cy.contains('Please log in')
30         cy.url().should('not.contain', '/projects/')
31     })
32 })