diff --git a/cypress/e2e/list/prepareLists.ts b/cypress/e2e/list/prepareLists.ts index afef6ba4f..d40dc9d08 100644 --- a/cypress/e2e/list/prepareLists.ts +++ b/cypress/e2e/list/prepareLists.ts @@ -3,14 +3,19 @@ import {UserFactory} from '../../factories/user' import {NamespaceFactory} from '../../factories/namespace' import {TaskFactory} from '../../factories/task' +export function createLists() { + UserFactory.create(1) + NamespaceFactory.create(1) + const lists = ListFactory.create(1, { + title: 'First List' + }) + TaskFactory.truncate() + return lists +} + export function prepareLists(setLists = () => {}) { beforeEach(() => { - UserFactory.create(1) - NamespaceFactory.create(1) - const lists = ListFactory.create(1, { - title: 'First List' - }) + const lists = createLists() setLists(lists) - TaskFactory.truncate() }) } \ No newline at end of file diff --git a/cypress/e2e/user/logout.spec.ts b/cypress/e2e/user/logout.spec.ts index 1a22e21ef..2f45f0bf1 100644 --- a/cypress/e2e/user/logout.spec.ts +++ b/cypress/e2e/user/logout.spec.ts @@ -1,16 +1,44 @@ import '../../support/authenticateUser' +import {createLists} from '../list/prepareLists' + +function logout() { + cy.get('.navbar .user .username') + .click() + cy.get('.navbar .user .dropdown-menu .dropdown-item') + .contains('Logout') + .click() +} describe('Log out', () => { it('Logs the user out', () => { cy.visit('/') - cy.get('.navbar .user .username') - .click() - cy.get('.navbar .user .dropdown-menu .dropdown-item') - .contains('Logout') - .click() + 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() + + cy.wait(1000) // This makes re-loading of the list and associated entities (and the resulting error) visible + + cy.url() + .should('contain', '/login') + .then(() => { + expect(localStorage.getItem('listHistory')).to.eq(null) + }) }) }) diff --git a/src/store/modules/auth.ts b/src/store/modules/auth.ts index 99291a2a9..6273e5c1e 100644 --- a/src/store/modules/auth.ts +++ b/src/store/modules/auth.ts @@ -287,6 +287,7 @@ export default { }, logout(ctx) { removeToken() + window.localStorage.clear() // Clear all settings and history we might have saved in local storage. ctx.dispatch('checkAuth') }, },