Skip to content

Commit a5061f7

Browse files
committed
add bread crumb test
1 parent 95b0235 commit a5061f7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

e2e-tests/dashboard/dashboard-layout-sidebar.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ async function checkLinkNameAndNavigateToIt(page: Page, locator: Locator,mobile=
66
await expect(await locator.nth(index).textContent()).toBe(link.name);
77
await locator.nth(index).click();
88
await expect(page).toHaveTitle(`Dashboard - ${link.name}`);
9+
const breadCrumbs = await page.locator('[data-test="OneTSRBreadCrumb"]');
10+
await expect(await breadCrumbs.count()).toBeGreaterThan(0)
11+
const breadCrumbName = link.href.split("/").pop();
12+
await expect(await breadCrumbs.first().textContent()).toBe(breadCrumbName);
913
await page.goBack();
1014
if(mobile){
1115
// open the mobile sidebar again
@@ -70,3 +74,5 @@ test("test mobile dashboard sidebar", async ({ page }) => {
7074
await expect(await mobileSidebarLinks.count()).toBe(dashboard_routes.length);
7175
await checkLinkNameAndNavigateToIt(page, mobileSidebarLinks,true);
7276
});
77+
78+

src/lib/tanstack/router/TSRBreadCrumbs.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export function TSRBreadCrumbs({}: TSRBreadCrumbsProps) {
2222
const { breadcrumb_routes } = useTSRBreadCrumbs();
2323
if (breadcrumb_routes.length < 2) return null;
2424
return (
25-
<div className="gap-0.1 flex flex-wrap p-1 px-3 md:justify-end">
25+
<div
26+
data-test="TSRBreadCrumbs"
27+
className="gap-0.1 flex flex-wrap p-1 px-3 md:justify-end"
28+
>
2629
<Breadcrumb>
2730
<BreadcrumbList>
2831
{breadcrumb_routes.map((crumb) => {
@@ -32,7 +35,10 @@ export function TSRBreadCrumbs({}: TSRBreadCrumbsProps) {
3235
) {
3336
return (
3437
<BreadcrumbItem key={crumb.path}>
35-
<BreadcrumbPage className="hover:text-accent-text line-clamp-1 cursor-pointer text-xs hover:max-w-fit hover:duration-300 hover:animate-in hover:fade-in">
38+
<BreadcrumbPage
39+
data-test="OneTSRBreadCrumb"
40+
className="hover:text-accent-text line-clamp-1 cursor-pointer text-xs hover:max-w-fit hover:duration-300 hover:animate-in hover:fade-in"
41+
>
3642
{crumb.name}
3743
</BreadcrumbPage>
3844
</BreadcrumbItem>

0 commit comments

Comments
 (0)