Skip to content

Commit

Permalink
Merge branch 'main' into disable-borehole-inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats authored Jan 24, 2024
2 parents 6c026db + 6961003 commit 9070f4b
Show file tree
Hide file tree
Showing 48 changed files with 1,128 additions and 1,514 deletions.
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/admin/aboutSettings.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin } from "../testHelpers";
import { loginAsAdmin } from "../helpers/testHelpers";
import license from "../../fixtures/license.json";

describe("Admin about page tests", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/admin/loginScreen.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin } from "../testHelpers";
import { loginAsAdmin } from "../helpers/testHelpers";

describe("Admin login preview tests", () => {
it("displays correct message when publishing a new welcome message.", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/admin/userAdministration.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin } from "../testHelpers";
import { loginAsAdmin } from "../helpers/testHelpers";

describe("Admin settings test", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/app.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin, loginAsEditorInViewerMode } from "./testHelpers";
import { loginAsAdmin, loginAsEditorInViewerMode } from "./helpers/testHelpers";

describe("General app tests", () => {
it("Displays the login page in the correct language", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/boreholeList.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin, loginAsEditorInViewerMode } from "../e2e/testHelpers";
import { loginAsAdmin, loginAsEditorInViewerMode } from "../e2e/helpers/testHelpers";

describe("Borehole list tests", () => {
it("Boreholes are displayed in correct order with editor login", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/codeList.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin, loginAsEditorInViewerMode } from "../e2e/testHelpers";
import { loginAsAdmin, loginAsEditorInViewerMode } from "../e2e/helpers/testHelpers";

describe("Codelist translations tests", () => {
it("Admin can open codelist translation section", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/attachments.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createAndEditBoreholeAsAdmin,
deleteDownloadedFile,
readDownloadedFile,
} from "../testHelpers";
} from "../helpers/testHelpers";

describe("Tests for 'Attachments' edit page.", () => {
it("creates, downloads and deletes attachments.", () => {
Expand Down
22 changes: 9 additions & 13 deletions src/client/cypress/e2e/editor/backfill-v2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {
bearerAuth,
createBorehole,
startBoreholeEditing,
setTextfield,
openDropdown,
selectDropdownOption,
} from "../testHelpers";
} from "../helpers/testHelpers";
import { setInput, setSelect } from "../helpers/formHelpers";

describe("Backfill crud tests", () => {
it("add, edit and delete backfills", () => {
Expand Down Expand Up @@ -54,13 +52,11 @@ describe("Backfill crud tests", () => {
cy.wait("@codelist_GET");

// fill out form
setTextfield('textarea[name="notes"]', "Lorem.");
setTextfield('input[name="fromDepth"]', "123456");
setTextfield('input[name="toDepth"]', "987654");
openDropdown("backfill-kind-select");
selectDropdownOption(2);
openDropdown("backfill-material-select");
selectDropdownOption(1);
setInput("notes", "Lorem.");
setInput("fromDepth", "123456");
setInput("toDepth", "987654");
setSelect("kindId", 2);
setSelect("materialId", 1);

// save backfill
cy.get('[data-cy="save-icon"]').click();
Expand All @@ -76,11 +72,11 @@ describe("Backfill crud tests", () => {
cy.get('[data-cy="edit-icon"]').click({ force: true });
cy.wait("@codelist_GET");

setTextfield('input[name="fromDepth"]', "222");
setInput("fromDepth", "222");

// close editing mask
cy.get('[data-cy="save-icon"]').click({ force: true });
cy.contains("123456222");
cy.contains("222");
cy.contains("inactive");

// delete backfill
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/boreholeEditorTable.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin } from "../../e2e/testHelpers";
import { loginAsAdmin } from "../../e2e/helpers/testHelpers";

describe("Borehole editor table tests", () => {
it("preserves column sorting and active page when navigating", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/boreholeform.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newEditableBorehole } from "../testHelpers";
import { newEditableBorehole } from "../helpers/testHelpers";

describe("Test for the borehole form.", () => {
it("Creates a borehole and fills dropdowns.", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/bulkedit.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createBorehole, loginAsAdmin } from "../testHelpers";
import { createBorehole, loginAsAdmin } from "../helpers/testHelpers";
import adminUser from "../../fixtures/adminUser.json";

describe("Test the borehole bulk edit feature.", () => {
Expand Down
54 changes: 23 additions & 31 deletions src/client/cypress/e2e/editor/casing-v2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {
bearerAuth,
createBorehole,
startBoreholeEditing,
setTextfield,
openDropdown,
selectDropdownOption,
} from "../testHelpers";
} from "../helpers/testHelpers";
import { setInput, setSelect } from "../helpers/formHelpers";

describe("Casing crud tests", () => {
it("add, edit and delete casings", () => {
Expand Down Expand Up @@ -53,18 +51,16 @@ describe("Casing crud tests", () => {
cy.get('[data-cy="add-casing-button"]').click();
cy.wait("@codelist_GET");

setTextfield('input[name="name"]', "casing-1");
setTextfield('input[name="fromDepth"]', "0");
setTextfield('input[name="toDepth"]', "10");
openDropdown("casing-kind-select");
selectDropdownOption(2);
openDropdown("casing-material-select");
selectDropdownOption(3);
setTextfield('input[name="dateStart"]', "2021-01-01");
setTextfield('input[name="dateFinish"]', "2021-01-02");
setTextfield('input[name="innerDiameter"]', "3");
setTextfield('input[name="outerDiameter"]', "4");
setTextfield('textarea[name="notes"]', "Lorem.");
setInput("name", "casing-1");
setInput("fromDepth", "0");
setInput("toDepth", "10");
setSelect("kindId", 2);
setSelect("materialId", 3);
setInput("dateStart", "2021-01-01");
setInput("dateFinish", "2021-01-02");
setInput("innerDiameter", "3");
setInput("outerDiameter", "4");
setInput("notes", "Lorem.");

cy.get('[data-cy="save-icon"]').click();
cy.wait("@casing_GET");
Expand All @@ -84,9 +80,8 @@ describe("Casing crud tests", () => {
cy.get('[data-cy="edit-icon"]').click();
cy.wait("@codelist_GET");

setTextfield('input[name="name"]', " updated");
openDropdown("casing-material-select");
selectDropdownOption(5);
setInput("name", "casing-1 updated");
setSelect("materialId", 5);

cy.get('[data-cy="save-icon"]').click({ force: true });
cy.get('[data-cy="casing-name"]').contains("casing-1 updated");
Expand All @@ -101,16 +96,13 @@ describe("Casing crud tests", () => {
cy.get('[data-cy="add-instrumentation-button"]').click({ force: true });
cy.wait("@casing_GET");

setTextfield('textarea[name="notes"]', "Lorem.");
setTextfield('input[name="name"]', "Inst-1");
setTextfield('input[name="fromDepth"]', "123456");
setTextfield('input[name="toDepth"]', "987654");
openDropdown("instrumentation-kind-select");
selectDropdownOption(2);
openDropdown("instrumentation-status-select");
selectDropdownOption(1);
openDropdown("instrumentation-casing-id-select");
selectDropdownOption(1);
setInput("notes", "Lorem.");
setInput("name", "Inst-1");
setInput("fromDepth", "123456");
setInput("toDepth", "987654");
setSelect("kindId", 2);
setSelect("statusId", 1);
setSelect("casingId", 1);
cy.get('[data-cy="save-icon"]').click({ force: true });

cy.get("[data-cy=completion-content-header-tab-Casing]").click();
Expand All @@ -130,8 +122,8 @@ describe("Casing crud tests", () => {
cy.get("[data-cy=completion-content-header-tab-Instrumentation]").click();
cy.wait("@instrumentation_GET");
cy.get('[data-cy="edit-icon"]').click();
openDropdown("instrumentation-casing-id-select");
selectDropdownOption(0);
setSelect("casingId", 0);

cy.get('[data-cy="save-icon"]').click({ force: true });

cy.get("[data-cy=completion-content-header-tab-Casing]").click();
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/chronostratigraphy.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createStratigraphy,
loginAsAdmin,
bearerAuth,
} from "../testHelpers";
} from "../helpers/testHelpers";

describe("Tests for the chronostratigraphy editor.", () => {
beforeEach(function () {
Expand Down
67 changes: 21 additions & 46 deletions src/client/cypress/e2e/editor/completion-v2.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import {
createBorehole,
startBoreholeEditing,
loginAsAdmin,
openDropdown,
selectDropdownOption,
setTextfield,
} from "../testHelpers";
} from "../helpers/testHelpers";
import {
setInput,
setSelect,
toggleCheckbox,
evaluateCheckbox,
} from "../helpers/formHelpers";

const toggleHeaderOpen = () => {
cy.get('[data-cy="completion-header-display"]')
Expand Down Expand Up @@ -45,34 +48,6 @@ const deleteCompletion = () => {
cy.get('[data-cy="delete-button"]').click();
};

const setName = (name, clear = false) => {
setTextfield('[data-cy="completion-name-textfield"]', name, clear);
};

const setAbandonDate = date => {
setTextfield('[data-cy="completion-abandon-date-textfield"]', date);
};

const setNotes = notes => {
setTextfield('[data-cy="completion-notes-textfield"]', notes);
};

const setKindId = index => {
openDropdown("completion-kind-id-select");
selectDropdownOption(index);
};

const setIsPrimary = () => {
cy.get('[data-cy="completion-is-primary-checkbox"]').click();
};

const checkIsPrimary = isPrimary => {
var checked = isPrimary ? "true" : "false";
cy.get('[data-cy="completion-is-primary-checkbox"]')
.invoke("attr", "aria-disabled")
.should("eq", checked);
};

const setTab = index => {
cy.get('[data-cy="completion-header-tab-' + index + '"]').click();
};
Expand Down Expand Up @@ -110,12 +85,12 @@ describe("completion crud tests", () => {
cy.get('[data-cy="completion-header-tab-0"]').should("not.exist");

addCompletion();
setName("Compl-1");
setKindId(1);
setInput("name", "Compl-1");
setSelect("kindId", 1);
cy.get('[data-cy="save-button"]').should("be.enabled");

setAbandonDate("2012-11-14");
setNotes("Lorem.");
setInput("abandonDate", "2012-11-14");
setInput("notes", "Lorem.");
saveChanges();
cy.contains("Compl-1");

Expand All @@ -127,16 +102,16 @@ describe("completion crud tests", () => {

// edit completion
startEditing();
setKindId(1);
setSelect("kindId", 1);
cancelEditing();
cy.contains("telescopic");
startEditing();
setName("Compl-2", true);
setIsPrimary();
setInput("name", "Compl-2");
toggleCheckbox("isPrimary");
saveChanges();
cy.contains("Compl-2");
startEditing();
checkIsPrimary(true);
evaluateCheckbox("isPrimary", true);
cancelEditing();

// delete completion
Expand Down Expand Up @@ -165,12 +140,12 @@ describe("completion crud tests", () => {

// add completions
addCompletion();
setName("Compl-1");
setKindId(1);
setInput("name", "Compl-1");
setSelect("kindId", 1);
saveChanges();
addCompletion();
setName("Compl-2");
setKindId(1);
setInput("name", "Compl-2");
setSelect("kindId", 1);
saveChanges();
isTabSelected(1);

Expand All @@ -181,7 +156,7 @@ describe("completion crud tests", () => {
isTabSelected(0);

startEditing();
setName("Compl-1 updated");
setInput("name", "Compl-1 updated");
setTab(1);
handlePrompt("Unsaved changes", "cancel");
isTabSelected(0);
Expand All @@ -196,7 +171,7 @@ describe("completion crud tests", () => {
cy.contains("Compl-1");

startEditing();
setName("Compl-2 updated");
setInput("name", "Compl-2 updated");
setTab(0);
handlePrompt("Unsaved changes", "save");
cy.wait("@get-completions-by-boreholeId");
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/coordinates.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newEditableBorehole, delayedType } from "../testHelpers";
import { newEditableBorehole, delayedType } from "../helpers/testHelpers";

describe("Tests for editing coordinates of a borehole.", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/copyBorehole.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createBorehole, loginAsAdmin } from "../testHelpers";
import { createBorehole, loginAsAdmin } from "../helpers/testHelpers";

describe("Test copying of boreholes", () => {
it("copies a borehole", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/emptyMessages.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newUneditableBorehole } from "../testHelpers";
import { newUneditableBorehole } from "../helpers/testHelpers";

describe("Messages for empty profiles", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/fieldMeasurement.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createBorehole,
createStratigraphy,
loginAsAdmin,
} from "../testHelpers";
} from "../helpers/testHelpers";

describe("Tests for the field measurement editor.", () => {
beforeEach(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createBorehole,
createStratigraphy,
loginAsAdmin,
} from "../testHelpers";
} from "../helpers/testHelpers";

describe("Tests for the groundwater level measurement editor.", () => {
beforeEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/hydrotest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
createBorehole,
createStratigraphy,
loginAsAdmin,
} from "../testHelpers";
} from "../helpers/testHelpers";

const openDropdown = dataCy => {
cy.get(`[data-cy="${dataCy}"]`)
Expand Down
2 changes: 1 addition & 1 deletion src/client/cypress/e2e/editor/import.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginAsAdmin, getImportFileFromFixtures } from "../../e2e/testHelpers";
import { loginAsAdmin, getImportFileFromFixtures } from "../../e2e/helpers/testHelpers";

describe("Test for importing boreholes.", () => {
it("Successfully imports multiple boreholes.", () => {
Expand Down
Loading

0 comments on commit 9070f4b

Please sign in to comment.