Skip to content

Commit

Permalink
Improve tests (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr authored Mar 18, 2024
2 parents 8747d42 + 0af3e96 commit 56a0aeb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 36 deletions.
4 changes: 1 addition & 3 deletions src/client/cypress/e2e/editor/backfill.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe("Backfill crud tests", () => {

it("adds, edits and deletes backfills", () => {
// add new backfill card
cy.wait(1000);
addItem("addBackfill");
cy.wait("@codelist_GET");

Expand Down Expand Up @@ -96,7 +95,6 @@ describe("Backfill crud tests", () => {
});

it("sorts backfill", () => {
cy.wait(1000);
addItem("addBackfill");
cy.wait("@codelist_GET");
setInput("notes", "Lorem.");
Expand All @@ -107,7 +105,7 @@ describe("Backfill crud tests", () => {
setSelect("casingId", 3);
saveForm();

cy.wait(1000);
cy.wait(500);
addItem("addBackfill");
cy.wait("@codelist_GET");
setInput("notes", "Lorem.");
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/casing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("Casing crud tests", () => {
cy.get("[data-cy=completion-content-tab-instrumentation]").click();
cy.wait("@instrumentation_GET");

cy.wait(1000);
cy.wait(500);
addItem("addInstrument");
cy.wait("@casing_GET");

Expand Down
47 changes: 26 additions & 21 deletions src/client/cypress/e2e/editor/completion.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createBorehole, startBoreholeEditing, loginAsAdmin, handlePrompt } from "../helpers/testHelpers";
import {
createBorehole,
createCompletion,
startBoreholeEditing,
loginAsAdmin,
handlePrompt,
} from "../helpers/testHelpers";
import {
setInput,
evaluateInput,
Expand All @@ -22,7 +28,6 @@ const toggleHeaderOpen = () => {
};

const addCompletion = () => {
cy.wait(500);
addItem("addCompletion");
cy.wait("@codelist_GET");
};
Expand Down Expand Up @@ -382,24 +387,24 @@ describe("completion crud tests", () => {
});

it("checks completion content validation", () => {
createBorehole({ "extended.original_name": "INTEADAL" }).as("borehole_id");
createBorehole({ "extended.original_name": "INTEADAL" })
.as("borehole_id")
.then(id => createCompletion("Compl-1", id, 16000001, true))
.then(response => {
expect(response).to.be.above(0);
});

// open completion editor
cy.get("@borehole_id").then(id => {
loginAsAdmin();
cy.visit(`/editor/${id}/completion`);
});
cy.wait("@get-completions-by-boreholeId");
cy.contains("No completion available");

// start editing session
startBoreholeEditing();

addCompletion();
setInput("name", "Compl-1");
setSelect("kindId", 1);
saveChanges();

// cancel switching content tabs
cy.wait(1000);
addItem("addCasing");
cy.wait("@codelist_GET");
setInput("name", "casing 1", "casing-card.0.edit");
Expand All @@ -419,7 +424,7 @@ describe("completion crud tests", () => {
cy.get('[data-cy="casing-card.0"]').should("not.exist");

// save when switching content tabs
cy.wait(1000);
cy.wait(500);
addItem("addCasing");
cy.wait("@codelist_GET");
setInput("name", "casing 1", "casing-card.0.edit");
Expand All @@ -435,7 +440,7 @@ describe("completion crud tests", () => {
// cancel switching header tabs when content changes are present
setContentTab("backfill");
cy.wait("@backfill_GET");
cy.wait(1000);
cy.wait(500);
addItem("addBackfill");
cy.wait("@casing_GET");
setInput("fromDepth", 0);
Expand All @@ -458,7 +463,7 @@ describe("completion crud tests", () => {
cy.get('[data-cy="backfill-card.0"]').should("not.exist");

// save content changes when switching header tabs
cy.wait(1000);
cy.wait(500);
addItem("addBackfill");
cy.wait("@casing_GET");
setInput("fromDepth", 0);
Expand All @@ -476,7 +481,7 @@ describe("completion crud tests", () => {
// cancel header changes, no prompt should be displayed for content changes because tab switching was already canceled
setContentTab("instrumentation");
cy.wait("@instrumentation_GET");
cy.wait(1000);
cy.wait(500);
addItem("addInstrument");
cy.wait("@casing_GET");
setInput("fromDepth", "0");
Expand All @@ -499,7 +504,7 @@ describe("completion crud tests", () => {
// reset header changes, cancel content changes
addCompletion();
handlePrompt("Completion: Unsaved changes", "Reset");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Cancel");
isHeaderTabSelected(0);
isContentTabSelected("instrumentation");
Expand All @@ -512,7 +517,7 @@ describe("completion crud tests", () => {
setInput("name", "Compl-1 updated", "completion-header");
addCompletion();
handlePrompt("Completion: Unsaved changes", "Reset");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Reset");
isHeaderTabSelected(1);
setHeaderTab(0);
Expand All @@ -522,7 +527,7 @@ describe("completion crud tests", () => {
cy.get('[data-cy="instrumentation-card.0"]').should("not.exist");

//reset header changes, save content changes
cy.wait(1000);
cy.wait(500);
addItem("addInstrument");
cy.wait("@casing_GET");
setInput("fromDepth", "0");
Expand All @@ -534,7 +539,7 @@ describe("completion crud tests", () => {
setInput("name", "Compl-1 updated", "completion-header");
addCompletion();
handlePrompt("Completion: Unsaved changes", "Reset");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Save");
isHeaderTabSelected(1);
setHeaderTab(0);
Expand All @@ -549,7 +554,7 @@ describe("completion crud tests", () => {
setInput("name", "Compl-1 updated", "completion-header");
addCompletion();
handlePrompt("Completion: Unsaved changes", "Save");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Cancel");
isHeaderTabSelected(0);
isContentTabSelected("instrumentation");
Expand All @@ -561,7 +566,7 @@ describe("completion crud tests", () => {
setInput("name", "Compl-1 updated again", "completion-header");
addCompletion();
handlePrompt("Completion: Unsaved changes", "Save");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Reset");
isHeaderTabSelected(1);
setHeaderTab(0);
Expand All @@ -577,7 +582,7 @@ describe("completion crud tests", () => {
setInput("name", "Compl-1 updated again and again", "completion-header");
addCompletion();
handlePrompt("Completion: Unsaved changes", "Save");
cy.wait(1000);
cy.wait(500);
handlePrompt("Instrumentation: Unsaved changes", "Save");
isHeaderTabSelected(1);
setHeaderTab(0);
Expand Down
7 changes: 2 additions & 5 deletions src/client/cypress/e2e/editor/fieldMeasurement.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ describe("Tests for the field measurement editor.", () => {
createCasing("casing-1", id, completionId, "2021-01-01", "2021-01-02", [
{ fromDepth: 0, toDepth: 10, kindId: 25000103 },
]);
createCasing("casing-2", id, completionId, "2021-01-03", "2021-01-04", [
{ fromDepth: 5, toDepth: 12, kindId: 25000105 },
]);
}),
)
.then(response => {
Expand All @@ -43,8 +40,8 @@ describe("Tests for the field measurement editor.", () => {
cy.get('[data-cy="menu"]').click({ force: true });
cy.contains("span", "DE").click({ force: true });

cy.wait(1000);
// create field measurement
cy.wait(500);
addItem("addFieldMeasurement");
cy.wait("@casing_GET");

Expand Down Expand Up @@ -96,7 +93,7 @@ describe("Tests for the field measurement editor.", () => {
saveForm();
cy.wait("@fieldmeasurement_GET");

cy.wait(1000);
cy.wait(500);
addItem("addFieldMeasurement");
cy.wait("@casing_GET");
setInput("fromDepthM", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe("Tests for the groundwater level measurement editor.", () => {
cy.get('[data-cy="menu"]').click({ force: true });
cy.contains("span", "DE").click({ force: true });

cy.wait(1000);
// create groundwater level measurement
addItem("addGroundwaterLevelMeasurement");
cy.wait("@casing_GET");
Expand Down Expand Up @@ -96,7 +95,7 @@ describe("Tests for the groundwater level measurement editor.", () => {
saveForm();
cy.wait("@groundwaterlevelmeasurement_GET");

cy.wait(1000);
cy.wait(500);
addItem("addGroundwaterLevelMeasurement");
cy.wait("@casing_GET");
setInput("fromDepthM", 0);
Expand Down
3 changes: 1 addition & 2 deletions src/client/cypress/e2e/editor/hydrotest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe("Tests for the hydrotest editor.", () => {
cy.get('[data-cy="menu"]').click({ force: true });
cy.contains("span", "DE").click({ force: true });

cy.wait(1000);
// create hydrotest
addItem("addHydrotest");
cy.wait("@casing_GET");
Expand Down Expand Up @@ -128,7 +127,7 @@ describe("Tests for the hydrotest editor.", () => {
saveForm();
cy.wait("@hydrotest_GET");

cy.wait(1000);
cy.wait(500);
addItem("addHydrotest");
cy.wait("@casing_GET");
setInput("fromDepthM", 0);
Expand Down
3 changes: 1 addition & 2 deletions src/client/cypress/e2e/editor/waterIngress.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe("Tests for the wateringress editor.", () => {
cy.get('[data-cy="menu"]').click({ force: true });
cy.contains("span", "DE").click({ force: true });

cy.wait(1000);
// create wateringress
addItem("addWaterIngress");
cy.wait("@casing_GET");
Expand Down Expand Up @@ -98,7 +97,7 @@ describe("Tests for the wateringress editor.", () => {
saveForm();
cy.wait("@wateringress_GET");

cy.wait(1000);
cy.wait(500);
addItem("addWaterIngress");
cy.wait("@casing_GET");
setInput("fromDepthM", 0);
Expand Down

0 comments on commit 56a0aeb

Please sign in to comment.