mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-28 08:09:59 -05:00
* Let the library's playlists go in a side panel, and call the Steam-style layout List (#413) In the Grid layout, View options has a Playlists position choice: Top of library (the tabs as before) or Side panel, which puts All, Updates, Hidden and the playlists down the left, as Quiver Launcher 3's tag filters were. A right-click on the tabs or the panel moves them to the other place. Players who brought a 3.x library over get a one-time tip offering it. Narrow windows, phones and TV mode keep the tabs on top. The Steam-style layout is now called List, so side panel only means the playlists. It's still saved as sidebar, so nothing needs moving over and older launchers read it as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * Lay out the List layout's filters again, and say when a playlist's apps are hidden The grid's centred filter bar rules matched the List layout's filters panel by its id, splitting it into columns. They now leave the panel alone. An empty tab or playlist whose apps are only hidden by the Hidden apps filter says how many there are, with a Show hidden apps button that sets the filter to show them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * Wait for all three cards before the Shift+click range test reads their order The catalog's cards come in after the first one, so on a busy runner the order was read from fewer cards than the range then selected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * Read the Rename dialog's name once it has filled the field The field is filled just after the dialog shows, so on a busy runner the test read it empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * Shift+click selects the range from the card clicked before, however busy the page is The range was worked out in React's update, which can run after the click has already moved the anchor to the card clicked, selecting only that one. It now reads the anchor and the order at the click. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * With the playlists in the side panel, the search goes beside the tools where there's room Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh * Match the Shift+click fix to PR 484's, so the two merge cleanly Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HpW14ydYUX1SCzG2p96Vh --------- Co-authored-by: Claude <noreply@anthropic.com>
292 lines
16 KiB
JavaScript
292 lines
16 KiB
JavaScript
/**
|
||
* The library with a controller: where the focus lands and goes, and its layouts. (controller.js has what these share.)
|
||
*/
|
||
import { test } from "node:test";
|
||
import assert from "node:assert/strict";
|
||
import { openApp } from "./app.js";
|
||
import { app, back, everything, focusIs, focusedSelector, home, installed, open, page, pause, s, state, where, useSharedApp } from "./controller.js";
|
||
import * as reach from "../reach.js";
|
||
|
||
useSharedApp();
|
||
|
||
test("the library: a card's own buttons are its menu's, A plays it and Y opens the menu", async () => {
|
||
await everything("the library", ".library-tile .tile-overlay button");
|
||
});
|
||
|
||
test("the Quiver logo isn't a stop for the d-pad: past the Library tab, it stays", async () => {
|
||
await reach.pressOn(app, ".topbar nav button.active", "DPadLeft");
|
||
await pause(100);
|
||
assert.equal(await app.execute(() => document.activeElement?.matches(".topbar nav button")), true);
|
||
assert.equal(await app.execute(() => document.querySelector(".brand").tabIndex), -1, "nor for Tab");
|
||
});
|
||
|
||
test("the first press lands on Continue playing's Play, else on the library's first card", async () => {
|
||
assert.equal(await focusedSelector(app), "nothing");
|
||
await reach.press(app, "DPadDown");
|
||
assert.equal(await focusedSelector(app), "play");
|
||
const s2 = await openApp({ state: { ...installed, settings: { library: { continuePlaying: false } } } });
|
||
try {
|
||
await s2.page.locator("article[data-slug]").first().waitFor();
|
||
await reach.install(s2.app);
|
||
await reach.press(s2.app, "DPadDown");
|
||
assert.equal(await focusedSelector(s2.app), "card");
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("with a controller there as the library comes, Play has the focus at once", async () => {
|
||
await s.emit("pads", ["Test pad"]);
|
||
await s.until(async () => (await focusedSelector(app)) === "play");
|
||
await s.emit("pads", []);
|
||
});
|
||
|
||
test("up and down go by way of Search and Play, wherever they start across the screen", async () => {
|
||
// The Add an app button, far from Search: up to Play, not the catalog button beside the banner's foot.
|
||
await reach.pressOn(app, ".add-app", "DPadUp");
|
||
assert.equal(await focusedSelector(app), "play");
|
||
await reach.press(app, "DPadDown");
|
||
assert.equal(await focusedSelector(app), "search");
|
||
await reach.press(app, "DPadDown");
|
||
assert.equal(await focusedSelector(app), "card");
|
||
await reach.press(app, "DPadUp");
|
||
assert.equal(await focusedSelector(app), "search");
|
||
// Up from Search, on its row under the tabs and tools: the sort, not the tab over it.
|
||
await reach.press(app, "DPadUp");
|
||
assert.equal(await app.execute(() => document.activeElement?.getAttribute("aria-label")), "Sort");
|
||
// From the far end of the top bar, down: Play too, not past it, or whatever's under that button.
|
||
await reach.pressOn(app, ".topbar button[aria-label='Settings']", "DPadDown");
|
||
const notices = await app.execute(() => document.querySelectorAll(".banner-stack button").length);
|
||
if (notices) await reach.pressOn(app, ".banner-stack button", "DPadDown");
|
||
assert.equal(await focusedSelector(app), "play");
|
||
});
|
||
|
||
test("up to the top of a scrolled page takes one press, not one to scroll and one to move", async () => {
|
||
const s2 = await openApp({ state: installed, height: 520 });
|
||
try {
|
||
const a = s2.app;
|
||
await s2.page.locator("article[data-slug]").first().waitFor();
|
||
await reach.install(a);
|
||
await reach.pressOn(a, ".library-tile .card-open", "DPadUp");
|
||
const seen = [await focusIs(a)];
|
||
for (let i = 0; i < 6 && !(await a.execute(() => Boolean(document.activeElement?.closest(".topbar")))); i++) {
|
||
await reach.press(a, "DPadUp");
|
||
const now = await focusIs(a);
|
||
assert.notEqual(now, seen.at(-1), `every Up moves the focus: after ${seen.join(", ")}`);
|
||
seen.push(now);
|
||
}
|
||
assert.equal(await a.execute(() => Boolean(document.activeElement?.closest(".topbar"))), true);
|
||
await s2.until(() => a.execute(() => document.querySelector(".shell > main").scrollTop === 0));
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("into the library's sidebar from the app beside it, the d-pad lands on the app open", async () => {
|
||
const many = { library: [...state.library, { id: "entry_test-remake", slug: "test-remake", addedAt: Date.now() - 86400_000 }], installs: state.installs };
|
||
const s2 = await openApp({ state: { ...many, settings: { library: { layout: "sidebar" } } }, height: 700 });
|
||
try {
|
||
const a = s2.app;
|
||
await s2.page.locator(".sidebar-row").first().waitFor();
|
||
await reach.install(a);
|
||
await s2.page.locator('.sidebar-row[data-slug="test-remake"]').click();
|
||
await pause(200);
|
||
await reach.pressOn(a, ".library-pane .back-link, .library-pane .app-actions button, .library-pane button", "DPadLeft");
|
||
assert.equal(await a.execute(() => document.activeElement?.dataset.slug), "test-remake");
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("Installed and Not installed are only filters: not tabs that can disagree with them", async () => {
|
||
const tabs = await app.execute(() => [...document.querySelectorAll(".playlists button, .library-show option")].map((b) => b.innerText || b.label));
|
||
assert.ok(tabs.some((name) => name.trim() === "All"));
|
||
assert.ok(!tabs.some((name) => /installed/i.test(name)), tabs.join());
|
||
});
|
||
|
||
test("the library's sidebar layout", async () => {
|
||
await home();
|
||
await open("button", { text: "Library" });
|
||
await open('button[aria-label="View options"]');
|
||
await app.execute(() => [...document.querySelectorAll("button")].find((b) => b.innerText.trim() === "List").focus());
|
||
await reach.press(app, "South");
|
||
await back();
|
||
await everything("the sidebar layout");
|
||
// Down from Play stays in the app's pane, to its tabs, rather than going to the sidebar beside it. Which tab depends
|
||
// on how wide the centred row is: the one under Play.
|
||
await app.execute(() => [...document.querySelectorAll(".app-actions button")].find((b) => b.innerText.trim() === "Play").focus());
|
||
await reach.press(app, "DPadDown");
|
||
assert.match(await reach.focused(app), /^button ".+" in App sections$/);
|
||
});
|
||
|
||
test("the grid's playlists in a side panel: the d-pad gets everywhere, and a right-click puts them back on top", async () => {
|
||
const playlists = [
|
||
{ key: "fav", name: "Favourites", tags: [], consoles: [], apps: ["entry_test-port"], order: 0 },
|
||
{ key: "todo", name: "To finish", tags: [], consoles: [], apps: [], order: 1 },
|
||
];
|
||
const s2 = await openApp({ state: { ...installed, collections: playlists, settings: { library: { playlists: "side" } } } });
|
||
try {
|
||
const { page: p } = s2;
|
||
await p.locator("article[data-slug]").first().waitFor();
|
||
// The tabs and playlists down the left, none along the top.
|
||
assert.deepEqual(await p.locator(".playlist-panel .panel-tab-name").allInnerTexts(), ["All", "Favourites", "To finish"]);
|
||
assert.equal(await p.locator("nav.playlists").count(), 0);
|
||
await p.locator(".panel-tab", { hasText: "Favourites" }).locator("button").first().click();
|
||
assert.equal(await p.locator(".panel-tab.active .panel-tab-name").innerText(), "Favourites");
|
||
// The open playlist's menu beside it.
|
||
assert.equal(await p.locator(".panel-tab.active .menu-button").count(), 1);
|
||
await reach.install(s2.app);
|
||
const { missed, outOfSight } = await reach.explore(s2.app, { ignore: 'button[aria-label="Back to top"], .card-action > .primary:only-of-type, .card-action .get-split > .primary' });
|
||
assert.deepEqual(missed, [], "the d-pad gets to everything");
|
||
assert.deepEqual(outOfSight, []);
|
||
// A right-click on the panel: back along the top, the playlist still open.
|
||
await p.locator(".playlist-panel").click({ button: "right", position: { x: 30, y: 20 } });
|
||
await p.getByRole("menuitem", { name: "Show at top of library" }).click();
|
||
await p.locator("nav.playlists").waitFor();
|
||
assert.equal(await p.locator(".playlist-panel").count(), 0);
|
||
assert.equal(await p.locator(".playlist-tab button.active").innerText(), "Favourites");
|
||
// And from the tabs, to the side again.
|
||
await p.locator("nav.playlists").click({ button: "right", position: { x: 4, y: 10 } });
|
||
await p.getByRole("menuitem", { name: "Show as side panel" }).click();
|
||
await p.locator(".playlist-panel").waitFor();
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("players from Quiver Launcher 3 are offered the side panel once", async () => {
|
||
const s2 = await openApp({ state: { ...installed, settings: { cameFromV3: true, oldLibraryNoticeSeen: true } } });
|
||
try {
|
||
const { page: p } = s2;
|
||
await p.locator(".playlists-tip").waitFor();
|
||
await p.locator(".playlists-tip").getByRole("button", { name: "Show as side panel" }).click();
|
||
await p.locator(".playlist-panel").waitFor();
|
||
assert.equal(await p.locator(".playlists-tip").count(), 0);
|
||
// Answered: not again, along the top once more.
|
||
await p.locator(".playlist-panel").click({ button: "right", position: { x: 30, y: 20 } });
|
||
await p.getByRole("menuitem", { name: "Show at top of library" }).click();
|
||
await p.locator("nav.playlists").waitFor();
|
||
assert.equal(await p.locator(".playlists-tip").count(), 0);
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
// Not for a player who never had 3.x.
|
||
const s3 = await openApp({ state: { ...installed, settings: { oldLibraryNoticeSeen: true } } });
|
||
try {
|
||
await s3.page.locator("article[data-slug]").first().waitFor();
|
||
await s3.page.waitForTimeout(300);
|
||
assert.equal(await s3.page.locator(".playlists-tip").count(), 0);
|
||
} finally {
|
||
await s3.close();
|
||
}
|
||
});
|
||
|
||
test("a playlist whose apps are all hidden says so, and its button shows them, in the grid and the List layout", async () => {
|
||
const playlists = [{ key: "pl", name: "Turtle", tags: [], consoles: [], apps: ["entry_test-port"], order: 0 }];
|
||
for (const layout of ["grid", "sidebar"]) {
|
||
const s2 = await openApp({ state: { ...installed, collections: playlists, settings: { library: { layout }, libraryTab: "pl", hidden: ["entry_test-port"] } } });
|
||
try {
|
||
const { page: p } = s2;
|
||
const note = p.locator(".hidden-note").first();
|
||
await note.waitFor();
|
||
assert.match(await note.innerText(), /1 app in this playlist is hidden\./);
|
||
await note.getByRole("button", { name: "Show hidden apps" }).click();
|
||
await p.locator(layout === "grid" ? "article[data-slug='test-port']" : ".sidebar-row").first().waitFor();
|
||
assert.equal(await p.locator(".hidden-note").count(), 0);
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
}
|
||
});
|
||
|
||
test("the library's sidebar rows line up: one icon size and one name column", async () => {
|
||
// A catalog app with a game (two names) beside one the player added (one name): the two used to have icons of different sizes.
|
||
const mixed = {
|
||
library: [...state.library, { id: "local:mine", slug: "", addedAt: Date.now() - 2 * 86400_000, local: { kind: "program", path: "/games/Test.exe", name: "Test" } }],
|
||
installs: state.installs,
|
||
};
|
||
const s2 = await openApp({ state: { ...mixed, settings: { library: { layout: "sidebar" } } }, height: 700 });
|
||
try {
|
||
// Both rows: the catalog app's shows once the catalog has loaded, a moment after the player's own.
|
||
await s2.page.locator(".sidebar-row").nth(1).waitFor();
|
||
const rows = await s2.page.evaluate(() =>
|
||
[...document.querySelectorAll(".sidebar-row")].map((row) => {
|
||
const icon = row.querySelector(".sidebar-icon")?.getBoundingClientRect();
|
||
const names = row.querySelector(".sidebar-names")?.getBoundingClientRect();
|
||
return { lines: row.getAttribute("data-lines"), icon: icon && `${icon.width}x${icon.height}`, left: names?.left };
|
||
}),
|
||
);
|
||
assert.deepEqual(rows.map((r) => r.lines).sort(), ["1", "2"], "a row with one name and one with two");
|
||
assert.equal(new Set(rows.map((r) => r.icon)).size, 1, `every row's icon is the same size (${rows.map((r) => r.icon).join(", ")})`);
|
||
assert.equal(new Set(rows.map((r) => r.left)).size, 1, `every row's name starts at the same place (${rows.map((r) => r.left).join(", ")})`);
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("A on a dropdown opens its options: the d-pad goes through them, A picks one, and B closes them and goes no further", async () => {
|
||
await home();
|
||
await open("button", { text: "Library" });
|
||
const SORT = ".library-tools select[aria-label=Sort]";
|
||
const picked = () => app.execute((q) => document.querySelector(q).selectedOptions[0].label, SORT);
|
||
const inList = () => app.execute(() => Boolean(document.querySelector(".select-picker")?.contains(document.activeElement)));
|
||
const was = await picked();
|
||
assert.doesNotMatch(await reach.pressOn(app, SORT, "South"), /^not reached/);
|
||
// Its options, the focus on the one picked now.
|
||
assert.deepEqual(
|
||
await app.execute(() => [...document.querySelectorAll(".select-picker [role=option]")].map((o) => o.textContent)),
|
||
await app.execute((q) => [...document.querySelector(q).options].map((o) => o.label), SORT),
|
||
);
|
||
assert.equal(await app.execute(() => document.activeElement.textContent), was);
|
||
// The d-pad keeps to the list.
|
||
await reach.press(app, "DPadLeft");
|
||
assert.ok(await inList(), "Left stays in the list");
|
||
await reach.press(app, "DPadDown");
|
||
assert.ok(await inList(), "Down stays in the list");
|
||
const next = await app.execute(() => document.activeElement.textContent);
|
||
assert.notEqual(next, was);
|
||
await reach.press(app, "South");
|
||
assert.ok(!(await page.locator(".select-picker").count()), "A on an option closes the list");
|
||
assert.equal(await picked(), next);
|
||
assert.equal(await reach.focused(app), 'select "Sort"');
|
||
// B: the list closes, the sort as it was, and the library stays.
|
||
await reach.press(app, "South");
|
||
assert.ok(await inList());
|
||
await reach.press(app, "DPadDown");
|
||
await reach.press(app, "East");
|
||
assert.ok(!(await page.locator(".select-picker").count()), "B closes the list");
|
||
assert.equal(await picked(), next);
|
||
assert.equal(await reach.focused(app), 'select "Sort"');
|
||
assert.equal(await where(), "main");
|
||
});
|
||
|
||
test("at another interface size, the focus box is on what has the focus and a game's ports line up with its card", async () => {
|
||
// Zoomed as Settings' Interface size zooms the page, which WebKit (a Steam Deck's) measures as it lays it out, not as
|
||
// it shows: the box and the list were drawn a fraction of the way toward the window's corner.
|
||
const game = await openApp({
|
||
state: { ...state, settings: { scale: 1.25, library: { byGame: true } }, library: [...state.library, { id: "entry_test-remake", slug: "test-remake", addedAt: Date.now() - 86400_000 }] },
|
||
});
|
||
const { app: g } = game;
|
||
try {
|
||
const CARD = 'article[data-game="test-port"] .card-open';
|
||
await game.page.locator(CARD).waitFor();
|
||
await reach.install(g);
|
||
assert.doesNotMatch(await reach.pressOn(g, CARD, "North"), /^not reached/);
|
||
await game.until(() => g.execute(() => Boolean(document.querySelector(".port-panel")?.contains(document.activeElement))));
|
||
const [panel, card] = await g.execute((q) => [".port-panel", q].map((s) => document.querySelector(s).getBoundingClientRect().toJSON()), CARD);
|
||
assert.ok(Math.min(Math.abs(panel.left - card.left), Math.abs(panel.right - card.right)) < 2, `the list (${panel.left}–${panel.right}) lines up with the card (${card.left}–${card.right})`);
|
||
// Once its glide there is done.
|
||
const off = () =>
|
||
g.execute(() => {
|
||
const [box, el] = [document.querySelector(".pad-halo"), document.activeElement].map((n) => n.getBoundingClientRect());
|
||
return [box.left + box.width / 2 - (el.left + el.width / 2), box.top + box.height / 2 - (el.top + el.height / 2), box.width - el.width];
|
||
});
|
||
await game.until(async () => {
|
||
const [x, y, wider] = await off();
|
||
return Math.abs(x) < 2 && Math.abs(y) < 2 && wider > 0 && wider < 12;
|
||
}).catch(async () => assert.fail(`the focus box is off what has the focus by ${JSON.stringify(await off())}`));
|
||
} finally {
|
||
await game.close();
|
||
}
|
||
});
|