-
Notifications
You must be signed in to change notification settings - Fork 34
132 cypress test for contact us form #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tausifqureshi786
wants to merge
3
commits into
TechIsHiring:dev
Choose a base branch
from
Tausifqureshi786:132-cypress-test-for-contact-us-form
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,65 @@ | ||
|
|
||
| import ContactForm from "../../src/components/molecules/contact-form/contact-form" | ||
|
|
||
| describe('Checks the Contact Us component for accepting three cases of inputs', () => { | ||
| beforeEach(()=> { | ||
| cy.mount(<ContactForm />) | ||
| // input text field for name | ||
| cy.get('[data-cy="name-input"]').as('nameInputTextField') | ||
|
|
||
| // input text element for email | ||
| cy.get('[data-cy="email-input"]').as('emailInputTextField') | ||
| 'data-cy="note-input"' | ||
|
|
||
| // input element for message | ||
| cy.get('[data-cy="note-input"]').as('messageEmailTextArea') | ||
|
|
||
| // button element | ||
| cy.get('[data-cy="send-msg-btn"]').as('sendMessageBtn') | ||
|
|
||
| }) | ||
|
|
||
| it('Case 1: Show error messages in a new span element when no text is provided in name, email and message inputs in the component', ()=> { | ||
| cy.get('@nameInputTextField').clear() | ||
| cy.get('@emailInputTextField').clear() | ||
| cy.get('@messageEmailTextArea').clear() | ||
|
|
||
| cy.get('@sendMessageBtn').click() | ||
|
|
||
| cy.get('[data-cy="name-error-msg"]').contains('Please add a name') | ||
| cy.get('[data-cy="email-error-msg"]').contains('Please add a proper email address') | ||
| cy.get('[data-cy="note-error-msg"]').contains('Please add a message') | ||
| }) | ||
|
|
||
| it("Case 2 : Show the success message after proper inputs for name, email and message inputs are provided", () => { | ||
| cy.fixture('example').as('exampleInput') | ||
| cy.get('@nameInputTextField').type('Tausif Qureshi') | ||
| cy.get('@emailInputTextField').type('tausif2606@gmail.com') | ||
| cy.get('@messageEmailTextArea').type('Hello tech is hiring!') | ||
|
|
||
| cy.intercept('POST','/api/process-email', (req) => { | ||
| const statusCode = 200 | ||
| req.reply(statusCode, {data:"Email sent"}) | ||
|
|
||
| }) | ||
| cy.get('@sendMessageBtn').click() | ||
|
|
||
| cy.get('[data-cy="email-sent-title"]').contains('Thank you for your feedback!') | ||
| cy.get('[data-cy="email-sent-msg"]').contains('We will get back to you as soon as possible!') | ||
|
|
||
| }) | ||
|
|
||
| it("Case 3: Show error under the name and message field ", ()=> { | ||
| cy.get('@nameInputTextField').clear() | ||
| cy.get('@emailInputTextField').type('tausif2606@gmail.com') | ||
| cy.get('@messageEmailTextArea').clear() | ||
|
|
||
| cy.get('@sendMessageBtn').click() | ||
|
|
||
| cy.get('[data-cy="name-error-msg"]').contains('Please add a name') | ||
| cy.get('[data-cy="note-error-msg"]').contains('Please add a message') | ||
|
|
||
| }) | ||
|
|
||
|
|
||
| }) | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.