hedgedoc/cypress/integration/profile.spec.ts

78 lines
2 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
describe('profile page', () => {
beforeEach(() => {
cy.intercept(
{
url: '/mock-backend/api/private/tokens',
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'
}
]
}
)
cy.intercept(
{
url: '/mock-backend/api/private/tokens',
method: 'POST'
},
{
body: {
label: 'cypress',
2021-12-02 17:03:03 -05:00
keyId: 'cypress2',
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'
}
}
)
cy.intercept(
{
2021-12-02 17:03:03 -05:00
url: '/mock-backend/api/private/tokens/cypress',
method: 'DELETE'
},
{
body: []
}
)
cy.visit('/profile')
})
describe('access tokens', () => {
it('list existing tokens', () => {
cy.getById('access-token-label').contains('cypress-App')
})
it('delete token', () => {
cy.getById('access-token-delete-button').click()
cy.getById('access-token-modal-delete').as('deletion-modal')
cy.get('@deletion-modal').should('be.visible').find('.modal-footer .btn-danger').click()
cy.get('@deletion-modal').should('not.exist')
})
it('add token', () => {
cy.getById('access-token-add-button').should('be.disabled')
2021-12-02 17:03:03 -05:00
cy.getById('access-token-add-input-label').type('cypress')
cy.getById('access-token-modal-add').should('not.exist')
cy.getById('access-token-add-button').should('not.be.disabled').click()
cy.getById('access-token-modal-add')
.should('be.visible')
.find('input[readonly]')
.should('have.value', 'c-y-p-r-e-s-s')
})
})
})