Skip to content

Commit 8cb8a39

Browse files
TheZokeredgarmueller
authored andcommitted
Add cypress tests
1 parent 21f5116 commit 8cb8a39

File tree

7 files changed

+2035
-925
lines changed

7 files changed

+2035
-925
lines changed

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sudo: required
2+
3+
language: node_js
4+
5+
node_js:
6+
- 'node'
7+
8+
cache: npm
9+
10+
before_install:
11+
- npm update
12+
13+
install:
14+
- npm ci
15+
16+
script:
17+
- npm run test-cypress

cypress.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cypress/integration/test_form.spec.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/// <reference types="Cypress" />
2+
3+
context('Form', () => {
4+
5+
beforeEach(() => {
6+
cy.visit('http://localhost:3000/')
7+
})
8+
9+
it('should change input values', () => {
10+
const nameText = 'John Deer';
11+
cy.get('[id="#/properties/name-input"]').clear().type(nameText);
12+
13+
const descText = 'This is a desc test';
14+
cy.get('[id="#/properties/description-input"]').clear().type(descText);
15+
16+
cy.get('[id="#/properties/done-input"]').uncheck();
17+
18+
cy.get('[id="#/properties/recurrence"] > div').click();
19+
cy.get('[data-value="Monthly"]').click();
20+
21+
const recurrenceIntervalText = 10;
22+
cy.get('[id="#/properties/recurrence_interval-input"]').clear().type(recurrenceIntervalText);
23+
24+
cy.get('[id="#/properties/due_date-input"]').clear().type('35');
25+
26+
cy.get('[id="#/properties/rating"] span:last').click();
27+
28+
cy.get('[id="boundData"]').invoke('text').then((content => {
29+
const data = JSON.parse(content);
30+
31+
expect(data.name).to.equal(nameText);
32+
cy.get('[id="#/properties/name"] p').should('be.empty')
33+
34+
cy.get('[id="#/properties/recurrence_interval"]').should('exist')
35+
36+
expect(data.description).to.equal(descText);
37+
expect(data.done).to.equal(false);
38+
expect(data.recurrence).to.equal('Monthly');
39+
expect(data.recurrence_interval).to.equal(recurrenceIntervalText);
40+
expect(data.due_date).to.equal('2001-03-15');
41+
expect(data.rating).to.equal(5);
42+
}));
43+
});
44+
45+
it('should show errors', () => {
46+
cy.get('[id="#/properties/name-input"]').clear();
47+
48+
cy.get('[id="#/properties/name"] p').should('not.be.empty');
49+
50+
cy.get('[id="#/properties/due_date-input"]').clear().type('351');
51+
52+
cy.get('[id="#/properties/due_date"] p').should('not.be.empty');
53+
54+
cy.get('[id="#/properties/recurrence"] > div').click();
55+
cy.get('[data-value="Never"]').click();
56+
57+
cy.get('[id="#/properties/recurrence_interval"]').should('not.exist')
58+
59+
cy.get('[id="boundData"]').invoke('text').then((content => {
60+
const data = JSON.parse(content);
61+
62+
expect(data.due_date).to.equal('Invalid date');
63+
}));
64+
});
65+
})

0 commit comments

Comments
 (0)