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


##########
frontend/src/app/hub/component/landing-page/landing-page.component.spec.ts:
##########
@@ -206,4 +206,28 @@ describe("LandingPageComponent", () => {
     component.navigateToSearch("something-else");
     expect(routerNavigateSpy).toHaveBeenCalledWith([HOME]);
   });
+
+  it("leaves currentUid undefined when there is no signed-in user", () => {
+    // The stub seeds a user in its constructor; clear it before the component 
reads it.
+    userService.user = undefined;
+    build();
+    expect(component.isLogin).toBe(false);
+    expect(component.currentUid).toBeUndefined();
+  });
+
+  it("falls back to empty lists when the hub returns no buckets and the 
enrichment yields nothing", async () => {
+    // A tops response without the requested action keys exercises 
`topsMap[act] || []`,
+    // and an enrichment that resolves to nothing exercises the `|| []` guard 
on each
+    // of the three assigned lists (an empty array would be truthy and skip 
them).
+    hubServiceStub.getTops.mockReturnValue(of({}));
+    
searchServiceStub.extendSearchResultsWithHubActivityInfo.mockReturnValue(of(undefined));
+    build();
+
+    await component.loadTops();
+
+    
expect(searchServiceStub.extendSearchResultsWithHubActivityInfo).toHaveBeenCalledWith([],
 true, ["access"]);
+    expect(component.topLovedWorkflows).toEqual([]);
+    expect(component.topClonedWorkflows).toEqual([]);
+    expect(component.topLovedDatasets).toEqual([]);
+  });

Review Comment:
   This test forces `extendSearchResultsWithHubActivityInfo` to return 
`undefined`, but the real implementation always emits a `DashboardEntry[]` (it 
maps `items` and never returns `undefined`). That makes the test cover an 
unrealistic branch and can hide type/contract regressions.
   
   Consider splitting the intent: (1) cover `topsMap[act] || []` by having 
`HubService.getTops` return `{}` while `extendSearchResultsWithHubActivityInfo` 
returns `[]`; and (2) cover `loadTops`’s `workflowEntries["like"] || []` 
fallbacks by mocking `getTopLovedEntries` to resolve missing keys, without 
violating `SearchService`’s contract.



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