Fix brand text test to handle split-element rendering
The nav brand was changed to <span>Groom</span>Book for color styling, but getByText with a regex can't match text split across child elements. Use a custom text matcher that checks the STRONG element's textContent. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -23,7 +23,9 @@ function renderApp(route = "/admin") {
|
|||||||
describe("App navigation", () => {
|
describe("App navigation", () => {
|
||||||
it("renders the Groom Book brand", () => {
|
it("renders the Groom Book brand", () => {
|
||||||
const nav = renderApp();
|
const nav = renderApp();
|
||||||
expect(within(nav).getByText(/Groom\s*Book/)).toBeInTheDocument();
|
expect(
|
||||||
|
within(nav).getByText((_, el) => el?.tagName === "STRONG" && /Groom\s*Book/.test(el.textContent ?? ""))
|
||||||
|
).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders the Book CTA button", () => {
|
it("renders the Book CTA button", () => {
|
||||||
@@ -61,6 +63,8 @@ describe("App navigation", () => {
|
|||||||
</MemoryRouter>
|
</MemoryRouter>
|
||||||
);
|
);
|
||||||
// Customer portal should render at root - no admin nav present
|
// Customer portal should render at root - no admin nav present
|
||||||
expect(screen.queryByText(/Groom\s*Book/)).not.toBeInTheDocument();
|
expect(
|
||||||
|
screen.queryByText((_, el) => el?.tagName === "STRONG" && /Groom\s*Book/.test(el.textContent ?? ""))
|
||||||
|
).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user