Created
August 4, 2016 19:00
-
-
Save brian-mann/646954178f03592c127103005828c8b0 to your computer and use it in GitHub Desktop.
piechopper failing test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe("PieChopper", function(){ | |
| beforeEach(function(){ | |
| // visit our local server running the application | |
| // | |
| // visiting before each test ensures the app | |
| // gets reset to a clean state | |
| // | |
| // https://on.cypress.io/api/visit | |
| cy.visit("http://localhost:8080") | |
| }) | |
| context("How do you contribute?", function(){ | |
| beforeEach(function(){ | |
| cy.get("#contrib-section").as("contrib") | |
| }) | |
| // the form changes based on which algorithm | |
| // has been selected with 'Company Roles' being the default | |
| describe("Market Value", function(){ | |
| beforeEach(function(){ | |
| // swap to market value | |
| cy.get(".carousel-control.right").click() | |
| }) | |
| it("validates input and displays errors", function(){ | |
| cy.contains("tr", "What is the sales commission percent that is usually paid on the market?").within(function(){ | |
| cy | |
| .get("td:eq(1) input").type(500) | |
| .parent().should("have.class", "invalid") | |
| .find(".cell-error-msg").should("contain", "Value must be smaller than 100") | |
| }) | |
| cy.get("#results-section").should("contain", "Your input seems to contain errors.") | |
| }) | |
| }) | |
| }) | |
| context("Sharing Results", function(){ | |
| beforeEach(function(){ | |
| // We want to start a server before each test | |
| // to control nerwork requests and responses | |
| // https://on.cypress.io/api/server | |
| cy.server() | |
| }) | |
| // simulate the server failing to respond to the share proposal | |
| it("displays error message in modal when server errors", function(){ | |
| // https://on.cypress.io/api/route | |
| cy | |
| .route({ | |
| method: "POST", | |
| url: /proposals/, | |
| status: 500, | |
| response: "" | |
| }).as("proposal") | |
| .get("#results-section").contains("Share").click() | |
| // https://on.cypress.io/api/wait | |
| .wait("@proposal") | |
| .get(".modal").should("contain", "We couldn't save the proposal.") | |
| .find("h2").should("contain", "Ooops !") | |
| // after we click on the backdrop the modal should go away | |
| .get(".modal-backdrop").click().should("not.exist") | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment