Skip to content

Commit

Permalink
feat(EditLocationE2E): add e2e tests for view,edit,delete location us…
Browse files Browse the repository at this point in the history
…erflows
  • Loading branch information
antekai committed Oct 21, 2018
1 parent 8b84f64 commit 299e047
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"baseUrl": "http://localhost:3000"
"baseUrl": "http://localhost:3000",
"projectId": "83ffh1"
}
69 changes: 68 additions & 1 deletion cypress/integration/EditLocation.spec.js
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
describe("User edit or remove location", () => {});
describe("User view, edit, remove location", () => {
beforeEach(() => {
cy.visit("");
});

it("views and deletes location", () => {
cy.contains("Load mockData").click();
cy.get("#0 .ant-card-head-title").should(
"have.text",
"Charite Virchow Klinikum"
);
cy.get("[data-icon=delete]:first").click();
cy.contains("Charite Virchow Klinikum").should("not.exist");
});

it("deletes all locations", () => {
cy.contains("RemoveAll")
.wait(500)
.click();
cy.contains("Latitude").should("not.exist");
});

it("displays error for empty fields", () => {
cy.get("[data-icon=edit]")
.eq(1)
.click();
cy.get("#1 input#name").clear();
cy.contains("Please enter name").should("exist");
cy.get("#1 input#lat").clear();
cy.contains("Please add latitude!").should("exist");
cy.get("#1 input#lon").clear();
cy.contains("Please add longitude!").should("exist");
});

it("displays error for invalid input", () => {
cy.get("[data-icon=edit]:first").click();
cy.get("#0 input#name")
.clear()
.type("!#$%");
cy.contains("Invalid name").should("exist");
cy.get("#0 input#lat")
.clear()
.type("49");
cy.contains("Invalid latitude format").should("exist");
cy.get("#0 input#lon")
.clear()
.type("243.6");
cy.contains("Invalid longitude format").should("exist");
});

it("edits a (valid) location", () => {
cy.get("[data-icon=edit]:first").click();
cy.get("#0 input#name")
.clear()
.type("cypLoc");
cy.get("#0 input#lat")
.clear()
.type("49.9999");
cy.get("#0 input#lon")
.clear()
.type("11.9999");
cy.get("[data-icon=check]:first").click({ force: true });
cy.get("#0").should(
"have.text",
"cypLocLatitude: 49.9999Longitude: 11.9999"
);
});
});
8 changes: 4 additions & 4 deletions cypress/integration/NewLocation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("User adds new location", () => {
.type("11.1111");
});

it("Validation check: Empty fields", () => {
it("displays error for empty fields", () => {
cy.get("@name").clear();
cy.contains(`Location's name is required`);
cy.get("@lat").clear();
Expand All @@ -25,7 +25,7 @@ describe("User adds new location", () => {
cy.contains(`longitude is required`);
});

it("Validation check: Invalid input", () => {
it("displays error for invalid input", () => {
cy.get("@name")
.clear()
.type("%^*(");
Expand All @@ -40,12 +40,12 @@ describe("User adds new location", () => {
cy.contains(`invalid longitude`);
});

it("New Location (valid) is saved", () => {
it("saves New Location", () => {
cy.contains("span", "Submit").click({ force: true });
cy.contains("CypressHaus");
cy.contains("SaveToFirebase").click();
cy.reload(true);
cy.contains("CypressHaus");
cy.get(`[title=CypressHaus]`).should("have.attr", "coords");
cy.get(`[title=CypressHaus]`).should("have.attr", "coords"); //check if location google marker exists
});
});
Binary file added cypress/videos/EditLocation.spec.js.mp4
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"cy:open": "cypress open",
"cy:run": "cypress run --spec cypress/integration/EditLocation.spec.js",
"eject": "react-scripts eject",
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release",
Expand Down

0 comments on commit 299e047

Please sign in to comment.