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


##########
frontend/src/app/common/service/workflow-persist/workflow-persist.service.spec.ts:
##########
@@ -77,4 +86,67 @@ describe("WorkflowPersistService", () => {
         
expect(value.workflow.content).toEqual(jsonCast<WorkflowContent>(testContent));
       });
   });
+
+  const API = AppSettings.getApiEndpoint();
+
+  it("retrieveWorkflow issues a GET and parses the workflow content", () => {
+    const raw = { wid: 5, name: "wf", content: '{"operators":[]}' } as unknown 
as Workflow;
+    let result: Workflow | undefined;
+    service.retrieveWorkflow(5).subscribe(w => (result = w));
+
+    const req = 
httpTestingController.expectOne(`${API}/${WORKFLOW_BASE_URL}/5`);
+    expect(req.request.method).toBe("GET");
+    req.flush(raw);
+
+    // parseWorkflowInfo turns the string content into a parsed object
+    expect(result?.content).toEqual({ operators: [] });
+  });
+
+  it("retrieveWorkflowIDs issues a GET to the workflow-ids url", () => {
+    let result: number[] | undefined;
+    service.retrieveWorkflowIDs().subscribe(ids => (result = ids));
+
+    const req = httpTestingController.expectOne(`${API}/${WORKFLOW_ID_URL}`);
+    expect(req.request.method).toBe("GET");
+    req.flush([1, 2, 3]);
+
+    expect(result).toEqual([1, 2, 3]);
+  });
+
+  it("retrieveOwners issues a GET to the owners url", () => {
+    let result: string[] | undefined;
+    service.retrieveOwners().subscribe(owners => (result = owners));
+
+    const req = 
httpTestingController.expectOne(`${API}/${WORKFLOW_OWNER_URL}`);
+    expect(req.request.method).toBe("GET");
+    req.flush(["[email protected]", "[email protected]"]);
+
+    expect(result).toEqual(["[email protected]", "[email protected]"]);
+  });
+
+  it("searchWorkflows issues a GET to the search url and maps each entry", () 
=> {
+    const params: SearchFilterParameters = {
+      createDateStart: null,
+      createDateEnd: null,
+      modifiedDateStart: null,
+      modifiedDateEnd: null,
+      owners: [],
+      ids: [],
+      operators: [],
+      projectIds: [],
+    };
+    const keywords = ["test"];
+    const entry = { workflow: { wid: 1, name: "w", content: '{"operators":[]}' 
} } as unknown as DashboardWorkflow;
+
+    let result: DashboardWorkflow[] | undefined;
+    service.searchWorkflows(keywords, params).subscribe(r => (result = r));
+
+    const req = 
httpTestingController.expectOne(`${API}/${WORKFLOW_SEARCH_URL}?${toQueryStrings(keywords,
 params)}`);
+    expect(req.request.method).toBe("GET");
+    req.flush([entry]);
+
+    expect(result?.length).toBe(1);
+    // each entry gains a parsed `dashboardWorkflowEntry`
+    expect((result?.[0] as any).dashboardWorkflowEntry.content).toEqual({ 
operators: [] });

Review Comment:
   In `searchWorkflows` test, accessing `(result?.[0] as 
any).dashboardWorkflowEntry` bypasses type checking (the `DashboardWorkflow` 
interface doesn’t declare `dashboardWorkflowEntry`). Prefer an assertion that 
doesn’t require `any`, e.g. `toHaveProperty(...)`, or assert on the typed 
`workflow.content` after parsing.



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