mengw15 commented on code in PR #6536:
URL: https://github.com/apache/texera/pull/6536#discussion_r3609570564
##########
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:
Good point — removed the `any` cast in `63f36ea3`. The test now uses
`toHaveProperty("dashboardWorkflowEntry")` to confirm the mapping adds the
field, plus a typed `result?.[0]?.workflow?.content` check for the parsed
content (`parseWorkflowInfo` mutates the shared workflow in place, so the
entry's own `workflow.content` is parsed too).
--
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]