2020-12-10 14:52:35 +01:00
|
|
|
import '../../support/authenticateUser'
|
2022-08-09 11:55:19 +02:00
|
|
|
import {createLists} from '../list/prepareLists'
|
|
|
|
|
|
|
|
function logout() {
|
|
|
|
cy.get('.navbar .user .username')
|
|
|
|
.click()
|
|
|
|
cy.get('.navbar .user .dropdown-menu .dropdown-item')
|
|
|
|
.contains('Logout')
|
|
|
|
.click()
|
|
|
|
}
|
2020-12-10 14:52:35 +01:00
|
|
|
|
|
|
|
describe('Log out', () => {
|
|
|
|
it('Logs the user out', () => {
|
|
|
|
cy.visit('/')
|
|
|
|
|
2022-08-09 11:55:19 +02:00
|
|
|
expect(localStorage.getItem('token')).to.not.eq(null)
|
|
|
|
|
|
|
|
logout()
|
|
|
|
|
|
|
|
cy.url()
|
|
|
|
.should('contain', '/login')
|
|
|
|
.then(() => {
|
|
|
|
expect(localStorage.getItem('token')).to.eq(null)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
it.skip('Should clear the list history after logging the user out', () => {
|
|
|
|
const lists = createLists()
|
|
|
|
cy.visit(`/lists/${lists[0].id}`)
|
|
|
|
.then(() => {
|
|
|
|
expect(localStorage.getItem('listHistory')).to.not.eq(null)
|
|
|
|
})
|
|
|
|
|
|
|
|
logout()
|
2020-12-10 14:52:35 +01:00
|
|
|
|
2022-08-09 11:55:19 +02:00
|
|
|
cy.wait(1000) // This makes re-loading of the list and associated entities (and the resulting error) visible
|
|
|
|
|
2020-12-10 14:52:35 +01:00
|
|
|
cy.url()
|
|
|
|
.should('contain', '/login')
|
2022-08-09 11:55:19 +02:00
|
|
|
.then(() => {
|
|
|
|
expect(localStorage.getItem('listHistory')).to.eq(null)
|
|
|
|
})
|
2020-12-10 14:52:35 +01:00
|
|
|
})
|
|
|
|
})
|