-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
19 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
Binary file added
BIN
+5.24 KB
e2e/cypress/e2e/__image_snapshots__/Newsletter page matches visually #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
describe('Newsletter page', () => { | ||
beforeEach(() => { | ||
cy.visit('/newsletter'); | ||
}); | ||
|
||
it('displays content', function () { | ||
cy.contains('Newsletter'); | ||
cy.contains('First Name'); | ||
cy.contains('Last Name'); | ||
cy.contains('Email'); | ||
cy.contains('Organization'); | ||
cy.contains('Country'); | ||
}); | ||
|
||
it('matches visually', function () { | ||
cy.matchImage(); | ||
}); | ||
|
||
it.only('can submit form', function () { | ||
cy.intercept('https://api.db-ip.com/v2/free/self', { | ||
body: { | ||
ipAddress: '85.34.21.23' | ||
} | ||
}); | ||
cy.contains('Sign up').click(); | ||
cy.get('.rrt-text').should('have.text', 'Fill all the required fields'); | ||
cy.get('input[name=first_name] ~ .error').should('have.text', 'The field is required'); | ||
cy.get('input[name=last_name] ~ .error').should('have.text', 'The field is required'); | ||
cy.get('input[name=email] ~ .error').should('have.text', 'The field is requiredThe field should be a valid email address'); | ||
cy.get('input[name=organization] ~ .error').should('have.text', 'The field is required'); | ||
cy.get('#select-country ~ .error').should('have.text', 'The field is required'); | ||
|
||
cy.get('input[name=first_name]').type('John'); | ||
cy.get('input[name=last_name]').type('Example'); | ||
cy.get('input[name=email]').type('[email protected]'); | ||
cy.get('input[name=organization]').type('Example Inc'); | ||
cy.selectOption('[name=country]', 'Po', 'Poland'); | ||
|
||
cy.intercept('POST', 'https://ortto.wri.org/custom-forms', (req) => { | ||
const formData = new URLSearchParams(req.body); | ||
|
||
expect(formData.get('website')).to.equal('opentimberportal.org'); | ||
expect(formData.get('form-name')).to.equal('Open Timber Portal Newsletter Signup'); | ||
expect(formData.get('list')).to.equal('FOR - OTP - Open Timber Portal Newsletter – LIST'); | ||
expect(formData.get('interests')).to.equal('Forests'); | ||
expect(formData.get('preferred_language')).to.equal('en'); | ||
expect(formData.get('ip_addr')).to.equal('85.34.21.23'); | ||
expect(formData.get('first_name')).to.equal('John'); | ||
expect(formData.get('last_name')).to.equal('Example'); | ||
expect(formData.get('email')).to.equal('[email protected]'); | ||
expect(formData.get('organization')).to.equal('Example Inc'); | ||
expect(formData.get('country')).to.equal('Poland'); | ||
|
||
req.reply({ statusCode: 302, headers: { location: 'http://localhost:4000/newsletter/thank-you' } }); | ||
}).as('submitForm'); | ||
|
||
cy.get('button').contains('Sign up').click(); | ||
cy.wait('@submitForm'); | ||
cy.contains('You are now signed up to receive updates from the Open Timber Portal.'); | ||
}); | ||
}) |
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