Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
57 changes: 57 additions & 0 deletions cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,61 @@ describe("Datasets general", () => {
.should("be.visible");
});
});

describe("Condition value persistence after navigation", () => {
beforeEach(() => {
cy.login(Cypress.env("username"), Cypress.env("password"));
cy.createDataset({
type: "raw",
dataFileSize: "small",
scientificMetadata: {
run_number: { type: "number", value: 76129, unit: "" },
},
});
cy.visit("/datasets");
});

it("should persist condition values after navigating away and back", () => {
cy.get('[data-cy="scientific-condition-filter-list"]').within(() => {
cy.get('[data-cy="add-condition-button"]').click();
});

cy.get('input[name="lhs"]').type("run_number");

cy.get("mat-dialog-container").find('button[type="submit"]').click();

cy.get(".condition-panel").first().click();

cy.get(".condition-panel")
.first()
.within(() => {
cy.get("mat-select").click();
});
cy.get("mat-option").contains(">").click();

cy.get(".condition-panel")
.first()
.within(() => {
cy.get("input[matInput]").eq(0).clear().type("19");
});

cy.get('[data-cy="filter-search-button"]').click();

cy.get(".dataset-table mat-row").first().click();

cy.get('[data-cy="edit-general-information"]').should("exist");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use generic selector here to make the test stable, e.g, check if mat-card exist or not.
The edit button displays based on user permission and do not exist in the dynamic dataset detail view.


cy.go('back');

cy.get(".condition-panel")
.first()
.find("mat-panel-title")
.should("contain", ">")
.and("contain", "19");
Comment on lines +716 to +722
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Selectors in the new test are fairly generic and may be brittle over time.

The assertions after cy.go('back') depend on generic selectors like .condition-panel and mat-panel-title plus content matches (> and 19), which ties the test to presentation details and may break on minor layout/label changes. Where possible, prefer dedicated hooks (e.g. data-cy attributes) for the condition panels and operator/value fields so the test stays stable while still verifying the persisted condition state.

Suggested implementation:

      cy.go('back');

      cy.get('[data-cy="condition-panel"]')
        .first()
        .within(() => {
          cy.get('[data-cy="condition-operator"]').should("contain", ">");
          cy.get('[data-cy="condition-value"]').should("contain", "19");
        });

To make this test pass and keep it robust, you’ll need to:

  1. Add data-cy="condition-panel" to the element that currently has the .condition-panel class in the UI template.
  2. Add data-cy="condition-operator" to the element within the condition panel that displays the comparison operator (currently the part that ends up in mat-panel-title).
  3. Add data-cy="condition-value" to the element within the condition panel that displays the value (19 in this test).
  4. If the operator/value are rendered differently (e.g., inside chips or separate spans), adjust the specific data-cy hooks accordingly, while keeping the Cypress selectors aligned with those hooks.


cy.get(".condition-panel").first().click();

cy.get('[data-cy="remove-condition-button"]').click();
});
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,6 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy {
index: number,
newOperator: ScientificCondition["relation"],
) {
delete this.tempConditionValues[index];

Comment on lines -751 to -752
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why this line is removed?

const updates: Partial<ScientificCondition> = {
relation: newOperator,
rhs: newOperator === "RANGE" ? [undefined, undefined] : "",
Expand Down
3 changes: 3 additions & 0 deletions src/app/state-management/reducers/user.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const reducer = createReducer(
columns = [],
externalSettings,
filters,
conditions,
} = userSettings as any;
const settings = { ...state.settings, datasetCount, jobCount };

Expand All @@ -116,13 +117,15 @@ const reducer = createReducer(
columns,
tablesSettings: externalSettings?.tablesSettings,
filters: filters || state.filters,
conditions: conditions || state.conditions,
};
} else {
return {
...state,
settings,
tablesSettings: externalSettings?.tablesSettings,
filters: filters || state.filters,
conditions: conditions || state.conditions,
};
}
},
Expand Down
Loading