* create new pack, handle user follow buttons, use pack on article page, remove initializeUserFollowButts * init all follow button types, add pack to tag index and podcast episode pages * add pack to all relevant pages, listen for newly inserted follow buttons * change to searchParams to remove follow button initializer calls * fix bug with tag page, add pack to notifications page * fix issue with follow back inner text * update cypress specs * run the followbuttons code on sponsors page * remove extra foreach * add test for follow from article sidebar * add test for follow and unfollow tag * add test for the tag index page * add spec for organisation profile follow * add tests for follow buttons in search results * add tests for notification follows * commit missed file - woops * show login modal if user is logged out when they click * add cypress tests for logged out state * change tag button initialization * remove data-button-initialized * init follow buttons from base pack * handle the case where multiple follow buttons exist on a page for the same user * account for instantclick and userdata not being defined, lower coverage for jest * use getInstantClick * fix issue with set initialisation * only listen for mutations in areas we know follow buttons may be added dynamically * small refactors
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
import { getInterceptsForLingeringUserRequests } from '../../../util/networkUtils';
|
|
|
|
describe('User Logout', () => {
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
|
|
cy.fixture('users/changePasswordUser.json').as('user');
|
|
|
|
cy.get('@user').then((user) => {
|
|
cy.loginAndVisit(user, '/');
|
|
});
|
|
});
|
|
|
|
it('should allow a user to logout', () => {
|
|
// Click on the sign out button
|
|
cy.findByText('Sign Out').click({ force: true });
|
|
|
|
// We intercept user-related network requests triggered on logout, so we can await them and avoid issues with a subsequent login
|
|
const logoutNetworkRequests = getInterceptsForLingeringUserRequests(
|
|
'/signout_confirm',
|
|
false,
|
|
);
|
|
|
|
// Sign out confirmation page is rendered
|
|
cy.url().should('contains', '/signout_confirm');
|
|
cy.findByRole('button', { name: 'Yes, sign out' }).click();
|
|
|
|
cy.wait(logoutNetworkRequests);
|
|
|
|
// User should be redirected to the homepage
|
|
const { baseUrl } = Cypress.config();
|
|
cy.url().should('equal', `${baseUrl}`);
|
|
|
|
// Make sure the state has updated to logged out
|
|
cy.findAllByRole('link', { name: 'Log in' });
|
|
|
|
// User data should not exist on the document or in localStorage
|
|
cy.document().should((doc) => {
|
|
expect(doc.body.dataset).not.to.have.property('user');
|
|
expect(localStorage.getItem('current_user')).to.be.null;
|
|
});
|
|
});
|
|
});
|