Copilot commented on code in PR #7442:
URL: https://github.com/apache/texera/pull/7442#discussion_r3743429505
##########
frontend/src/app/workspace/component/result-panel/error-frame/error-frame.component.spec.ts:
##########
@@ -158,4 +158,108 @@ describe("ErrorFrameComponent", () => {
expect(highlight).toHaveBeenCalledWith(false, "op-42");
});
});
+ /**
+ * The frame's template decides what an error list looks like: the
all-operators banner, the empty
+ * state, the grouping into categories, and — the part with real teeth —
whether a "focus operator"
+ * shortcut is offered at all. The suite above builds the category map and
never renders it.
+ */
+ describe("rendered errors", () => {
+ /** Renders the frame for the given errors, optionally scoped to one
operator. */
+ function render(errors: WorkflowFatalError[], scopedTo?: string):
HTMLElement {
+ component.operatorId = scopedTo;
+ component.categoryToErrorMapping = errors.reduce((acc, e) => {
+ const key = e.type.name;
+ acc.set(key, [...(acc.get(key) ?? []), e]);
+ return acc;
+ }, new Map<string, WorkflowFatalError[]>());
+ fixture.detectChanges();
+ return fixture.nativeElement as HTMLElement;
+ }
+
+ function gotoIcons(): HTMLElement[] {
+ return Array.from((fixture.nativeElement as
HTMLElement).querySelectorAll<HTMLElement>(".goto-operator-icon"));
+ }
+
+ it("announces that it is showing every operator's errors", () => {
+ const el = render([fatalError()]);
+
+ expect(el.querySelector(".all-errors-notification")).not.toBeNull();
+ });
+
+ it("drops that banner once the frame is scoped to one operator", () => {
+ const el = render([fatalError()], "op1");
+
+ expect(el.querySelector(".all-errors-notification")).toBeNull();
+ });
+
+ it("says so when there is nothing to report, and only then", () => {
+ const el = render([]);
+ expect(el.textContent).toContain("No error to display.");
+
+ render([fatalError()]);
+ expect((fixture.nativeElement as
HTMLElement).textContent).not.toContain("No error to display.");
+ });
+
+ it("groups the errors under their category headings", () => {
+ const el = render([
+ fatalError({ type: { name: "COMPILATION" } as any }),
+ fatalError({ type: { name: "EXECUTION" } as any }),
Review Comment:
The `as any` casts on the error `type` objects here are unnecessary and
reduce type-safety. Earlier tests in this same spec pass `{ type: { name:
"TYPE_A" } }` without a cast, so these should compile cleanly as well.
--
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]