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