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


##########
frontend/src/app/dashboard/component/user/user-quota/user-quota.component.spec.ts:
##########
@@ -24,12 +24,18 @@ 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() }));
+// Real Plotly renders into a DOM element by id; create one and assert on the
+// `data`/`layout` Plotly attaches to that graph div. (Module-level mocking of
+// plotly.js-basic-dist-min was flaky across the CI matrix — the mock did not
+// always intercept, letting the real newPlot throw "No DOM element with id".)
+function chartDiv(id: string): void {
+  const div = document.createElement("div");
+  div.id = id;
+  document.body.appendChild(div);
+}

Review Comment:
   `chartDiv` always appends a new element and never removes an existing 
element with the same id. If the helper is called twice (e.g., a retry, watch 
mode rerun without full DOM reset, or future tests reusing the same id), the 
document can accumulate duplicate ids and `getElementById` will return the 
first one, which can make assertions read stale Plotly state. Consider removing 
any existing element before appending the new div (and optionally returning it).



-- 
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