Skip to content

Commit

Permalink
fix: add imports from cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jun 10, 2024
1 parent 67e2cb3 commit 6418fb7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
7 changes: 2 additions & 5 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { defineConfig } from 'cypress'
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
},
})
});
53 changes: 29 additions & 24 deletions cypress/e2e/test_form.cy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/// <reference types="Cypress" />

context('Form', () => {
import { describe, beforeEach, cy, it, expect } from 'cypress';

describe('Form', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/')
})
cy.visit('http://localhost:3000/');
});

it('should change input values', () => {
const nameText = 'John Deer';
Expand All @@ -17,24 +16,28 @@ context('Form', () => {
cy.get('[id="#/properties/done-input"]').uncheck();
cy.get('[id="#/properties/recurrence"] > div').click();
cy.get('[data-value="Monthly"]').click();
cy.get('[id="#/properties/recurrence_interval-input"]').clear().type(recurrenceIntervalText);
cy.get('[id="#/properties/recurrence_interval-input"]')
.clear()
.type(recurrenceIntervalText);
cy.get('[id="#/properties/due_date-input"]').clear().type(dateText);
cy.get('[id="#/properties/rating"] span:last').click();
cy.get('[id="boundData"]').invoke('text').then((content => {
const data = JSON.parse(content);
cy.get('[id="boundData"]')
.invoke('text')
.then(content => {
const data = JSON.parse(content);

expect(data.name).to.equal(nameText);
cy.get('[id="#/properties/name"] p').should('be.empty')
expect(data.name).to.equal(nameText);
cy.get('[id="#/properties/name"] p').should('be.empty');

cy.get('[id="#/properties/recurrence_interval"]').should('exist')
cy.get('[id="#/properties/recurrence_interval"]').should('exist');

expect(data.description).to.equal(descText);
expect(data.done).to.equal(false);
expect(data.recurrence).to.equal('Monthly');
expect(data.recurrence_interval).to.equal(recurrenceIntervalText);
expect(data.due_date).to.equal(dateText);
expect(data.rating).to.equal(5);
}));
expect(data.description).to.equal(descText);
expect(data.done).to.equal(false);
expect(data.recurrence).to.equal('Monthly');
expect(data.recurrence_interval).to.equal(recurrenceIntervalText);
expect(data.due_date).to.equal(dateText);
expect(data.rating).to.equal(5);
});
});

it('should show errors', () => {
Expand All @@ -49,12 +52,14 @@ context('Form', () => {
cy.get('[id="#/properties/recurrence"] > div').click();
cy.get('[data-value="Never"]').click();

cy.get('[id="#/properties/recurrence_interval"]').should('not.exist')
cy.get('[id="#/properties/recurrence_interval"]').should('not.exist');

cy.get('[id="boundData"]').invoke('text').then((content => {
const data = JSON.parse(content);
cy.get('[id="boundData"]')
.invoke('text')
.then(content => {
const data = JSON.parse(content);

expect(data.due_date).to.equal('Invalid date');
}));
expect(data.due_date).to.equal('Invalid date');
});
});
})
});

0 comments on commit 6418fb7

Please sign in to comment.