Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable DataCard components #1008

Merged
merged 57 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ee8532a
Add datacard components
tschumpr Feb 1, 2024
152a738
Fix imports
tschumpr Feb 2, 2024
735642d
Apply completion style to hydro
tschumpr Feb 2, 2024
6e6b973
Condition is required
tschumpr Feb 2, 2024
524d852
Clean up code
tschumpr Feb 2, 2024
ef8e8f4
Use completionContentTab for Hydro
tschumpr Feb 2, 2024
4a3db68
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 2, 2024
6c8abd1
Use common styling
tschumpr Feb 2, 2024
01bf75e
Fix test
tschumpr Feb 2, 2024
fb01504
Move button to common file
tschumpr Feb 2, 2024
65fb54e
Unify dataCard logic
tschumpr Feb 2, 2024
d4093de
Fix cypress label
tschumpr Feb 2, 2024
6a1b7e4
Fix test
tschumpr Feb 5, 2024
686c6e5
Fix parameter unit endAdornment
tschumpr Feb 5, 2024
c33c828
Remove temp card on cancel
tschumpr Feb 5, 2024
101a7f1
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 5, 2024
b3edf7c
Use dataCard and multiSelect form
tschumpr Feb 6, 2024
922fe68
Merge remote-tracking branch 'origin/reusable-datacard-components' in…
tschumpr Feb 6, 2024
6d05256
Update parameter unit onchange
tschumpr Feb 7, 2024
42c1843
Fix data-cy labels
tschumpr Feb 7, 2024
4491cb6
Only show supported parameters
tschumpr Feb 7, 2024
9031bb0
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 7, 2024
c41ab56
Merge branch 'reusable-datacard-components' into refactor-hydrotest
tschumpr Feb 7, 2024
8d87b84
Show correct value
tschumpr Feb 7, 2024
2c35269
Re-use code
tschumpr Feb 7, 2024
e3fc0e2
Check if codelist entries are arrays
tschumpr Feb 7, 2024
45a0cd0
Update test
tschumpr Feb 7, 2024
e493500
Fix disabled check
tschumpr Feb 7, 2024
2d902ec
Update changelog
tschumpr Feb 7, 2024
83efb8f
Fix console warning
tschumpr Feb 7, 2024
f53f6ac
Simplify code
tschumpr Feb 7, 2024
2052ed9
Remove unused code
tschumpr Feb 7, 2024
503c2e2
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 7, 2024
66a39f9
Refactor hydrotest (#1012)
tschumpr Feb 12, 2024
f3efb9a
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 12, 2024
6965038
Update cancel icon
tschumpr Feb 12, 2024
b3e9381
Set id if not defined in form
tschumpr Feb 12, 2024
9896035
Check casing after re-save
tschumpr Feb 12, 2024
0391b7b
Use tab hash for cy labels
tschumpr Feb 12, 2024
44f84d1
Reuse style
tschumpr Feb 12, 2024
23b9f39
Reuse style
tschumpr Feb 12, 2024
35a099d
Use error background color from theme
tschumpr Feb 12, 2024
7f7eb1b
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 12, 2024
7ba51f2
Update labels to camel case
tschumpr Feb 12, 2024
09540f3
Set casingId for all hydrogeo modules
tschumpr Feb 12, 2024
6f31124
Merge branch 'reusable-datacard-components' into set-casing-id-on-resave
tschumpr Feb 12, 2024
540ebde
Fix label
tschumpr Feb 12, 2024
5b1e091
Set casingId on re-save (#1017)
tschumpr Feb 13, 2024
3fee60b
Use theme for styling
tschumpr Feb 13, 2024
8b2e367
Use same cancel icon in completion
tschumpr Feb 13, 2024
6315d20
Re-use icon button in completion
tschumpr Feb 13, 2024
c4ae24e
Use text buttons
tschumpr Feb 13, 2024
80d9bf7
Merge branch 'main' into reusable-datacard-components
tschumpr Feb 13, 2024
4b082b7
Re-use button components
tschumpr Feb 13, 2024
d1e8f25
Merge branch 'reusable-datacard-components' of github.com:geoadmin/su…
tschumpr Feb 13, 2024
9ea8cac
Fix test
tschumpr Feb 13, 2024
82a8265
Fix test
tschumpr Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Use reusable form components for hydrogeology.
- Replaced label for layer description quality.
- Reduced number of seeded boreholes for development from 10'000 to 3'000.
- Use reusable card components for hydrogeology.

### Fixed

Expand Down
17 changes: 12 additions & 5 deletions src/client/cypress/e2e/editor/backfill.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import {
startBoreholeEditing,
} from "../helpers/testHelpers";
import { setInput, setSelect } from "../helpers/formHelpers";
import {
addItem,
startEditing,
saveForm,
deleteItem,
} from "../helpers/buttonHelpers";

describe("Backfill crud tests", () => {
it("add, edit and delete backfills", () => {
Expand All @@ -27,10 +33,11 @@ describe("Backfill crud tests", () => {
startBoreholeEditing();

// select backfill tab
cy.get("[data-cy=completion-content-header-tab-Backfill]").click();
cy.get("[data-cy=completion-content-header-tab-backfill]").click();
cy.wait("@backfill_GET");

// add new backfill card
addItem("addFilling");
cy.get('[data-cy="addFilling-button"]').click({ force: true });
cy.wait("@codelist_GET");

Expand All @@ -42,7 +49,7 @@ describe("Backfill crud tests", () => {
setSelect("materialId", 1);

// save backfill
cy.get('[data-cy="save-icon"]').click();
saveForm();

// check if backfill is saved
cy.contains("123456");
Expand All @@ -52,18 +59,18 @@ describe("Backfill crud tests", () => {
cy.contains("filter gravel");

// edit backfill
cy.get('[data-cy="edit-icon"]').click({ force: true });
startEditing();
cy.wait("@codelist_GET");

setInput("fromDepth", "222");

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

// delete backfill
cy.get('[data-cy="delete-icon"]').click({ force: true });
deleteItem();
cy.contains("From depth").should("not.exist");
});
});
34 changes: 20 additions & 14 deletions src/client/cypress/e2e/editor/casing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import {
setInput,
setSelect,
} from "../helpers/formHelpers";
import {
addItem,
startEditing,
saveForm,
deleteItem,
} from "../helpers/buttonHelpers";

describe("Casing crud tests", () => {
it("add, edit and delete casings", () => {
Expand All @@ -31,11 +37,11 @@ describe("Casing crud tests", () => {
startBoreholeEditing();

// select casing tab
cy.get("[data-cy=completion-content-header-tab-Casing]").click();
cy.get("[data-cy=completion-content-header-tab-casing]").click();
cy.wait("@casing_GET");

// create casing
cy.get('[data-cy="addCasing-button"]').click();
addItem("addCasing");
cy.wait("@codelist_GET");

setInput("name", "casing-1");
Expand All @@ -49,7 +55,7 @@ describe("Casing crud tests", () => {
setInput("outerDiameter", "4");
setInput("notes", "Lorem.");

cy.get('[data-cy="save-icon"]').click();
saveForm();
cy.wait("@casing_GET");

evaluateDisplayValue("name", "casing-1");
Expand All @@ -59,28 +65,28 @@ describe("Casing crud tests", () => {
evaluateDisplayValue("materialCasingLayer", "steel");
evaluateDisplayValue("dateStartCasing", "01. Jan. 2021");
evaluateDisplayValue("dateFinishCasing", "02. Jan. 2021");
evaluateDisplayValue("casing_inner_diameter", "3");
evaluateDisplayValue("casing_outer_diameter", "4");
evaluateDisplayValue("casingInnerDiameter", "3");
evaluateDisplayValue("casingOuterDiameter", "4");
evaluateDisplayValue("notes", "Lorem.");

// update casing
cy.get('[data-cy="edit-icon"]').click();
startEditing();
cy.wait("@codelist_GET");

setInput("name", "casing-1 updated");
setSelect("materialId", 5);

cy.get('[data-cy="save-icon"]').click({ force: true });
saveForm();
evaluateDisplayValue("name", "casing-1 updated");
evaluateDisplayValue("materialCasingLayer", "concrete");
evaluateDisplayValue("casing_inner_diameter", "3");
evaluateDisplayValue("casingInnerDiameter", "3");

// delete casing
// Precondition: instrumentation with reference to casing
cy.get("[data-cy=completion-content-header-tab-Instrumentation]").click();
cy.get("[data-cy=completion-content-header-tab-instrumentation]").click();
cy.wait("@instrumentation_GET");

cy.get('[data-cy="addInstrument-button"]').click({ force: true });
addItem("addInstrument");
cy.wait("@casing_GET");

setInput("notes", "Lorem.");
Expand All @@ -90,16 +96,16 @@ describe("Casing crud tests", () => {
setSelect("kindId", 2);
setSelect("statusId", 1);
setSelect("casingId", 1);
cy.get('[data-cy="save-icon"]').click({ force: true });
saveForm();

cy.get("[data-cy=completion-content-header-tab-Casing]").click();
cy.get("[data-cy=completion-content-header-tab-casing]").click();
cy.wait("@casing_GET");

cy.get('[data-cy="delete-icon"]').click({ force: true });
deleteItem();
cy.wait("@casing_DELETE");
cy.contains("casing-1 updated").should("not.exist");

cy.get("[data-cy=completion-content-header-tab-Instrumentation]").click();
cy.get("[data-cy=completion-content-header-tab-instrumentation]").click();
cy.wait("@instrumentation_GET");
evaluateDisplayValue("casingName", "-");
});
Expand Down
58 changes: 25 additions & 33 deletions src/client/cypress/e2e/editor/completion.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import {
evaluateCheckbox,
evaluateDisplayValue,
} from "../helpers/formHelpers";
import {
addItem,
startEditing,
cancelEditing,
saveForm,
deleteItem,
copyItem,
} from "../helpers/buttonHelpers";

const toggleHeaderOpen = () => {
cy.get('[data-cy="completion-header-display"]')
Expand All @@ -26,44 +34,28 @@ const toggleHeaderOpen = () => {
};

const addCompletion = () => {
cy.get('[data-cy="add-completion-button"]').click({
force: true,
});
addItem("addCompletion");
cy.wait("@codelist_GET");
};

const startEditing = () => {
const startEdit = () => {
toggleHeaderOpen();
cy.get('[data-cy="edit-button"]').click({
force: true,
});
};

const cancelEditing = () => {
cy.get('[data-cy="cancel-button"]').click({
force: true,
});
startEditing();
};

const saveChanges = () => {
cy.get('[data-cy="save-button"]').click({
force: true,
});
saveForm();
cy.wait("@get-completions-by-boreholeId");
};

const copyCompletion = () => {
toggleHeaderOpen();
cy.get('[data-cy="copy-button"]').click({
force: true,
});
copyItem();
};

const deleteCompletion = () => {
toggleHeaderOpen();
cy.get('[data-cy="delete-button"]').click({
force: true,
});
deleteItem();
};

const setTab = index => {
Expand Down Expand Up @@ -117,16 +109,16 @@ describe("completion crud tests", () => {
cy.contains("Compl-1 (Clone)");

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

Expand Down Expand Up @@ -197,14 +189,14 @@ describe("completion crud tests", () => {
isTabSelected(1);

// check hash updates on tab switch
cy.get("[data-cy=completion-content-header-tab-Instrumentation]").click();
cy.get("[data-cy=completion-content-header-tab-instrumentation]").click();
cy.location().should(location => {
expect(location.pathname).to.eq(
`/editor/${boreholeId}/completion/${completion2Id}`,
);
expect(location.hash).to.eq("#instrumentation");
});
cy.get("[data-cy=completion-content-header-tab-Backfill]").click();
cy.get("[data-cy=completion-content-header-tab-backfill]").click();
cy.location().should(location => {
expect(location.pathname).to.eq(
`/editor/${boreholeId}/completion/${completion2Id}`,
Expand All @@ -214,7 +206,7 @@ describe("completion crud tests", () => {

// switch tabs
// existing editing to other existing: no prompt should be displayed when no changes have been made
startEditing();
startEdit();
setTab(0);
cy.get('[data-cy="prompt"]').should("not.exist");
isTabSelected(0);
Expand All @@ -226,7 +218,7 @@ describe("completion crud tests", () => {
});

// existing editing to other existing: tab switching can be canceled in prompt
startEditing();
startEdit();
setInput("name", "Compl-1 updated");
setTab(1);
handlePrompt("Unsaved changes", "cancel");
Expand All @@ -252,7 +244,7 @@ describe("completion crud tests", () => {
});

// existing editing to other existing: changes can be saved in prompt
startEditing();
startEdit();
setInput("name", "Compl-2 updated");
setTab(0);
handlePrompt("Unsaved changes", "save");
Expand Down Expand Up @@ -339,7 +331,7 @@ describe("completion crud tests", () => {
);
expect(location.hash).to.eq("#casing");
});
startEditing();
startEdit();
cy.get(`[data-cy="name-formInput"]`).click();
addCompletion();
evaluateInput("name", "");
Expand All @@ -359,7 +351,7 @@ describe("completion crud tests", () => {
);
expect(location.hash).to.eq("#casing");
});
startEditing();
startEdit();
setInput("name", "Reset compl-1");
addCompletion();
handlePrompt("Unsaved changes", "reset");
Expand All @@ -377,7 +369,7 @@ describe("completion crud tests", () => {
);
expect(location.hash).to.eq("#casing");
});
startEditing();
startEdit();
setInput("name", "Reset compl-1");
addCompletion();
handlePrompt("Unsaved changes", "save");
Expand Down
Loading
Loading