mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-26 07:11:27 -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>
239 lines
13 KiB
JavaScript
239 lines
13 KiB
JavaScript
/**
|
||
* Settings and Downloads with a controller, and the library's background Settings chooses. (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, installed, open, page, pause, s, where, useSharedApp } from "./controller.js";
|
||
import * as reach from "../reach.js";
|
||
|
||
useSharedApp();
|
||
|
||
test("into Settings' list from the section beside it, the d-pad lands on the section open", async () => {
|
||
await page.locator(".topbar button[aria-label='Settings']").click();
|
||
await page.locator(".settings-nav").waitFor();
|
||
await page.locator('.settings-nav [data-section="updates"]').click();
|
||
await pause(100);
|
||
await reach.pressOn(app, ".settings-pane button, .settings-pane input, .settings-pane select", "DPadLeft");
|
||
assert.equal(await app.execute(() => document.activeElement?.getAttribute("data-section")), "updates");
|
||
});
|
||
|
||
test("the player's picture shows behind the library's grid and nowhere else, and Settings chooses it", async () => {
|
||
const picture = "/home/player/Pictures/wall.png";
|
||
const s2 = await openApp({ state: { ...installed, pickBackground: picture } });
|
||
const { page: p, app: a } = s2;
|
||
const behind = p.locator(".library-background img");
|
||
const settingsOpen = async (name) => {
|
||
await p.locator(".topbar button[aria-label='Settings']").click();
|
||
await p.locator(".settings-nav button", { hasText: name }).first().click();
|
||
};
|
||
try {
|
||
await p.locator(".library-grid").waitFor();
|
||
assert.equal(await behind.count(), 0, "none until the player chooses one");
|
||
|
||
await settingsOpen("Library");
|
||
const setting = p.locator('section[aria-label="Library background"]');
|
||
await setting.waitFor();
|
||
await reach.install(a);
|
||
assert.doesNotMatch(await reach.pressOn(a, 'section[aria-label="Library background"] button', "South", { text: "Choose a picture…" }), /^not reached/);
|
||
await setting.getByText("wall.png").waitFor();
|
||
const preview = setting.locator(".background-preview img");
|
||
await preview.waitFor();
|
||
await setting.locator('input[type="range"]').fill("60");
|
||
await s2.until(() => preview.evaluate((i) => i.style.opacity === "0.6"));
|
||
|
||
await s2.page.locator(".topbar nav button", { hasText: "Library" }).click();
|
||
await behind.waitFor({ state: "attached" });
|
||
assert.equal(await behind.evaluate((i) => i.style.opacity), "0.6");
|
||
const placed = await behind.evaluate((i) => {
|
||
const bar = document.querySelector(".topbar").getBoundingClientRect();
|
||
const card = document.querySelector(".library-tile").getBoundingClientRect();
|
||
const box = i.getBoundingClientRect();
|
||
return { wide: box.width === innerWidth, tall: box.height === innerHeight, shown: i.naturalWidth > 0, overBar: document.elementFromPoint(bar.x + bar.width / 2, bar.y + bar.height / 2) === i, overCard: document.elementFromPoint(card.x + card.width / 2, card.y + card.height / 2) === i };
|
||
});
|
||
assert.deepEqual(placed, { wide: true, tall: true, shown: true, overBar: false, overCard: false });
|
||
const scroller = p.locator(".shell > main");
|
||
await scroller.evaluate((m) => m.scrollTo(0, 200));
|
||
assert.equal(await behind.evaluate((i) => i.getBoundingClientRect().y), 0, "stays put as the cards scroll");
|
||
|
||
await p.locator(".topbar nav button", { hasText: "Browse" }).click();
|
||
await behind.waitFor({ state: "detached" });
|
||
await p.locator(".topbar nav button", { hasText: "Library" }).click();
|
||
await behind.waitFor({ state: "attached" });
|
||
await p.locator(".library-tile").first().click();
|
||
await p.locator(".app-page").first().waitFor();
|
||
assert.equal(await behind.isVisible(), false, "not behind an app's page");
|
||
await reach.press(a, "East");
|
||
await behind.waitFor();
|
||
|
||
await settingsOpen("Library");
|
||
await setting.locator("button", { hasText: "Remove" }).click();
|
||
await setting.locator("button", { hasText: "Choose a picture…" }).waitFor();
|
||
await p.locator(".topbar nav button", { hasText: "Library" }).click();
|
||
await p.locator(".library-grid").waitFor();
|
||
assert.equal(await behind.count(), 0);
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
|
||
// The List layout keeps its own background, with the picture still chosen for the grid.
|
||
const s3 = await openApp({ state: { ...installed, settings: { libraryBackground: picture, library: { layout: "sidebar" } } } });
|
||
try {
|
||
await s3.page.locator(".library-split").waitFor();
|
||
assert.equal(await s3.page.locator(".library-background").count(), 0);
|
||
} finally {
|
||
await s3.close();
|
||
}
|
||
|
||
// A file moved or deleted since: Settings says so, and the library goes on without it.
|
||
const s4 = await openApp({ state: { ...installed, settings: { libraryBackground: "/home/player/Pictures/missing.png" } } });
|
||
try {
|
||
await s4.page.locator(".library-grid").waitFor();
|
||
assert.equal(await s4.page.locator(".library-background").count(), 0);
|
||
await s4.page.locator(".topbar button[aria-label='Settings']").click();
|
||
await s4.page.locator(".settings-nav button", { hasText: "Library" }).first().click();
|
||
await s4.page.getByText("Quiver couldn't show that picture.", { exact: false }).waitFor();
|
||
} finally {
|
||
await s4.close();
|
||
}
|
||
});
|
||
|
||
test("Settings' list stays on the screen as the page scrolls, in a window with just room for it", async () => {
|
||
// Room for the list's eight sections, and little more.
|
||
const s2 = await openApp({ state: installed, height: 434 });
|
||
try {
|
||
await s2.page.locator(".topbar").waitFor();
|
||
await s2.page.locator(".topbar button[aria-label='Settings']").click();
|
||
await s2.page.locator(".settings-nav").waitFor();
|
||
for (const section of ["general", "updates"]) {
|
||
await s2.page.locator(`.settings-nav [data-section="${section}"]`).click();
|
||
await pause(100);
|
||
const over = await s2.app.execute(() => {
|
||
const main = document.querySelector(".shell > main");
|
||
const list = document.querySelector(".settings-nav");
|
||
main.scrollTop = main.scrollHeight;
|
||
return [list.getBoundingClientRect().top - main.getBoundingClientRect().top, main.clientHeight - list.offsetHeight];
|
||
});
|
||
assert.ok(over[1] >= 0, "the window has room for all of it");
|
||
assert.ok(over[0] >= 0, `${section}: ${over[0]}px from the top`);
|
||
}
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("Downloads, and every section of Settings", async () => {
|
||
assert.equal(await open('button[aria-label="Downloads"]'), "page: Downloads");
|
||
await everything("Downloads");
|
||
assert.equal(await back(), "main");
|
||
assert.equal(await open('button[aria-label="Settings"]'), "page: Settings");
|
||
const sections = await app.execute(() => [...document.querySelectorAll('nav[aria-label="Settings sections"] button')].map((b) => b.innerText.trim()));
|
||
for (const name of sections) {
|
||
await open('nav[aria-label="Settings sections"] button', { text: name });
|
||
await everything(`Settings › ${name}`);
|
||
}
|
||
});
|
||
|
||
test("tags open in a window of their own, which a controller gets all around, both tabs, ticks in and leaves", async () => {
|
||
assert.equal(await open('button[aria-label="Settings"]'), "page: Settings");
|
||
await open('nav[aria-label="Settings sections"] button', { text: "Library" });
|
||
assert.equal(await open('section[aria-label="Tags"] button', { text: "Manage tags" }), "dialog: Manage tags");
|
||
await everything("Manage tags › Your tags");
|
||
await reach.pressOn(app, '[role="tab"]', "South", { text: "From the catalog" });
|
||
await s.until(() => app.execute(() => Boolean(document.querySelector('[role="dialog"] .catalog-tag'))));
|
||
await everything("Manage tags › From the catalog");
|
||
const box = '[role="dialog"] .catalog-tag input';
|
||
assert.equal(await app.execute((b) => document.querySelector(b).checked, box), true);
|
||
assert.doesNotMatch(await reach.pressOn(app, box, "South"), /^not reached/);
|
||
await s.until(() => app.execute((b) => !document.querySelector(b).checked, box));
|
||
await reach.press(app, "South");
|
||
await s.until(() => app.execute((b) => document.querySelector(b).checked, box));
|
||
assert.equal(await back(), "page: Settings");
|
||
});
|
||
|
||
test("a controller rebinds a control with its own buttons", async () => {
|
||
const binding = 'button[aria-label="Confirm / Select: controller"]';
|
||
assert.equal(await open('button[aria-label="Settings"]'), "page: Settings");
|
||
await open('nav[aria-label="Settings sections"] button', { text: "Controllers" });
|
||
await open(binding);
|
||
assert.equal(await app.execute((b) => document.querySelector(b).innerText, binding), "Press a button…");
|
||
await reach.press(app, "West");
|
||
assert.equal(await app.execute((b) => document.querySelector(b).innerText, binding), "X");
|
||
// X is Confirm now: it rebinds it back to A.
|
||
await app.execute((b) => document.querySelector(b).focus(), binding);
|
||
await reach.press(app, "West");
|
||
await reach.press(app, "South");
|
||
assert.equal(await app.execute((b) => document.querySelector(b).innerText, binding), "A");
|
||
// Swap A and B, with the controller: A swaps them, and then it's B that confirms, so B swaps them back.
|
||
const cells = () => app.execute(() => ["Confirm / Select", "Cancel / Back"].map((a) => document.querySelector(`button[aria-label="${a}: controller"]`).innerText));
|
||
await app.execute(() => [...document.querySelectorAll(".controls label.toggle")].find((l) => l.innerText.startsWith("Swap ")).querySelector("input").focus());
|
||
await reach.press(app, "South");
|
||
await s.until(async () => (await cells()).join() === "B,A");
|
||
await reach.press(app, "East");
|
||
await s.until(async () => (await cells()).join() === "A,B");
|
||
});
|
||
|
||
test("Settings turns off closing a game with Start + Select, and chooses other buttons for it", async () => {
|
||
const s2 = await openApp({ state: installed });
|
||
const { page: p } = s2;
|
||
const last = () => p.evaluate(() => window.__calls.filter((c) => c.cmd === "close_combo").at(-1)?.args);
|
||
try {
|
||
// On from the start.
|
||
await s2.until(async () => (await last())?.on === true);
|
||
await p.locator(".topbar button[aria-label='Settings']").click();
|
||
await p.locator(".settings-nav button", { hasText: "Controllers" }).first().click();
|
||
const toggle = p.locator(".controls label.toggle", { hasText: "Close a game" }).locator("input");
|
||
const buttons = p.locator(".controls .close-combo select");
|
||
const saved = () => p.evaluate(() => window.__calls.filter((c) => c.cmd === "write_state" && c.args.name === "settings").at(-1)?.args.value);
|
||
assert.equal(await toggle.isChecked(), true);
|
||
assert.equal(await buttons.inputValue(), "Start+Select");
|
||
// Other buttons: the sticks pressed in.
|
||
await buttons.selectOption("LeftThumb+RightThumb");
|
||
await s2.until(async () => (await last())?.buttons?.join() === "LeftThumb,RightThumb");
|
||
assert.deepEqual((await saved()).closeCombo, ["LeftThumb", "RightThumb"]);
|
||
await toggle.uncheck();
|
||
await s2.until(async () => (await last())?.on === false);
|
||
assert.equal((await saved()).closeComboOff, true);
|
||
assert.equal(await buttons.isDisabled(), true);
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("Advanced Settings takes a GitLab token, keeps it in the keychain, and shows what it allows", async () => {
|
||
const s2 = await openApp({ state: installed });
|
||
const { page: p } = s2;
|
||
try {
|
||
await p.locator(".topbar button[aria-label='Settings']").click();
|
||
await p.locator('.settings-nav [data-section="advanced"]').click();
|
||
const setting = p.locator('section[aria-label="GitLab token"]');
|
||
await setting.waitFor();
|
||
// Without one, the mock allows fewer requests, and says how many are left.
|
||
await setting.getByText(/499 of 500 requests left/).waitFor();
|
||
await setting.locator('input[type="password"]').fill("glpat-test");
|
||
await setting.getByRole("button", { name: "Save token" }).click();
|
||
await setting.getByText("Saved. Requests to GitLab use your token now.").waitFor();
|
||
// The token was kept in the keychain, not in settings.json: with every host's, under its own host.
|
||
assert.deepEqual(
|
||
await p.evaluate(() => window.__calls.find((c) => c.cmd === "secret_set")?.args),
|
||
{ key: "repositoryTokens", value: JSON.stringify({ "gitlab.com": "glpat-test" }) },
|
||
);
|
||
// It went with the request that checked it, and the mock's higher limit shows.
|
||
assert.ok(s2.api.gitlabRequests().some((r) => r.path === "/gitlab/user" && r.token === "glpat-test"));
|
||
await setting.getByText(/1,999 of 2,000 requests left/).waitFor();
|
||
} finally {
|
||
await s2.close();
|
||
}
|
||
});
|
||
|
||
test("A on a dropdown on a page opens its options, and B closes them without going back a page", async () => {
|
||
assert.equal(await open('button[aria-label="Settings"]'), "page: Settings");
|
||
await open('nav[aria-label="Settings sections"] button', { text: "General" });
|
||
assert.doesNotMatch(await reach.pressOn(app, ".settings-pane select", "South"), /^not reached/);
|
||
assert.ok((await page.locator(".select-picker").count()) > 0, "A opens the list");
|
||
await reach.press(app, "East");
|
||
assert.ok(!(await page.locator(".select-picker").count()), "B closes the list");
|
||
assert.equal(await where(), "page: Settings", "and the page stays");
|
||
assert.match(await reach.focused(app), /^select /);
|
||
});
|