diff --git a/cypress/e2e/datasets/datasets-general.cy.js b/cypress/e2e/datasets/datasets-general.cy.js
index 49dd5e485b..9ba4674077 100644
--- a/cypress/e2e/datasets/datasets-general.cy.js
+++ b/cypress/e2e/datasets/datasets-general.cy.js
@@ -495,27 +495,21 @@ describe("Datasets general", () => {
});
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
- const relationsToTest = [
- { relation: "GREATER_THAN", rhs: 1 },
- { relation: "LESS_THAN", rhs: 3 },
- { relation: "EQUAL_TO_NUMERIC", rhs: 2 },
- { relation: "GREATER_THAN_OR_EQUAL", rhs: 2 },
- { relation: "LESS_THAN_OR_EQUAL", rhs: 2 },
- { relation: "RANGE", rhs: [1, 3] },
- ];
const testConfig = {
...baseConfig,
defaultDatasetsListSettings: {
...baseConfig.defaultDatasetsListSettings,
- conditions: relationsToTest.map(({ relation, rhs }) => ({
- condition: {
- lhs: "extra_entry_end_time",
- relation,
- rhs,
- unit: "",
+ conditions: [
+ {
+ condition: {
+ lhs: "extra_entry_end_time",
+ relation: "GREATER_THAN",
+ rhs: 1,
+ unit: "",
+ },
+ enabled: true,
},
- enabled: true,
- })),
+ ],
},
};
@@ -536,20 +530,16 @@ describe("Datasets general", () => {
cy.get(".dataset-table mat-row").first().click();
cy.get(".metadataTable", { timeout: 10000 }).scrollIntoView();
- cy.get(".metadataTable mat-row").within(() => {
- cy.get(".mat-column-human_name label")
- .invoke("text")
- .then((fieldName) => {
- if (fieldName && fieldName.trim() === "Extra Entry End Time") {
- cy.get(".mat-column-value label")
- .invoke("text")
- .then((valueText) => {
- const value = parseFloat(valueText.trim());
- expect(value).to.be.greaterThan(1);
- });
- }
- });
- });
+ cy.get(".metadataTable mat-row .mat-column-value label")
+ .invoke("text")
+ .then((valueText) => {
+ const value = parseFloat(valueText.trim());
+ expect(value).to.be.greaterThan(1);
+ });
+
+ cy.visit("/datasets");
+ cy.get(".condition-panel").first().click();
+ cy.get('[data-cy="remove-condition-button"]').click();
});
});
@@ -651,7 +641,7 @@ describe("Datasets general", () => {
cy.visit("/datasets");
- cy.wait("@getConfig", { timeout: 10000 });
+ cy.wait("@getConfig", { timeout: 20000 });
cy.finishedLoading();
});
@@ -670,4 +660,67 @@ describe("Datasets general", () => {
.should("be.visible");
});
});
+
+ describe("Conditions in multiple pages", () => {
+ beforeEach(() => {
+ cy.login(Cypress.env("username"), Cypress.env("password"));
+ });
+
+ it("should preverse dataset conditions when clearing sample conditions", () => {
+
+ cy.createDataset({
+ type: "raw",
+ scientificMetadata: {
+ extra_entry_end_time: { type: "number", value: 5, unit: "" },
+ },
+ });
+ const sampleId = Math.floor(100000 + Math.random() * 900000).toString();
+ cy.createSample({...testData.sample, sampleId});
+
+ cy.visit("/datasets");
+ cy.finishedLoading();
+
+ cy.get('[data-cy="add-condition-button"]').click();
+ cy.get('input[name="lhs"]').type("extra_entry_end_time");
+ cy.get("mat-dialog-container").find('button[type="submit"]').click();
+
+ cy.get(".condition-panel").should("have.length", 1);
+
+ cy.visit("/samples");
+ cy.finishedLoading();
+
+ cy.get('[data-cy="add-condition-button"]').click();
+ cy.get('input[name="lhs"]').type("test_characteristic");
+ cy.get("mat-dialog-container").find('button[type="submit"]').click();
+
+ cy.get(".condition-panel").should("have.length", 1);
+
+ cy.get(".condition-panel").first().click();
+ cy.get(".condition-panel")
+ .first()
+ .within(() => {
+ cy.get("input[matInput]").eq(0).clear().type("10");
+ });
+ cy.get('[data-cy="samples-filters-search-button"]').click();
+
+ // Clear conditions on samples page
+ cy.get('[data-cy="samples-filters-clear-button"]').click();
+
+ cy.get(".condition-panel").should("have.length", 0);
+
+ // Navigate back to datasets and verify condition is still there
+ cy.visit("/datasets");
+ cy.finishedLoading();
+
+ cy.get(".condition-panel").should("have.length", 1);
+ cy.get(".condition-panel").should("contain.text", "extra_entry_end_time");
+
+ cy.get(".condition-panel").first().click();
+ cy.get('[data-cy="remove-condition-button"]').click();
+ });
+ afterEach(() => {
+ cy.removeSamples();
+ })
+ });
+
});
diff --git a/cypress/fixtures/testData.js b/cypress/fixtures/testData.js
index 0d44199aae..47812207dd 100644
--- a/cypress/fixtures/testData.js
+++ b/cypress/fixtures/testData.js
@@ -70,6 +70,21 @@ export const testData = {
main_user: "ESS",
},
},
+ sample: {
+ ownerGroup: "ess",
+ accessGroups: ["string"],
+ instrumentGroup: "string",
+ sampleId: "string",
+ owner: "string",
+ description: "Cypress Sample",
+ type: "string",
+ proposalId: "cypress",
+ parentSampleId: "string",
+ sampleCharacteristics: {
+ test_characteristic: { type: "number", value: 10, unit: "" },
+ },
+ isPublished: false,
+ },
rawDataset: {
principalInvestigator: "string",
endTime: "2019-10-31T14:44:46.143Z",
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index fe83913f91..38034a3efd 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -215,6 +215,28 @@ Cypress.Commands.add("createInstrument", (instrument) => {
});
});
+Cypress.Commands.add("createSample", (sample) => {
+ return cy.getCookie("user").then((userCookie) => {
+ const user = JSON.parse(decodeURIComponent(userCookie.value));
+
+ cy.getToken().then((token) => {
+ cy.log("Sample: " + JSON.stringify(sample, null, 2));
+ cy.log("User: " + JSON.stringify(user, null, 2));
+
+ cy.request({
+ method: "POST",
+ url: lbBaseUrl + "/Samples",
+ headers: {
+ Authorization: token,
+ Accept: "application/json",
+ "Content-Type": "application/json",
+ },
+ body: sample,
+ });
+ });
+ });
+});
+
Cypress.Commands.add("updateProposal", (proposalId, updateProposalDto) => {
return cy.getCookie("user").then((userCookie) => {
const user = JSON.parse(decodeURIComponent(userCookie.value));
diff --git a/src/app/datasets/datasets-filter/datasets-filter.component.html b/src/app/datasets/datasets-filter/datasets-filter.component.html
index fb6bebb561..d35d48af82 100644
--- a/src/app/datasets/datasets-filter/datasets-filter.component.html
+++ b/src/app/datasets/datasets-filter/datasets-filter.component.html
@@ -61,308 +61,19 @@
(numericRangeChange)="numericRangeChange(filter.key, $event)"
>
-
+ [showConditions]="true"
+ [metadataKeys]="metadataKeys$ | async"
+ [unitsEnabled]="appConfig.scienceSearchUnitsEnabled"
+ [showConditionToggle]="true"
+ [conditionType]="'datasets'"
+ [addConditionAction]="addCondition"
+ [removeConditionAction]="removeCondition"
+ >