feat(design): a playlist's one action list (C1) — the row's "…", Delete + undo, the header's "…" (E28 S3e2)
- Playlist rows: the X column became the row's "…" (play, pin, copy title/link, move, order,
remove). Remove runs at once, with no confirm; its toast's Undo puts the row back at its index.
The Delete key removes a keyboard-walked row, and focus moves on to the next.
- POST /api/playlists/{id}/items takes an optional `position`, so an undo is one request that
renumbers the list around the row.
- A new `listDelete` key scope. Only a list with `onDelete` registers it, so the help sheet does not
offer Delete where nothing handles it.
- A playlist has one list, `usePlaylistActions.items`: rename, pin, YouTube open/push/revert,
delete. The rail row's "…" and the page header's "…" both open it. Push and revert moved into
the hook; the header keeps Play all.
- Phone-width playlist table: "#" and Channel are hidden below sm (`Column.phoneHidden`). Their
fixed widths had left the title no width.
This commit is contained in:
@@ -23,10 +23,13 @@ vi.mock("./comfortPin", () => ({
|
||||
useComfortPin: () => ({ item: () => [] }),
|
||||
pinPlaylist: (id: number) => id,
|
||||
}));
|
||||
const rename = vi.fn(async () => {});
|
||||
vi.mock("./usePlaylistActions", () => ({
|
||||
usePlaylistActions: () => ({ rename, remove: vi.fn() }),
|
||||
// The real usePlaylistActions builds the menu (the rename row is its first); only the dialogs are
|
||||
// stubbed, and the write is watched at the API.
|
||||
vi.mock("./confirmContext", () => ({
|
||||
useChoice: () => async () => null,
|
||||
useConfirm: () => async () => false,
|
||||
}));
|
||||
const rename = vi.fn(async () => ({}) as never);
|
||||
// The SidePanel/PanelGroups chrome is not what is under test: render the rail's bodies directly.
|
||||
vi.mock("./FilterRail", () => ({
|
||||
default: ({ items }: { items: { id: string; body: ReactNode }[] }) => (
|
||||
@@ -74,6 +77,7 @@ const alpha = {
|
||||
|
||||
async function openRename() {
|
||||
vi.spyOn(api, "playlists").mockResolvedValue([alpha]);
|
||||
vi.spyOn(api, "renamePlaylist").mockImplementation(rename);
|
||||
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
render(
|
||||
<QueryClientProvider client={qc}>
|
||||
@@ -117,3 +121,40 @@ describe("PlaylistsRail · rename from the keyboard", () => {
|
||||
await vi.waitFor(() => expect(document.activeElement).toBe(rowButton()));
|
||||
});
|
||||
});
|
||||
|
||||
// E28 C1: the row's "…" opens the same menu as its right-click — the list's one action list.
|
||||
describe("PlaylistsRail · the row's '…'", () => {
|
||||
it("opens the playlist's menu under the row, and says so", async () => {
|
||||
vi.spyOn(api, "playlists").mockResolvedValue([alpha]);
|
||||
const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
render(
|
||||
<QueryClientProvider client={qc}>
|
||||
<FloatingTree>
|
||||
<PlaylistsRail
|
||||
layout={{} as never}
|
||||
setLayout={() => {}}
|
||||
collapsed={false}
|
||||
onToggleCollapse={() => {}}
|
||||
/>
|
||||
</FloatingTree>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
await screen.findByText("alpha");
|
||||
const more = screen.getByRole("button", { name: "playlists.railMenu" });
|
||||
expect(more.getAttribute("aria-expanded")).toBe("false");
|
||||
fireEvent.click(more);
|
||||
await vi.waitFor(() =>
|
||||
expect(screen.getAllByRole("menuitem", { hidden: true }).map((b) => b.textContent)).toEqual([
|
||||
"playlists.rename",
|
||||
"playlists.exportToYoutube",
|
||||
"playlists.delete",
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
screen.getByRole("button", { name: "playlists.railMenu" }).getAttribute("aria-expanded"),
|
||||
).toBe("true");
|
||||
// It is not inside the row's own button: a button cannot hold a button.
|
||||
expect(more.closest("button")).toBe(more);
|
||||
expect(rowButton()?.contains(more)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user