Skip to content

Commit d081bc0

Browse files
committed
fix: fix test errors
1 parent 4487301 commit d081bc0

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

frontend/src/features/base-models/components/__tests__/base-model-card.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ describe("BaseModelCard", () => {
5959
it("renders BaseModelKeywords with the model keywords", () => {
6060
renderCard();
6161
// Default visibleLimit is 3 — all 3 keywords should appear
62-
expect(screen.getAllByText("building-detection")[0]).toBeInTheDocument();
63-
expect(screen.getAllByText("ramp")[0]).toBeInTheDocument();
64-
expect(screen.getAllByText("segmentation")[0]).toBeInTheDocument();
62+
// The component converts hyphens to spaces, and CSS `capitalize` uppercases first letters
63+
// so "building-detection" renders as "Building Detection" in the DOM
64+
expect(screen.getAllByText(/building detection/i)[0]).toBeInTheDocument();
65+
expect(screen.getAllByText(/^ramp$/i)[0]).toBeInTheDocument();
66+
expect(screen.getAllByText(/^segmentation$/i)[0]).toBeInTheDocument();
6567
});
6668
});

frontend/src/features/base-models/components/__tests__/base-model-keywords.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe("BaseModelKeywords", () => {
2828
);
2929
expect(screen.getAllByRole("generic").length).toBeGreaterThanOrEqual(5);
3030
["a", "b", "c", "d", "e"].forEach((kw) => {
31-
expect(screen.getByText(kw)).toBeInTheDocument();
31+
expect(screen.getByText(new RegExp(`^${kw}$`, "i"))).toBeInTheDocument();
3232
});
3333
});
3434

@@ -44,7 +44,7 @@ describe("BaseModelKeywords", () => {
4444

4545
it("renders each keyword in its own badge span", () => {
4646
render(<BaseModelKeywords keywords={["roof", "road"]} visibleLimit={2} />);
47-
const badges = screen.getAllByText(/roof|road/);
47+
const badges = screen.getAllByText(/roof|road/i);
4848
expect(badges).toHaveLength(2);
4949
badges.forEach((badge) => {
5050
expect(badge.tagName.toLowerCase()).toBe("span");

0 commit comments

Comments
 (0)