Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
25 changes: 25 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,29 @@ 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="search-button"]').click();

cy.intercept("GET", "/api/v3/datasets/fullquery*").as("fullquery");

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);
});
});
});
});
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);
Comment on lines +593 to +607
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

});
});
});
});
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 @@ -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
17 changes: 16 additions & 1 deletion src/app/state-management/effects/proposals.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,22 @@ export class ProposalEffects {
limitsParam.order = `${sortColumn}:${sortDirection}`;
}

const queryParam = search || {};
const queryParam = search ? { ...search } : {};
const { startTime } = queryParam;
if (
startTime &&
typeof startTime === "object" &&
startTime !== null &&
"begin" in startTime &&
"end" in startTime &&
startTime.begin &&
startTime.end == null
) {
queryParam.startTime = {
...startTime,
end: new Date().toISOString(),
};
}

return this.proposalsService
.proposalsControllerFullqueryV3(
Expand Down
9 changes: 8 additions & 1 deletion src/app/state-management/selectors/datasets.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,15 @@ 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 modifiedFilters = { ...theRest };
if (
modifiedFilters.creationTime?.begin &&
modifiedFilters.creationTime.end === null
) {
modifiedFilters.creationTime.end = new Date().toISOString();
}
const limits = { ...pagination, order: sortField };
const query = restrictFilter(theRest);
const query = restrictFilter(modifiedFilters);
return { query, limits };
},
);
Expand Down
Loading