Skip to content

Commit a013d3f

Browse files
Marek DanoMarek Dano
authored andcommitted
fix(ui-rewrite): formatting and unit test failures
Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
1 parent fc64fe6 commit a013d3f

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

client/src/pages/CreateServer.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ describe("CreateServer", () => {
178178
});
179179
});
180180

181+
// Wait a tick to ensure the useEffect that sets selectedComponents has run
182+
await act(async () => {
183+
await new Promise((resolve) => setTimeout(resolve, 0));
184+
});
185+
181186
await act(async () => {
182187
componentMockState.capturedProps?.onSuccess({
183188
name: "Updated GH repo tasks",

client/src/pages/Resources.test.tsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,13 @@ describe("Resources", () => {
268268
expect(screen.getByText("Resource 1")).toBeInTheDocument();
269269
});
270270

271-
const resourceBadge = screen.getByText("Resource 1");
272-
expect(resourceBadge).toHaveAttribute("title", "Description for resource 1");
271+
// CardTag wraps content in a button when tooltip is provided
272+
const resourceBadge = screen.getByText("Resource 1").closest("button");
273+
expect(resourceBadge).not.toBeNull();
274+
275+
// Focus the badge to trigger tooltip (Radix UI behavior)
276+
resourceBadge!.focus();
277+
expect(await screen.findByRole("tooltip")).toHaveTextContent("Description for resource 1");
273278
});
274279

275280
it("renders more options button for each resource group", async () => {
@@ -360,8 +365,17 @@ describe("Resources", () => {
360365
expect(screen.queryByText("Resource 9")).not.toBeInTheDocument();
361366
expect(screen.queryByText("Resource 12")).not.toBeInTheDocument();
362367

363-
expect(screen.getByText("+4")).toBeInTheDocument();
364-
expect(screen.getByTitle("4 more resources")).toBeInTheDocument();
368+
// Check for the +4 badge
369+
const overflowBadge = screen.getByText("+4");
370+
expect(overflowBadge).toBeInTheDocument();
371+
372+
// CardTag wraps content in a button when tooltip is provided
373+
const badgeButton = overflowBadge.closest("button");
374+
expect(badgeButton).not.toBeNull();
375+
376+
// Focus to trigger tooltip
377+
badgeButton!.focus();
378+
expect(await screen.findByRole("tooltip")).toHaveTextContent("4 more resources");
365379
});
366380

367381
it("displays all resources when count is 8 or less without +N tag", async () => {
@@ -396,8 +410,17 @@ describe("Resources", () => {
396410
expect(screen.getByText("gateway-with-nine-resources")).toBeInTheDocument();
397411
});
398412

399-
expect(screen.getByText("+1")).toBeInTheDocument();
400-
expect(screen.getByTitle("1 more resource")).toBeInTheDocument();
413+
// Check for the +1 badge
414+
const overflowBadge = screen.getByText("+1");
415+
expect(overflowBadge).toBeInTheDocument();
416+
417+
// CardTag wraps content in a button when tooltip is provided
418+
const badgeButton = overflowBadge.closest("button");
419+
expect(badgeButton).not.toBeNull();
420+
421+
// Focus to trigger tooltip
422+
badgeButton!.focus();
423+
expect(await screen.findByRole("tooltip")).toHaveTextContent("1 more resource");
401424
});
402425

403426
describe("Dropdown Menu and Details Panel", () => {

client/src/pages/Resources.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,3 @@ export function Resources() {
491491
</div>
492492
);
493493
}
494-

0 commit comments

Comments
 (0)