2020-11-22 15:50:07 -05:00
|
|
|
/*
|
2021-01-06 15:37:59 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 15:50:07 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2020-10-10 05:38:32 -04:00
|
|
|
describe('profile page', () => {
|
|
|
|
beforeEach(() => {
|
2020-11-30 06:31:54 -05:00
|
|
|
cy.intercept({
|
2021-05-02 16:38:43 -04:00
|
|
|
url: '/mock-backend/api/private/tokens',
|
2020-11-30 06:31:54 -05:00
|
|
|
method: 'GET'
|
|
|
|
}, {
|
|
|
|
body: [
|
2020-10-10 05:38:32 -04:00
|
|
|
{
|
2021-02-03 16:13:04 -05:00
|
|
|
label: 'cypress-App',
|
2020-10-10 05:38:32 -04:00
|
|
|
created: 1601991518
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2020-11-30 06:31:54 -05:00
|
|
|
cy.intercept({
|
2021-05-02 16:38:43 -04:00
|
|
|
url: '/mock-backend/api/private/tokens',
|
2020-11-30 06:31:54 -05:00
|
|
|
method: 'POST'
|
|
|
|
}, {
|
|
|
|
body: {
|
2020-10-10 05:38:32 -04:00
|
|
|
label: 'cypress',
|
|
|
|
secret: 'c-y-p-r-e-s-s',
|
|
|
|
created: Date.now()
|
|
|
|
}
|
|
|
|
})
|
2020-11-30 06:31:54 -05:00
|
|
|
cy.intercept({
|
2021-05-02 16:38:43 -04:00
|
|
|
url: '/mock-backend/api/private/tokens/1601991518',
|
2020-11-30 06:31:54 -05:00
|
|
|
method: 'DELETE'
|
|
|
|
}, {
|
|
|
|
body: []
|
2020-10-10 05:38:32 -04:00
|
|
|
})
|
|
|
|
cy.visit('/profile')
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('access tokens', () => {
|
|
|
|
it('list existing tokens', () => {
|
|
|
|
cy.get('.card.access-tokens .list-group-item .text-start.col')
|
|
|
|
.contains('cypress-App')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('delete token', () => {
|
2020-11-28 05:51:40 -05:00
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('not.exist')
|
2020-10-10 05:38:32 -04:00
|
|
|
cy.get('.card.access-tokens .list-group-item .btn-danger')
|
|
|
|
.click()
|
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('be.visible')
|
|
|
|
.get('.modal-footer .btn-danger')
|
|
|
|
.click()
|
|
|
|
cy.get('.modal-dialog')
|
2020-11-28 05:51:40 -05:00
|
|
|
.should('not.exist')
|
2020-10-10 05:38:32 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
it('add token', () => {
|
|
|
|
cy.get('.card.access-tokens .btn-primary')
|
|
|
|
.should('be.disabled')
|
|
|
|
cy.get('.card.access-tokens input[type=text]')
|
|
|
|
.type('cypress')
|
2020-11-28 05:51:40 -05:00
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('not.exist')
|
2020-10-10 05:38:32 -04:00
|
|
|
cy.get('.card.access-tokens .btn-primary')
|
|
|
|
.should('not.be.disabled')
|
|
|
|
.click()
|
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('be.visible')
|
|
|
|
.get('.modal-dialog input[readonly]')
|
|
|
|
.should('have.value', 'c-y-p-r-e-s-s')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|