|
| 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