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


##########
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:
   Agreed, and adopted the suggested split: one test drives 
`getTopLovedEntries` with a tops response that has no action keys (covering 
`topsMap[act] || []` while the search service keeps returning 
`DashboardEntry[]`), and a second stubs `getTopLovedEntries` to resolve maps 
without the keys so `loadTops`'s `|| []` fallbacks run. No stub returns 
`undefined` any more, so `SearchService`'s contract is respected. Branch 
coverage on the file is unchanged at 20/21.
   
   Note the Autofix commit that applied this needed a formatting follow-up — 
its chained `.mockResolvedValueOnce()` call was a single line, which 
`prettier-eslint` reformats, so `format:ci` (and the frontend CI job) failed on 
it. That is fixed in the pushed version.
   



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