diff --git a/apps/desktop/src/features/score/ScoreView.tooltip.test.tsx b/apps/desktop/src/features/score/ScoreView.tooltip.test.tsx new file mode 100644 index 000000000..6eea21eb8 --- /dev/null +++ b/apps/desktop/src/features/score/ScoreView.tooltip.test.tsx @@ -0,0 +1,37 @@ +import { render, screen } from "@testing-library/react"; +import { expect, test, vi } from "vitest"; +import { ScoreView } from "./ScoreView"; +import type { RehearsalSong } from "@bandscope/shared-types"; + +vi.mock("../../i18n", () => ({ + detectPreferredLocale: () => "en", + createTranslator: () => (key: string) => key, +})); +vi.mock("./scoreStorage", () => ({ + readScorePdf: vi.fn(), + attachScorePdf: vi.fn(), + removeScorePdf: vi.fn(), +})); +vi.mock("./ScoreViewer", () => ({ + ScoreViewer: () =>
Viewer
, +})); + +test("ScoreView places title on wrapper when remove button is disabled", () => { + const song: RehearsalSong = { + id: "song-1", + title: "Test Song", + scoreAttachments: [{ id: "att-1", fileName: "test.pdf" }], + } as unknown as RehearsalSong; + + // No projectId -> buttons should be disabled + render(); + + const removeButton = screen.getByRole("button", { name: "scoreRemove: test.pdf" }); + expect(removeButton).toBeDisabled(); + + // title should be on the wrapper, NOT the button + expect(removeButton).not.toHaveAttribute("title"); + + const wrapper = removeButton.parentElement; + expect(wrapper).toHaveAttribute("title", "scoreRemove: test.pdf"); +}); diff --git a/apps/desktop/src/features/score/ScoreView.tsx b/apps/desktop/src/features/score/ScoreView.tsx index 72732450f..67eca634a 100644 --- a/apps/desktop/src/features/score/ScoreView.tsx +++ b/apps/desktop/src/features/score/ScoreView.tsx @@ -192,16 +192,21 @@ export function ScoreView({ song, projectId, onSongUpdate }: ScoreViewProps) {