Skip to content
24 changes: 24 additions & 0 deletions cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,28 @@ 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.intercept("GET", "/api/v3/datasets/fullquery*").as("fullquery");
cy.get('[data-cy="filter-search-button"]').click();

cy.wait("@fullquery").then((interception) => {
const {url} = interception.request;
expect(url).to.contain("/api/v3/datasets/fullquery");
expect(url).to.contain("creationTime");

const today = new Date().toISOString().slice(0, 10);
expect(url).to.include(today);
cy.log("Fullquery URL:", url);
Copy link
Member

Choose a reason for hiding this comment

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

This test looks odd to me, not sure why interception is needed here.
wouldn't it be simpler to just mock the actions, set start date filter and check if dataset table shows the correct dataset

Copy link
Member Author

Choose a reason for hiding this comment

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

I used the interception to verify that the creationTime and todays date are included in the request URL, but I see your point, mocking it and checking the table would make the tests simpler

Copy link
Member Author

Choose a reason for hiding this comment

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

changed in fcfcf56

});
});
});
});
31 changes: 31 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,35 @@ 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.intercept("GET", "/api/v3/proposals/fullquery*").as("fullquery");

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

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

cy.wait("@fullquery");
cy.wait("@fullquery").then((interception) => {
const {url} = interception.request;
expect(url).to.contain("/api/v3/proposals/fullquery");
expect(url).to.contain("startTime");

const today = new Date().toISOString().slice(0, 10);
expect(url).to.include(today);
cy.log("Fullquery URL:", url);
Copy link
Member

Choose a reason for hiding this comment

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

Same as the datasets test

Copy link
Member Author

Choose a reason for hiding this comment

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

changed in f2e9335

});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,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 @@ -218,6 +218,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 @@ -30,6 +30,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 @@ -77,6 +77,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 @@ -72,8 +72,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);
return { query, limits };
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