Skip to content

Commit 669eaf6

Browse files
authored
Merge pull request #666 from mpourismaiel/chore/tests/write-more-tests
Add more tests
2 parents 2a2901a + 9a4d868 commit 669eaf6

File tree

6 files changed

+70
-7
lines changed

6 files changed

+70
-7
lines changed

cypress/fixtures/contact.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "John Doe",
3+
"email": "[email protected]",
4+
"message": "Lorem ipsum dolor sit amet",
5+
"phone": "0"
6+
}

cypress/fixtures/example.json

-5
This file was deleted.

cypress/integration/events.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
describe("Events", () => {
2+
beforeEach(() => {
3+
cy.visit("/dev/events/payment//");
4+
});
5+
6+
it("should focus stripe form when stripe event is fired", () => {
7+
cy.get(
8+
"a[href='/dev/events/payment?event=pricing:change&product=Starting%20plan&price=$9.99/mo&currency=usd']"
9+
).click();
10+
cy.get("#stripe input[name=email]").should("focused", true);
11+
cy.get("#stripe .price-display .btn-group label")
12+
.should("have.length", 1)
13+
.should("contain", "$9.99/mo");
14+
});
15+
16+
it("should focus contact form when contact event is fired", () => {
17+
cy.get(
18+
"a[href='/dev/events/payment?e=P2V2ZW50PWNvbnRhY3Q6dXBkYXRlJm1lc3NhZ2U9VGl0bGU6IExldCdzIG5lZ290aWF0ZQpQbGFuOiBFbnRlcnByaXNlIHBsYW4KWW91ciBtZXNzYWdlOgo=']"
19+
).click();
20+
cy.get("#contact input[name=name]").should("focused", true);
21+
cy.get("#contact textarea[name=message]").should(
22+
"contain",
23+
`Title: Let's negotiate
24+
Plan: Enterprise plan
25+
Your message:
26+
`
27+
);
28+
});
29+
});
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
describe("Form errors", () => {
2+
beforeEach(() => {
3+
cy.visit("/fragments/contact/");
4+
});
5+
6+
it("should not be displayed by default", () => {
7+
cy.get("#contact .form-group .has-error").should("have.length", 0);
8+
});
9+
10+
it("should be displayed if field is touched", () => {
11+
cy.get("#contact .form-group input[name=name]").focus()
12+
cy.get("#contact .form-group .has-error").should("have.length", 1);
13+
});
14+
15+
it("should be not be displayed if field is touched but filled with valid information", () => {
16+
cy.fixture('contact').then(({name}) => cy.get("#contact .form-group input[name=name]").type(name));
17+
cy.get("#contact .form-group .has-error").should("have.length", 0);
18+
});
19+
20+
it("should all be displayed if all inputs are touched", () => {
21+
cy.get("#contact .form-group input, #contact .form-group textarea").each((node, i) => setTimeout(() => node.focus(), i * 250));
22+
cy.get("#contact .form-group .has-error").should("have.length", 4);
23+
});
24+
25+
it("should not be displayed if all fields are touched but filled with valid information", () => {
26+
cy.fixture('contact').then(fields =>
27+
Object.keys(fields).forEach(field =>
28+
cy.get(`#contact .form-group ${field === 'message' ? 'textarea' : 'input'}[name=${field}]`).type(fields[field])
29+
)
30+
);
31+
cy.get("#contact .form-group .has-error").should("have.length", 0);
32+
});
33+
});

exampleSite/resources/_gen/assets/scss/styles/index.scss_a4e369375f17bb89f2019364cbe7a830.content

+1-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"Target":"style.min.186bc2691b3b0267fb7a27723217f3b96c3c44739751202d136f9460f847ac6f.css","MediaType":"text/css","Data":{"Integrity":"sha256-GGvCaRs7Amf7eidyMhfzuWw8RHOXUSAtE2+UYPhHrG8="}}
1+
{"Target":"style.min.186bc2691b3b0267fb7a27723217f3b96c3c44739751202d136f9460f847ac6f.css","MediaType":"text/css","Data":{"Integrity":"sha256-GGvCaRs7Amf7eidyMhfzuWw8RHOXUSAtE2+UYPhHrG8="}}

0 commit comments

Comments
 (0)