Skip to content
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.url;
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.url;
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);
});
});
});
});
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.startTime;
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
6 changes: 5 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,12 @@
const pagination = state.pagination;
// don't query with modeToggle, it's only in filters for persistent routing
const { skip, limit, sortField, modeToggle, ...theRest } = filter;
let modifiedFilters = {...theRest};

Check failure on line 190 in src/app/state-management/selectors/datasets.selectors.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `...theRest` with `·...theRest·`

Check failure on line 190 in src/app/state-management/selectors/datasets.selectors.ts

View workflow job for this annotation

GitHub Actions / eslint

'modifiedFilters' is never reassigned. Use 'const' instead
if (modifiedFilters.creationTime?.begin && modifiedFilters.creationTime.end === null) {

Check failure on line 191 in src/app/state-management/selectors/datasets.selectors.ts

View workflow job for this annotation

GitHub Actions / eslint

Replace `modifiedFilters.creationTime?.begin·&&·modifiedFilters.creationTime.end·===·null` with `⏎······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