2020-11-22 20:50:07 +00:00
|
|
|
/*
|
2021-01-06 20:37:59 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 20:50:07 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2020-10-10 09:38:32 +00:00
|
|
|
describe('profile page', () => {
|
|
|
|
beforeEach(() => {
|
2020-11-30 11:31:54 +00:00
|
|
|
cy.intercept({
|
2021-05-02 20:38:43 +00:00
|
|
|
url: '/mock-backend/api/private/tokens',
|
2020-11-30 11:31:54 +00:00
|
|
|
method: 'GET'
|
|
|
|
}, {
|
|
|
|
body: [
|
2020-10-10 09:38:32 +00:00
|
|
|
{
|
2021-02-03 21:13:04 +00:00
|
|
|
label: 'cypress-App',
|
2020-10-10 09:38:32 +00:00
|
|
|
created: 1601991518
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
2020-11-30 11:31:54 +00:00
|
|
|
cy.intercept({
|
2021-05-02 20:38:43 +00:00
|
|
|
url: '/mock-backend/api/private/tokens',
|
2020-11-30 11:31:54 +00:00
|
|
|
method: 'POST'
|
|
|
|
}, {
|
|
|
|
body: {
|
2020-10-10 09:38:32 +00:00
|
|
|
label: 'cypress',
|
|
|
|
secret: 'c-y-p-r-e-s-s',
|
|
|
|
created: Date.now()
|
|
|
|
}
|
|
|
|
})
|
2020-11-30 11:31:54 +00:00
|
|
|
cy.intercept({
|
2021-05-02 20:38:43 +00:00
|
|
|
url: '/mock-backend/api/private/tokens/1601991518',
|
2020-11-30 11:31:54 +00:00
|
|
|
method: 'DELETE'
|
|
|
|
}, {
|
|
|
|
body: []
|
2020-10-10 09:38:32 +00: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 10:51:40 +00:00
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('not.exist')
|
2020-10-10 09:38:32 +00: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 10:51:40 +00:00
|
|
|
.should('not.exist')
|
2020-10-10 09:38:32 +00: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 10:51:40 +00:00
|
|
|
cy.get('.modal-dialog')
|
|
|
|
.should('not.exist')
|
2020-10-10 09:38:32 +00: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')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|