Copilot commented on code in PR #6524:
URL: https://github.com/apache/texera/pull/6524#discussion_r3609359428


##########
frontend/src/app/dashboard/component/user/user-quota/user-quota.component.spec.ts:
##########
@@ -24,6 +24,40 @@ import { HttpClientTestingModule } from 
"@angular/common/http/testing";
 import { commonTestProviders } from "../../../../common/testing/test-utils";
 import { of } from "rxjs";
 import type { Mocked } from "vitest";
+import * as Plotly from "plotly.js-basic-dist-min";
+import { ExecutionQuota } from "../../../../common/type/user";
+import { DatasetQuota } from "../../../type/quota-statistic.interface";
+
+// Plotly is a read-only ESM namespace (can't be spied on), so mock the whole 
module.
+vi.mock("plotly.js-basic-dist-min", () => ({ newPlot: vi.fn() }));
+
+// ISO 'YYYY-MM-DD' for a date `days` before now (kept by the 1-year filter 
for small values).
+function isoDaysAgo(days: number): string {
+  return new Date(Date.now() - days * 86_400_000).toISOString().slice(0, 10);
+}
+
+// ISO 'YYYY-MM-DD' on `day` of the month `monthsAgo` months before now.
+function isoInMonthsAgo(monthsAgo: number, day: number): string {
+  const d = new Date();
+  d.setDate(1); // avoid month-length overflow before shifting the month
+  d.setMonth(d.getMonth() - monthsAgo);
+  d.setDate(day);
+  return d.toISOString().slice(0, 10);
+}

Review Comment:
   The date helpers mix local-time setters (`setDate`/`setMonth`) with 
`toISOString()` (UTC). This can shift the resulting `YYYY-MM-DD` by +/- 1 day 
(and potentially the month) depending on the runner timezone and time-of-day, 
making these tests flaky around day/month boundaries. Use UTC setters (or 
freeze time with fake timers) so the generated ISO strings are deterministic.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to