-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to prevent invalid email from unsubscribing
- Loading branch information
1 parent
0bc4fa9
commit 87050ef
Showing
1 changed file
with
24 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
describe('Unsubscribe form', () => { | ||
let shortcodePostURL; | ||
let blockPostPostURL; | ||
const testEmail = '[email protected]'; | ||
|
||
before(() => { | ||
// TODO: Initialize tests from a blank state | ||
|
@@ -34,6 +33,8 @@ describe('Unsubscribe form', () => { | |
}) | ||
|
||
it('unsubscribes valid emails that were previously subscribed to a list', () => { | ||
const testEmail = '[email protected]'; | ||
|
||
[shortcodePostURL, blockPostPostURL].forEach((url) => { | ||
let baseUrl; | ||
|
||
|
@@ -78,11 +79,28 @@ describe('Unsubscribe form', () => { | |
}); | ||
|
||
it('throws an error when unsubscribing an email that was never subscribed to a list', () => { | ||
// Visit the mailchimp block page | ||
// Assert unsubscribe link exists | ||
// Visit unsubscribe link | ||
// Unsubscribe | ||
// Assert that the unsubscribe didn't work because the email isn't subscribed | ||
const testEmail = '[email protected]'; | ||
|
||
[shortcodePostURL, blockPostPostURL].forEach((url) => { | ||
// Visit the mailchimp block page | ||
cy.visit(url); | ||
|
||
// Assert unsubscribe link exists | ||
cy.get('a[href*="/unsubscribe"]').should('exist'); | ||
|
||
// Visit unsubscribe link | ||
cy.get('a[href*="/unsubscribe"]') | ||
.invoke('removeAttr', 'target') // Prevent opening in new window so that Cypress can test | ||
.click(); | ||
|
||
// Unsubscribe | ||
cy.get('#email-address').type(testEmail); | ||
cy.get('input[type="submit"]').click(); | ||
|
||
// Assert that the unsubscribe didn't work because the email isn't subscribed | ||
cy.get('.errorText').should('contain', 'this email is not subscribed'); | ||
|
||
}); | ||
}); | ||
|
||
it('does not display an unsubscribe link when the unsubscribe option is disabled', () => { | ||
|