31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
/// <reference types="cypress" />
|
|
|
|
import makeFakeUser from '../../factories/user';
|
|
|
|
describe('Unsubscribe from email link', () => {
|
|
beforeEach(() => {
|
|
// cy.intercept('POST', /\S+\/unsubscribe_user_match\/\S+/, { statusCode: 200, body: { ok: true } });
|
|
const currentUser = makeFakeUser({
|
|
email: 'sam@example.com'
|
|
});
|
|
cy.stubAuthenticate({ ...currentUser });
|
|
cy.intercept('POST', /\S+\/unsubscribe\/\S+/, { statusCode: 200, body: { ok: true } });
|
|
})
|
|
|
|
it("redirect to home page if tok is not provided", () => {
|
|
cy.visit('/unsubscribe');
|
|
cy.location('pathname').should('eq', '/errors/404');
|
|
});
|
|
|
|
it("show unsubscribed message", () => {
|
|
cy.visit('/unsubscribe/123');
|
|
// cy.location('search')
|
|
// .should('equal', '?tok=123')
|
|
// .then((s) => new URLSearchParams(s))
|
|
// .invoke('get', 'tok')
|
|
// .should('equal', '123')
|
|
cy.contains("You have successfully unsubscribed from JamKazam emails.").should('be.visible');
|
|
cy.contains("Loading...").should('not.exist');
|
|
});
|
|
|
|
}) |