Repository navigation
Feature (desktop): qualify pinned sidebar rows with their project name #7575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
apps/desktop/src/renderer/components/WorkspaceNameMarquee/WorkspaceNameMarquee.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { afterAll, afterEach, describe, expect, test } from "bun:test"; | ||
| import { GlobalRegistrator } from "@happy-dom/global-registrator"; | ||
|
|
||
| // happy-dom over the preloaded plain-object document — the marquee measures | ||
| // scrollWidth/clientWidth through refs and a ResizeObserver, so it needs a | ||
| // real DOM. Bun runs test files sequentially in one process and happy-dom's | ||
| // globals are process-wide, so we MUST unregister in afterAll to restore the | ||
| // shared mock document for the other renderer suites. | ||
| const alreadyRegistered = GlobalRegistrator.isRegistered; | ||
| if (!alreadyRegistered) GlobalRegistrator.register(); | ||
| ( | ||
| globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean } | ||
| ).IS_REACT_ACT_ENVIRONMENT = true; | ||
|
|
||
| const { cleanup, render } = await import("@testing-library/react"); | ||
| const { WorkspaceNameMarquee } = await import("./WorkspaceNameMarquee"); | ||
|
|
||
| afterEach(cleanup); | ||
| afterAll(async () => { | ||
| if (!alreadyRegistered) await GlobalRegistrator.unregister(); | ||
| }); | ||
|
|
||
| describe("WorkspaceNameMarquee", () => { | ||
| test("renders the bare name when no prefix is given", () => { | ||
| const { container } = render(<WorkspaceNameMarquee name="local" />); | ||
|
|
||
| const marquee = container.firstElementChild as HTMLElement; | ||
| expect(marquee.textContent).toBe("local"); | ||
| expect(marquee.title).toBe("local"); | ||
| }); | ||
|
|
||
| test("prepends the prefix and a separator to the name", () => { | ||
| const { container } = render( | ||
| <WorkspaceNameMarquee name="local" prefix="Flamaster" />, | ||
| ); | ||
|
|
||
| expect((container.firstElementChild as HTMLElement).textContent).toBe( | ||
| "Flamaster/local", | ||
| ); | ||
| }); | ||
|
|
||
| test("titles the whole prefixed label so a clipped row still reads in full", () => { | ||
| const { container } = render( | ||
| <WorkspaceNameMarquee name="basic_optimization" prefix="Bifrost" />, | ||
| ); | ||
|
|
||
| expect((container.firstElementChild as HTMLElement).title).toBe( | ||
| "Bifrost/basic_optimization", | ||
| ); | ||
| }); | ||
|
|
||
| test("dims the prefix so the workspace name stays the prominent half", () => { | ||
| const { container } = render( | ||
| <WorkspaceNameMarquee name="local" prefix="Flamaster" />, | ||
| ); | ||
|
|
||
| const prefix = container.querySelector(".text-muted-foreground"); | ||
| expect(prefix?.textContent).toBe("Flamaster/"); | ||
| }); | ||
|
|
||
| test("ignores an empty prefix", () => { | ||
| const { container } = render( | ||
| <WorkspaceNameMarquee name="local" prefix="" />, | ||
| ); | ||
|
|
||
| const marquee = container.firstElementChild as HTMLElement; | ||
| expect(marquee.textContent).toBe("local"); | ||
| expect(marquee.title).toBe("local"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add a row-level test for pinned prefix wiring.
DashboardSidebarExpandedWorkspaceRowpasses the project name, the localized"Session"fallback, or no prefix for unpinned rows. The existing tests renderWorkspaceNameMarqueedirectly and do not render this row branch. A regression in this wiring would pass those tests. Add coverage for project-backed, project-less, and unpinned rows.🤖 Prompt for AI Agents