Skip to content
Merged
16 changes: 16 additions & 0 deletions cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,22 @@ describe("Datasets general", () => {
});
});

describe("Dataset filter end date auto-set", () => {
it("should set end date to today if only start date is provided", () => {
cy.createDataset({
type: "raw",
creationTime: "2025-10-08T15:00:00.000Z",
});
cy.visit("/datasets");

cy.get('[data-cy="creation-time-begin"]').type("2025-10-07");

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

cy.get(".dataset-table mat-row").contains("Cypress Dataset").should("exist");
});
});

describe("Scientific notation in condition panel test", () => {
beforeEach(() => {
cy.login(Cypress.env("username"), Cypress.env("password"));
Expand Down
21 changes: 21 additions & 0 deletions cypress/e2e/proposals/proposals-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,4 +577,25 @@ describe("Proposals general", () => {
});
});
});

describe("Proposals filter end date auto-set", () => {
it("should auto-set end date when start date is set and end date is empty", () => {
const newProposal = {
...testData.proposal,
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
startTime: "2025-10-08T15:00:00.000Z",
};

cy.createProposal(newProposal);

cy.visit("/proposals");

cy.get('[data-cy="creation-time-begin"]').type("2025-10-08");

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

cy.get("mat-table mat-row").should("contain", newProposal.proposalId);

});
});
});
24 changes: 23 additions & 1 deletion cypress/fixtures/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,29 @@ export const testConfig = {
enabled: true,
},
],
filters: [],
filters: [
{
key: "instrumentIds",
label: "Instrument",
type: "checkbox",
description: "Filter by instrument name",
enabled: true,
},
{
key: "pi_lastname",
label: "PI Last Name",
type: "checkbox",
description: "Filter by dataset start time",
enabled: true,
},
{
key: "startTime",
label: "Start Time",
type: "dateRange",
description: "Filter by dataset start time",
enabled: true,
},
],
conditions: [],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
mat-raised-button
color="primary"
class="datasets-filters-search-button"
data-cy="filter-search-button"
(click)="applyFilters()"
>
<mat-icon>search</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ export class DatasetsFilterComponent implements OnInit, OnDestroy {
const { queryParams } = this.route.snapshot;
const searchQuery = JSON.parse(queryParams.searchQuery || "{}");

if (
this.activeFilters.creationTime &&
!this.activeFilters.creationTime["end"]
) {
this.activeFilters.creationTime["end"] = new Date().toISOString();
}
this.router.navigate([], {
queryParams: {
searchQuery: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
color="primary"
class="proposal-filters-search-button"
(click)="applyFilters()"
data-cy="apply-button-filter"
>
<mat-icon>search</mat-icon>
Apply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export class ProposalSideFilterComponent implements OnInit {
const { queryParams } = this.route.snapshot;
const searchQuery = JSON.parse(queryParams.searchQuery || "{}");

if (this.activeFilters.startTime && !this.activeFilters.startTime["end"]) {
this.activeFilters.startTime["end"] = new Date().toISOString();
}
this.router.navigate([], {
queryParams: {
searchQuery: JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
matStartDate
(dateChange)="dateChanged($event, 'begin')"
formControlName="start"
data-cy="creation-time-begin"
/>
<input
matEndDate
(dateChange)="dateChanged($event, 'end')"
formControlName="end"
data-cy="creation-time-end"
/>
</mat-date-range-input>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export class SharedFilterComponent implements OnChanges {
@Output() selectionChange = new EventEmitter<MultiSelectFilterValue>();
@Output() numericRangeChange = new EventEmitter<INumericRange>();
@Output() dateRangeChange = new EventEmitter<{
begin: string;
end: string;
begin?: string;
end?: string;
}>();

constructor() {}
Expand Down
1 change: 1 addition & 0 deletions src/app/state-management/selectors/datasets.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export const selectFullqueryParams = createSelector(
const pagination = state.pagination;
// don't query with modeToggle, it's only in filters for persistent routing
const { skip, limit, sortField, modeToggle, ...theRest } = filter;

const limits = { ...pagination, order: sortField };
const query = restrictFilter(theRest);

Expand Down
4 changes: 2 additions & 2 deletions src/app/state-management/state/proposals.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
import { TableField } from "shared/modules/dynamic-material-table/models/table-field.model";

export interface DateRange {
begin: string;
end: string;
begin?: string;
end?: string;
}

export interface FacetCount {
Expand Down
Loading