2020-11-22 20:50:07 +00:00
|
|
|
/*
|
2022-06-08 11:19:51 +00:00
|
|
|
* SPDX-FileCopyrightText: 2022 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(() => {
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.intercept(
|
|
|
|
{
|
2023-08-12 18:07:38 +00:00
|
|
|
url: '/api/private/tokens',
|
2021-11-19 17:04:04 +00:00
|
|
|
method: 'GET'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
body: [
|
|
|
|
{
|
|
|
|
label: 'cypress-App',
|
2021-12-02 22:03:03 +00:00
|
|
|
keyId: 'cypress',
|
|
|
|
createdAt: '2021-11-21T01:11:12+01:00',
|
|
|
|
lastUsed: '2021-11-21T01:11:12+01:00',
|
|
|
|
validUntil: '2023-11-21'
|
2021-11-19 17:04:04 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
cy.intercept(
|
|
|
|
{
|
2023-08-12 18:07:38 +00:00
|
|
|
url: '/api/private/tokens',
|
2021-11-19 17:04:04 +00:00
|
|
|
method: 'POST'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
body: {
|
|
|
|
label: 'cypress',
|
2021-12-02 22:03:03 +00:00
|
|
|
keyId: 'cypress2',
|
2021-11-19 17:04:04 +00:00
|
|
|
secret: 'c-y-p-r-e-s-s',
|
2021-12-02 22:03:03 +00:00
|
|
|
createdAt: '2021-11-21T01:11:12+01:00',
|
|
|
|
lastUsed: '2021-11-21T01:11:12+01:00',
|
|
|
|
validUntil: '2023-11-21'
|
2022-04-15 21:03:15 +00:00
|
|
|
},
|
|
|
|
statusCode: 201
|
2020-10-10 09:38:32 +00:00
|
|
|
}
|
2021-11-19 17:04:04 +00:00
|
|
|
)
|
|
|
|
cy.intercept(
|
|
|
|
{
|
2023-08-12 18:07:38 +00:00
|
|
|
url: '/api/private/tokens/cypress',
|
2021-11-19 17:04:04 +00:00
|
|
|
method: 'DELETE'
|
|
|
|
},
|
|
|
|
{
|
2022-04-15 21:03:15 +00:00
|
|
|
body: [],
|
|
|
|
statusCode: 204
|
2021-11-19 17:04:04 +00:00
|
|
|
}
|
|
|
|
)
|
2022-01-30 20:46:43 +00:00
|
|
|
cy.visit('/profile', { retryOnNetworkFailure: true })
|
2020-10-10 09:38:32 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('access tokens', () => {
|
|
|
|
it('list existing tokens', () => {
|
2021-12-25 15:44:24 +00:00
|
|
|
cy.getByCypressId('access-token-label').contains('cypress-App')
|
2020-10-10 09:38:32 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('delete token', () => {
|
2021-12-25 15:44:24 +00:00
|
|
|
cy.getByCypressId('access-token-delete-button').click()
|
|
|
|
cy.getByCypressId('access-token-modal-delete').as('deletion-modal')
|
2021-11-19 17:04:04 +00:00
|
|
|
cy.get('@deletion-modal').should('be.visible').find('.modal-footer .btn-danger').click()
|
|
|
|
cy.get('@deletion-modal').should('not.exist')
|
2020-10-10 09:38:32 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('add token', () => {
|
2021-12-25 15:44:24 +00:00
|
|
|
cy.getByCypressId('access-token-add-button').should('be.disabled')
|
|
|
|
cy.getByCypressId('access-token-add-input-label').type('cypress')
|
|
|
|
cy.getByCypressId('access-token-modal-add').should('not.exist')
|
|
|
|
cy.getByCypressId('access-token-add-button').should('not.be.disabled').click()
|
|
|
|
cy.getByCypressId('access-token-modal-add')
|
2020-10-10 09:38:32 +00:00
|
|
|
.should('be.visible')
|
2021-11-19 17:04:04 +00:00
|
|
|
.find('input[readonly]')
|
2020-10-10 09:38:32 +00:00
|
|
|
.should('have.value', 'c-y-p-r-e-s-s')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|