Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit e139cc6

Browse files
committed
feat(cypress tests): fix contact tests
1 parent 50d7f6b commit e139cc6

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

cypress/integration/app-contact.spec.js

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
describe('Contact Page', function () {
2+
var env = 'https://openforge.io';
23
beforeEach(() => {
3-
cy.visit('localhost:3333/contact')
4+
cy.visit( env + '/contact')
45
cy.get('button[type=submit]').as('submitBtn')
56
})
67

@@ -25,60 +26,44 @@ describe('Contact Page', function () {
2526
.find('.btn')
2627
.should('exist')
2728
.and('be.visible')
28-
.and('contain', 'Request Now')
29+
.and('contain', 'Request Free Quote')
2930
.click()
3031
cy.get('#second-content').click()
3132
})
3233
})
3334

3435
describe('Contact Form', function() {
35-
let nameField;
36-
let emailField;
37-
let companyField;
38-
let phoneField;
39-
let messageField;
40-
let radioField1;
41-
let radioField2;
36+
let nameField
37+
let emailField
38+
let phoneField
39+
let messageField
4240

4341
describe('Successful form submission', function () {
4442
beforeEach(() => {
45-
nameField = cy.get('input[name=name]')
46-
.type('Test Name')
47-
emailField = cy.get('input[name=email]')
48-
.type('testEmail@gmail.com')
49-
companyField = cy.get('input[name=company]')
50-
.type('Test Company Name')
51-
phoneField = cy.get('input[name=phone]')
52-
.type('1459341234')
53-
messageField = cy.get('input[name=message]')
54-
.type('This is a test message')
55-
radioField1 = cy.get('[type="radio"]')
56-
.check('Web Development')
57-
radioField2 = cy.get('[type="radio"]')
58-
.check('200K')
43+
cy.get('input[name=name]').type('Testing')
44+
cy.get('input[name=email]').type('testEmail@gmail.com')
45+
cy.get('input[name=phone]').type('1459341234')
46+
cy.get('input[name=message]').type('This is a test message')
5947
cy.get('@submitBtn').click()
6048
})
6149

6250
it('Should show a success message on submit when all form values have been filled out', function() {
63-
cy.get('div.alert')
64-
.should('exist')
65-
.contains('Thank you')
51+
cy.contains('Thank you')
6652
})
6753

6854
it('All fields should be clear after successful form submission', function() {
69-
nameField.should('have.value', '')
70-
emailField.should('have.value', '')
71-
companyField.should('have.value', '')
72-
phoneField.should('have.value', '')
73-
messageField.should('have.value', '')
55+
cy.get('input[name=name]').should('not.have.value', 'Testing')
56+
cy.get('input[name=email]').should('not.have.value', 'testEmail@gmail.com')
57+
cy.get('input[name=phone]').should('not.have.value', '1459341234')
58+
cy.get('input[name=message]').should('not.have.value', 'This is a test message')
59+
7460
})
7561
})
7662
describe('Unsucessful form submission', function() {
7763
it('DOM should not show success message when all fields of the form are not filled out', function () {
7864
nameField = cy.get('input[name=name]')
7965
.type('Test Name')
80-
cy.get('@submitBtn').click()
81-
cy.get('div.alert').should('not.exist')
66+
cy.get('@submitBtn').should('be.disabled')
8267
})
8368
})
8469
})

0 commit comments

Comments
 (0)