mirror of
https://github.com/tgeorgiadis/quiver-launcher.git
synced 2026-11-22 21:50:52 -05:00
Remove the end-to-end tests that ran in WSL (#277)
CI doesn't run these; they ran in WSL through e2e/wsl.sh. This removes the 36 tauri-driver test files, along with e2e/wsl.sh, e2e/run.js and the e2e and e2e:ci scripts, and updates CONTRIBUTING.md to match. The phone, web and live suites stay as they are.
This commit is contained in:
1 parent
b7b9e1db81
commit
bf62f13c3a
45 files changed
+10
-5029
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
# Shell scripts run in Linux (e2e/wsl.sh, from a Windows checkout too): never with Windows line endings.
|
||||
# Shell scripts run in Linux: never with Windows line endings.
|
||||
*.sh text eol=lf
|
||||
# So is the e2e tests' stand-in browser, which the app runs by its shebang (QUIVER_BROWSER).
|
||||
e2e/fake-browser.js text eol=lf
|
||||
|
||||
@@ -36,8 +36,6 @@ jobs:
|
||||
# The translation catalogs list every string in the code: a string added without running extract fails here.
|
||||
- run: pnpm --filter @quiverlauncher/i18n check
|
||||
- run: cargo test --manifest-path apps/launcher/src-tauri/Cargo.toml
|
||||
# The end-to-end tests aren't run here: on the runner, slow and drawing without a GPU, one of them or another
|
||||
# failed most runs for reasons of timing, not of the app. They run in WSL (e2e/wsl.sh).
|
||||
|
||||
# Every screen at Android phones' sizes (e2e/phone.test.js): the web side alone, so no Rust build.
|
||||
phone:
|
||||
|
||||
+4
-14
@@ -71,8 +71,6 @@ corporate version of this agreement. Open an issue and we'll sort it out before
|
||||
- Work on a branch and open a pull request against `main`. Every change is reviewed before it's merged.
|
||||
- Keep each pull request to one change, and describe what a player would see before and after it.
|
||||
- Run `pnpm typecheck` and `pnpm test` before you push.
|
||||
- On Windows, [`e2e/wsl.sh`](e2e/wsl.sh) runs the end-to-end tests as CI's Linux check does, in WSL's Ubuntu 24.04, so
|
||||
a failure there can be tried in minutes rather than a CI run. Its first lines say how to set it up and use it.
|
||||
|
||||
## How the code is laid out
|
||||
|
||||
@@ -81,7 +79,7 @@ corporate version of this agreement. Open an issue and we'll sort it out before
|
||||
| `apps/launcher` | The Tauri app: React UI in `src`, Rust core in `src-tauri` |
|
||||
| `packages/api` | Typed client for the catalog API (`https://api.quiverlauncher.com/api/v1`) |
|
||||
| `packages/ui` | Catalog components and styles shared with quiverlauncher.com |
|
||||
| `e2e` | User journeys run against the real app with WebDriver and a mock catalog |
|
||||
| `e2e` | The web side against a mock catalog, and the real app against the real one |
|
||||
|
||||
`announcement.json` is the banner Quiver Launcher 3 shows. 3.x reads it from `main` here, so it stays at the root even
|
||||
though Quiver Launcher 4 takes its announcements from quiverlauncher.com.
|
||||
@@ -99,17 +97,9 @@ pnpm typecheck && pnpm test
|
||||
cargo test --manifest-path apps/launcher/src-tauri/Cargo.toml
|
||||
```
|
||||
|
||||
End-to-end journeys (Linux and Windows; needs `cargo install tauri-driver`, and on Linux `webkit2gtk-driver` and `xvfb`):
|
||||
|
||||
```sh
|
||||
pnpm --filter @quiver/e2e build
|
||||
xvfb-run -a pnpm e2e
|
||||
```
|
||||
|
||||
On Linux with no display at all, each copy of the app gets a virtual display of its own, so
|
||||
`pnpm --filter @quiver/e2e e2e:ci` can run two test files at once. CI doesn't run these (on its runners
|
||||
they failed for timing, not the app): on Windows, `e2e/wsl.sh` runs them in WSL. The tests against the
|
||||
real catalog (`pnpm --filter @quiver/e2e live`) run once a day in CI.
|
||||
The tests against the real catalog (`pnpm --filter @quiver/e2e live`) run once a day in CI. They need
|
||||
`cargo install tauri-driver`, and on Linux `webkit2gtk-driver` and `xvfb`, with the app built by
|
||||
`pnpm --filter @quiver/e2e build`.
|
||||
|
||||
How every screen looks on Android phones, without one or a build of the app (Chromium, as Playwright installs it):
|
||||
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* The apps folder can move: Settings asks first, moves every installed app
|
||||
* with its files, and apps play and install there from then on, after a
|
||||
* restart too.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const games = join(mkdtempSync(join(tmpdir(), "quiver-drive-")), "Games");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
s = await launch({ env: { QUIVER_PICK_FOLDER: games } });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const settings = () => s.app.$("section.settings-page");
|
||||
const openSettings = () => s.settings("Apps folder");
|
||||
const folderText = async () => (await (await settings()).$("section[aria-label='Apps folder'] p")).getText();
|
||||
|
||||
test("moving the apps folder takes installed apps and their saves along", async () => {
|
||||
const { app, card, apps, until } = s;
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
writeFileSync(join(apps, "test-port", "save.dat"), "my save");
|
||||
|
||||
await openSettings();
|
||||
assert.equal(await folderText(), `Apps are installed in ${apps}`);
|
||||
await (await (await settings()).$("button=Change…")).click();
|
||||
const confirm = await app.$('[role="group"][aria-label="Move apps"]');
|
||||
await confirm.waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await confirm.getText(), new RegExp(`Move 1 installed app to ${games.replace(/[/\\]/g, ".")}`));
|
||||
await (await confirm.$("button=Move apps")).click();
|
||||
await (await (await settings()).$("p*=Moved 1 app")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.equal(await folderText(), `Apps are installed in ${games}`);
|
||||
assert.equal(readFileSync(join(games, "test-port", "save.dat"), "utf8"), "my save");
|
||||
assert.equal(readFileSync(join(games, "test-port", ".quiver-version"), "utf8"), "1.0.0");
|
||||
assert.ok(!existsSync(join(apps, "test-port")), "the old copy is gone");
|
||||
await s.closeSettings();
|
||||
|
||||
// It plays from there, and the next app installs there.
|
||||
await (await (await card("test-port")).$("button*=Play")).click();
|
||||
await until(() => existsSync(join(games, "test-port", "launched.txt")));
|
||||
await (await (await card("tampered-port")).$("button=Get")).waitForDisplayed();
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button=Browse")).click();
|
||||
const remake = await card("test-remake");
|
||||
await (await remake.$("button=Get")).click();
|
||||
await (await remake.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
assert.ok(existsSync(join(games, "test-remake", ".quiver-version")));
|
||||
});
|
||||
|
||||
test("the new folder is kept after a restart", async () => {
|
||||
await s.close();
|
||||
s = await launch({ data: s.data, env: { QUIVER_PICK_FOLDER: games } });
|
||||
await openSettings();
|
||||
assert.equal(await folderText(), `Apps are installed in ${games}`);
|
||||
await s.closeSettings();
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await (await s.card("test-port")).$("button*=Play")).click();
|
||||
// Played again: the file it writes is rewritten.
|
||||
await s.until(() => readFileSync(join(games, "test-port", "launched.txt"), "utf8").includes("played"));
|
||||
});
|
||||
|
||||
test("a folder inside the apps folder, or one with an app's folder name taken, is refused", async () => {
|
||||
await s.close();
|
||||
const taken = mkdtempSync(join(tmpdir(), "quiver-taken-"));
|
||||
mkdirSync(join(taken, "test-port"));
|
||||
s = await launch({ data: s.data, env: { QUIVER_PICK_FOLDER: taken } });
|
||||
await openSettings();
|
||||
await (await (await settings()).$("button=Change…")).click();
|
||||
await (await (await settings()).$("p*=already has a folder named test-port")).waitForDisplayed({ timeout: 10000 });
|
||||
await s.closeSettings();
|
||||
await s.close();
|
||||
s = await launch({ data: s.data, env: { QUIVER_PICK_FOLDER: join(games, "test-port") } });
|
||||
await openSettings();
|
||||
await (await (await settings()).$("button=Change…")).click();
|
||||
await (await (await settings()).$("p=Choose a folder outside the apps folder.")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.ok(existsSync(join(games, "test-port", ".quiver-version")), "nothing moved");
|
||||
});
|
||||
@@ -1,41 +0,0 @@
|
||||
/**
|
||||
* Releases packed as .tar.xz, .tar.bz2 and .tar.zst install and play, as
|
||||
* zips do: from repositories whose only file for this computer is one.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, apps, until;
|
||||
|
||||
before(async () => {
|
||||
s = await launch();
|
||||
({ app, api, apps, until } = s);
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => app.$(".page-layer:not([hidden]) .app-page");
|
||||
|
||||
for (const packing of ["xz", "bz2", "zst"])
|
||||
test(`a release packed as .tar.${packing} installs, keeps its program runnable, and plays`, async () => {
|
||||
// Added in the library: Browse's button is the catalog's submission form.
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button*=Add an app")).click();
|
||||
await (await (await app.$("[role=dialog][aria-label='Add an app']")).$("button*=From GitHub")).click();
|
||||
await (await app.$("input[aria-label=Repository]")).setValue(`someone/packed-${packing}`);
|
||||
await (await app.$("button=Look it up")).click();
|
||||
await (await app.$(`p*=Downloads Packed-linux-x64.tar.${packing}`)).waitForDisplayed({ timeout: 10000 });
|
||||
await (await app.$("button=Add and get")).click();
|
||||
const folder = join(apps, `packed-${packing}`);
|
||||
await until(() => existsSync(join(folder, ".quiver-version")), 30000);
|
||||
assert.equal(readFileSync(join(folder, ".quiver-version"), "utf8"), "v1.0");
|
||||
assert.equal(readFileSync(join(folder, "data/level1.dat"), "utf8"), "level", "the wrapper folder is flattened");
|
||||
assert.deepEqual(api.downloads().slice(-1), [`packed-linux-x64.tar.${packing}`]);
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
await until(() => existsSync(join(folder, "launched.txt")));
|
||||
await app.keys("Escape");
|
||||
});
|
||||
@@ -1,168 +0,0 @@
|
||||
/**
|
||||
* Back without the back link: a mouse's back button, Alt+Left, Escape or a
|
||||
* controller's B close the dialog on top, else go back a page, as the
|
||||
* "← Browse" link does. The mouse's buttons bind in Settings with the keys,
|
||||
* and Settings is a page too.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
s = await launch();
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
/**
|
||||
* A mouse's side button (3 is back, 4 forward), pressed and let go. WebKitGTK's
|
||||
* driver only has the three main buttons, so the events come from the page.
|
||||
*/
|
||||
const mouse = (button) =>
|
||||
s.app.execute((button) => {
|
||||
const target = document.activeElement ?? document.body;
|
||||
for (const type of ["mousedown", "mouseup"]) target.dispatchEvent(new MouseEvent(type, { button, bubbles: true, cancelable: true }));
|
||||
}, button);
|
||||
/** A controller button going down or up, as the Rust side reports it. */
|
||||
const padEvent = (key, down) => s.app.execute((key, down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key, down } }), key, down);
|
||||
/** A controller button, pressed and let go. */
|
||||
const pad = async (key) => {
|
||||
for (const down of [true, false]) await padEvent(key, down);
|
||||
};
|
||||
const onPage = () => s.app.$(".app-page").then((p) => p.isDisplayed());
|
||||
const openPage = async () => {
|
||||
// On its artwork: the middle of a box card is its Get button.
|
||||
await (await (await s.card("test-port")).$(".card-open")).click({ y: -100 });
|
||||
await s.until(onPage);
|
||||
};
|
||||
const backInBrowse = () => s.until(async () => !(await onPage()) && (await (await s.card("test-port")).isDisplayed()));
|
||||
|
||||
test("the mouse's back button goes back a page", async () => {
|
||||
await openPage();
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("Alt+Left and a controller's B go back a page too", async () => {
|
||||
await openPage();
|
||||
await s.app.keys(["Alt", "ArrowLeft"]);
|
||||
await backInBrowse();
|
||||
await openPage();
|
||||
await pad("East");
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("with a dialog open, Back closes it and stays on the page", async () => {
|
||||
await openPage();
|
||||
await (await (await s.app.$(".topbar")).$("button=Sign in")).click();
|
||||
await (await s.app.$('[role="dialog"]')).waitForDisplayed();
|
||||
await mouse(3);
|
||||
await s.until(async () => !(await s.app.$('[role="dialog"]').then((d) => d.isExisting())));
|
||||
assert.equal(await onPage(), true);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("Settings opened over a page goes back to it", async () => {
|
||||
await openPage();
|
||||
await s.settings();
|
||||
assert.equal(await onPage(), false);
|
||||
assert.equal(await (await s.app.$("section.settings-page .back-link")).getText(), "Test Port");
|
||||
await mouse(3);
|
||||
await s.until(onPage);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("the mouse's forward button and Alt+Right open again the page Back left", async () => {
|
||||
await openPage();
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await mouse(4);
|
||||
await s.until(onPage);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await s.app.keys(["Alt", "ArrowRight"]);
|
||||
await s.until(onPage);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("opening another page or another tab leaves Forward nothing to open", async () => {
|
||||
await openPage();
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await s.settings();
|
||||
await mouse(4);
|
||||
await s.app.pause(500);
|
||||
assert.equal(await onPage(), false);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
|
||||
await openPage();
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await mouse(4);
|
||||
await s.app.pause(500);
|
||||
assert.equal(await onPage(), false);
|
||||
await (await s.app.$("button=Browse")).click();
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("Forward, given a controller button, opens no page under a dropdown's list", async () => {
|
||||
await s.settings("Controllers");
|
||||
const forward = await s.app.$("button[aria-label='Forward: controller']");
|
||||
await forward.click();
|
||||
await pad("LeftPaddle1");
|
||||
await s.until(async () => (await forward.getText()) !== "—");
|
||||
await s.closeSettings();
|
||||
await backInBrowse();
|
||||
|
||||
await openPage();
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await s.app.execute(() => [...document.querySelectorAll("select")].find((el) => el.offsetParent).focus());
|
||||
await pad("South");
|
||||
const list = await s.app.$(".select-picker");
|
||||
await list.waitForDisplayed();
|
||||
await pad("LeftPaddle1");
|
||||
await s.app.pause(500);
|
||||
assert.equal(await onPage(), false, "a page opened under the dropdown's list");
|
||||
await pad("East");
|
||||
await s.until(async () => !(await list.isExisting()));
|
||||
});
|
||||
|
||||
test("Forward on a controller opens one page a press, however long it's held", async () => {
|
||||
// Two pages to go forward through: the app's, then Settings over it.
|
||||
await openPage();
|
||||
await s.settings();
|
||||
await mouse(3);
|
||||
await s.until(onPage);
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
await padEvent("LeftPaddle1", true);
|
||||
await s.app.pause(800);
|
||||
await padEvent("LeftPaddle1", false);
|
||||
assert.equal(await onPage(), true, "held, it went on past the app's page");
|
||||
await mouse(3);
|
||||
await backInBrowse();
|
||||
});
|
||||
|
||||
test("Settings shows Back on Esc, Alt+Left and the mouse's back button, and the mouse's buttons rebind", async () => {
|
||||
await s.settings("Controllers");
|
||||
const back = await s.app.$("button[aria-label='Cancel / Back: keyboard']");
|
||||
assert.equal(await back.getText(), "Esc / Alt+← / Mouse back");
|
||||
assert.equal(await (await s.app.$("button[aria-label='Forward: keyboard']")).getText(), "Alt+→ / Mouse forward");
|
||||
const options = await s.app.$("button[aria-label='Options: keyboard']");
|
||||
await options.click();
|
||||
await mouse(4);
|
||||
await s.until(async () => (await options.getText()) === "Mouse forward");
|
||||
await s.until(() => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8")).keys?.options?.[0] === "MouseForward");
|
||||
await s.closeSettings();
|
||||
});
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* Back to top: on a long page, a button in the corner, Home, or a
|
||||
* controller's R3 goes back to the top, with the focus on the top control so
|
||||
* the next move starts from there.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
// A small window, so the catalog runs well past a screen, at the largest interface size it has room for.
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ scale: 2 }));
|
||||
s = await launch({ data });
|
||||
await s.app.setWindowSize(900, 600);
|
||||
await (await s.app.$("article[data-slug]")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
/** A controller button, pressed and let go, as the Rust side reports it. */
|
||||
const pad = async (key) => {
|
||||
for (const down of [true, false])
|
||||
await s.app.execute((key, down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key, down } }), key, down);
|
||||
};
|
||||
const scrolled = () => s.app.execute(() => document.querySelector(".shell > main").scrollTop);
|
||||
const button = () => s.app.$("button[aria-label='Back to top']");
|
||||
/** Focuses the last card's link and scrolls it into view, as moving down to it would. */
|
||||
const toBottom = async () => {
|
||||
await s.app.execute(() => {
|
||||
const last = [...document.querySelectorAll("main article .card-open")].at(-1);
|
||||
last.focus();
|
||||
document.querySelector(".shell > main").scrollTo(0, document.querySelector(".shell > main").scrollHeight);
|
||||
});
|
||||
await s.until(async () => (await scrolled()) > 0 && (await button().then((b) => b.isDisplayed())));
|
||||
};
|
||||
/** The focused control's distance from the top of the page, and whether it's in the page's own content. */
|
||||
const focusAt = () =>
|
||||
s.app.execute(() => {
|
||||
const el = document.activeElement;
|
||||
return { top: el.getBoundingClientRect().top + document.querySelector(".shell > main").scrollTop, inMain: Boolean(el.closest("main")) };
|
||||
});
|
||||
|
||||
test("the button shows only once the page has scrolled, and takes it back to the top", async () => {
|
||||
assert.equal(await button().then((b) => b.isExisting()), false);
|
||||
await toBottom();
|
||||
await (await button()).click();
|
||||
await s.until(async () => (await scrolled()) === 0);
|
||||
await s.until(async () => !(await button().then((b) => b.isExisting())));
|
||||
});
|
||||
|
||||
test("Home goes back to the top and moves the focus up with it", async () => {
|
||||
await toBottom();
|
||||
await s.app.keys("Home");
|
||||
await s.until(async () => (await scrolled()) === 0);
|
||||
const at = await focusAt();
|
||||
assert.ok(at.inMain);
|
||||
assert.ok(at.top < 600, `the focus is near the top (${at.top})`);
|
||||
});
|
||||
|
||||
test("a controller's R3 goes back to the top, and the next move starts there", async () => {
|
||||
await toBottom();
|
||||
const bottom = await scrolled();
|
||||
await pad("RightThumb");
|
||||
await s.until(async () => (await scrolled()) === 0);
|
||||
const at = await focusAt();
|
||||
assert.ok(at.inMain && at.top < 600, `the focus is near the top (${at.top})`);
|
||||
// Moving down from the top doesn't jump back to the bottom.
|
||||
await pad("DPadDown");
|
||||
await new Promise((r) => setTimeout(r, 800));
|
||||
assert.ok((await scrolled()) < bottom / 2);
|
||||
});
|
||||
|
||||
test("Home in a text field stays the field's", async () => {
|
||||
const search = await s.app.$("input[placeholder^=Search]");
|
||||
await search.click();
|
||||
await search.setValue("test");
|
||||
await s.app.execute(() => document.querySelector(".shell > main").scrollTo(0, 400));
|
||||
await s.app.execute(() => document.querySelector("input[placeholder^=Search]").focus({ preventScroll: true }));
|
||||
await s.app.keys("Home");
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
assert.equal(await s.app.execute(() => document.activeElement?.getAttribute("placeholder")?.startsWith("Search")), true);
|
||||
assert.equal(await s.app.execute(() => document.activeElement.selectionStart), 0);
|
||||
await search.clearValue();
|
||||
});
|
||||
|
||||
test("Back to top is in Settings with the other bindings, on Home and R3", async () => {
|
||||
await s.settings("Controllers");
|
||||
assert.equal(await (await s.app.$("button[aria-label='Back to top: keyboard']")).getText(), "Home");
|
||||
assert.equal(await (await s.app.$("button[aria-label='Back to top: controller']")).getText(), "R3");
|
||||
await s.closeSettings();
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* Browse leaves out apps already in the library, as Quiver Launcher 3 does:
|
||||
* one just added stays with its "In library" badge, a note says how many are
|
||||
* left out, and they can be shown again (kept on this computer) or hidden.
|
||||
*/
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, readFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const settings = () => JSON.parse(readFileSync(join(data, "settings.json"), "utf8"));
|
||||
|
||||
test("apps in the library stay out of Browse until the player shows them", async () => {
|
||||
let s = await launch({ data });
|
||||
try {
|
||||
const game = await s.card("test-port");
|
||||
await game.waitForDisplayed({ timeout: 20000 });
|
||||
await (await game.$("button=Get")).click();
|
||||
await (await game.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
// Just added: still here, with its badge.
|
||||
assert.equal((await (await game.$(".cover-badge")).getText()).toLowerCase(), "in library");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
|
||||
s = await launch({ data });
|
||||
try {
|
||||
// With apps in the library, the launcher opens on it.
|
||||
const browse = await s.app.$("button=Browse");
|
||||
await browse.waitForDisplayed({ timeout: 20000 });
|
||||
await browse.click();
|
||||
await (await s.card("tampered-port")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.equal(await (await s.card("test-port")).isExisting(), false);
|
||||
const note = await s.app.$(".owned-note");
|
||||
assert.equal(await note.getText(), "1 app here is already in your library. Show it");
|
||||
await (await note.$("button=Show it")).click();
|
||||
await (await s.card("test-port")).waitForDisplayed();
|
||||
await s.until(() => settings().browseShowsLibrary === true);
|
||||
const shown = await s.app.$(".owned-note");
|
||||
assert.equal(await shown.getText(), "Apps in your library are shown here too. Hide them");
|
||||
await (await shown.$("button=Hide them")).click();
|
||||
await s.until(async () => !(await (await s.card("test-port")).isExisting()));
|
||||
await s.until(() => settings().browseShowsLibrary === undefined);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* A download can be cancelled: nothing is left behind, and an update that's
|
||||
* cancelled leaves the version already installed as it was.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, apps, card, until;
|
||||
|
||||
before(async () => {
|
||||
// The update is started from Browse, so Browse shows apps in the library (browse-owned.test.js covers leaving them out).
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ browseShowsLibrary: true }));
|
||||
s = await launch({ data });
|
||||
({ app, api, apps, card, until } = s);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
api?.stall(false);
|
||||
return s?.close();
|
||||
});
|
||||
|
||||
const staging = () => (existsSync(join(apps, ".staging")) ? readdirSync(join(apps, ".staging")) : []);
|
||||
|
||||
test("cancelling a first download leaves nothing behind, and Get starts again", async () => {
|
||||
api.stall(true);
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await until(() => api.stalled() === 1);
|
||||
await (await port.$("button[aria-label='Cancel downloading Test Port']")).click();
|
||||
// The launcher hangs up, and the card is back to Get with no error.
|
||||
await until(() => api.stalled() === 0);
|
||||
await (await port.$("button=Get")).waitForDisplayed();
|
||||
assert.ok(!(await (await port.$('[role="alert"]')).isExisting()), "no error");
|
||||
assert.ok(!existsSync(join(apps, "test-port")), "nothing was installed");
|
||||
assert.deepEqual(staging(), [], "the half-downloaded file is gone");
|
||||
|
||||
api.stall(false);
|
||||
await (await port.$("button=Get")).click();
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
assert.equal(readFileSync(join(apps, "test-port", ".quiver-version"), "utf8"), "1.0.0");
|
||||
});
|
||||
|
||||
test("cancelling an update keeps the version that was installed", async () => {
|
||||
api.release("1.1.0");
|
||||
api.stall(true);
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button=Browse")).click();
|
||||
const port = await card("test-port");
|
||||
await (await port.$("button=Update to v1.1.0")).click();
|
||||
await until(() => api.stalled() === 1);
|
||||
// On the app's page too.
|
||||
await (await port.$(".card-open")).click();
|
||||
const page = await app.$(".app-page");
|
||||
await (await page.$("button[aria-label='Cancel downloading Test Port']")).click();
|
||||
await (await page.$("button=Update to v1.1.0")).waitForDisplayed();
|
||||
assert.equal(readFileSync(join(apps, "test-port", ".quiver-version"), "utf8"), "1.0.0");
|
||||
assert.ok(existsSync(join(apps, "test-port", "data/level1.dat")), "its files are all there");
|
||||
assert.deepEqual(staging(), []);
|
||||
|
||||
// And it still updates when asked again.
|
||||
api.stall(false);
|
||||
await (await page.$("button=Update to v1.1.0")).click();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "1.1.0", 30000);
|
||||
await app.keys("Escape");
|
||||
api.release("1.0.0");
|
||||
});
|
||||
@@ -1,242 +0,0 @@
|
||||
/**
|
||||
* A library card's menu: behind its ⋯ button, a right-click, the Menu key, a
|
||||
* long press and a controller's Options button, with what the app's page has:
|
||||
* its main action first, then "Play with" its programs, "Add to playlist" and "Manage" beside it.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, apps, card, until, tap;
|
||||
// A home folder with a desktop, so shortcuts land somewhere we can look.
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const opened = join(home, "opened.log");
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(join(home, "Desktop"));
|
||||
s = await launch({ env: { HOME: home, QUIVER_OPENED: opened } });
|
||||
({ app, api, apps, card, until, tap } = s);
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const menu = () => app.$('[role="menu"][aria-label="Test Port menu"]');
|
||||
const items = () => app.execute(() => [...document.querySelectorAll('[role="menu"] [role="menuitem"]')].map((b) => b.textContent));
|
||||
const pick = async (text) => (await (await menu()).$(`button=${text}`)).click();
|
||||
/** Items only Linux has: Test Port has a Linux and a Windows build, and there Windows' runs through Wine. */
|
||||
const onLinux = (...names) => (process.platform === "linux" ? names : []);
|
||||
|
||||
/** Picks an item in the Manage submenu, opening it first. */
|
||||
const manage = async (text) => {
|
||||
await pick("Manage");
|
||||
await pick(text);
|
||||
};
|
||||
/** A library card's ⋯ button, which shows with the card's other buttons while the pointer is on it. */
|
||||
const menuButton = async () => {
|
||||
const port = await card("test-port");
|
||||
await (await port.$(".card-open")).moveTo();
|
||||
return port.$("button[aria-label='Test Port menu']");
|
||||
};
|
||||
const library = async () => {
|
||||
await (await app.$("button=Browse")).click();
|
||||
await (await app.$("button*=Library")).click();
|
||||
};
|
||||
|
||||
test("the ⋯ button on a library card has the app's actions", async () => {
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await menuButton()).click();
|
||||
await (await menu()).waitForDisplayed();
|
||||
assert.deepEqual(await items(), ["Play", "Play with", "Add to playlist", "Manage", "App page"]);
|
||||
await pick("Manage");
|
||||
assert.deepEqual(await items(), ["Play", "Play with", "Add to playlist", "Manage", "Open folder", "Rename folder…", "Desktop shortcut", "Add to Steam", "Change version…", ...onLinux("Switch to the Windows version (Wine)"), "Hide from library", "Uninstall", "Uninstall and remove", "App page"]);
|
||||
await pick("Open folder");
|
||||
await until(() => existsSync(opened) && readFileSync(opened, "utf8").includes(join(apps, "test-port")));
|
||||
await (await menu()).waitForDisplayed({ reverse: true });
|
||||
});
|
||||
|
||||
test("the app's page puts it under the consoles picked, and back under the catalog's; the menu leaves them be", async () => {
|
||||
await (await app.$("main > div:not(.page-layer) select[aria-label='Group by']")).selectByVisibleText("Group by console");
|
||||
// Grouped, every section starts folded away.
|
||||
await (await app.$("main > div:not(.page-layer) button[aria-label='Expand all sections']")).click();
|
||||
const sectionOf = () => app.execute(() => document.querySelector("article[data-slug='test-port']")?.closest(".console-section")?.getAttribute("aria-label"));
|
||||
await until(async () => (await sectionOf()) === "Nintendo 64");
|
||||
// Its consoles are on its page's On this computer tab.
|
||||
const openConsoles = async () => {
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await (await (await app.$(".app-page")).$("button*=On this computer")).click();
|
||||
};
|
||||
await openConsoles();
|
||||
const consoles = await app.$(".app-page section[aria-label=Consoles]");
|
||||
await (await consoles.$("select[aria-label='Add a console']")).selectByVisibleText("Super Nintendo Entertainment System");
|
||||
await (await consoles.$("button[aria-label='Remove console Nintendo 64']")).click();
|
||||
await (await consoles.$("button[aria-label='Remove console Super Nintendo Entertainment System']")).waitForDisplayed();
|
||||
await app.keys("Escape");
|
||||
await until(async () => (await sectionOf()) === "Super Nintendo Entertainment System");
|
||||
await openConsoles();
|
||||
await (await consoles.$("button=Use the catalog's consoles")).click();
|
||||
await (await consoles.$("button[aria-label='Remove console Nintendo 64']")).waitForDisplayed();
|
||||
await app.keys("Escape");
|
||||
await until(async () => (await sectionOf()) === "Nintendo 64");
|
||||
await (await app.$("main > div:not(.page-layer) select[aria-label='Group by']")).selectByVisibleText("No groups");
|
||||
});
|
||||
|
||||
test("a right-click opens it where the pointer is, ready for the keyboard", async () => {
|
||||
await (await (await card("test-port")).$(".card-open")).click({ button: "right" });
|
||||
await (await menu()).waitForDisplayed();
|
||||
assert.equal(await app.execute(() => document.activeElement?.textContent), "Play");
|
||||
assert.ok(!(await (await app.$(".app-page")).isExisting()), "the app's page didn't open");
|
||||
await manage("Desktop shortcut");
|
||||
await until(() => existsSync(join(home, "Desktop", "Test Port.desktop")));
|
||||
await (await app.$('.toast[role="status"]')).waitForDisplayed();
|
||||
await (await app.$('.toast[role="status"]')).click();
|
||||
});
|
||||
|
||||
test("a right-click elsewhere shows no browser menu, but a text field keeps its own", async () => {
|
||||
// Whether the browser would show its menu: nothing cancelled the event.
|
||||
const browserMenu = (tag) =>
|
||||
app.execute((tag) => {
|
||||
const el = document.body.appendChild(document.createElement(tag));
|
||||
const shown = el.dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true, button: 2 }));
|
||||
el.remove();
|
||||
return shown;
|
||||
}, tag);
|
||||
assert.equal(await browserMenu("div"), false);
|
||||
assert.equal(await browserMenu("input"), true);
|
||||
assert.equal(await browserMenu("textarea"), true);
|
||||
});
|
||||
|
||||
test("Shift+F10 and a controller's Options button open it on the focused card", async () => {
|
||||
const focusCard = () => app.execute(() => document.querySelector('article[data-slug="test-port"] .card-open').focus());
|
||||
await focusCard();
|
||||
await app.keys(["Shift", "F10"]);
|
||||
await (await menu()).waitForDisplayed();
|
||||
// Escape closes only the menu, and focus goes back to the card.
|
||||
await app.keys("Escape");
|
||||
await (await menu()).waitForDisplayed({ reverse: true });
|
||||
assert.ok(await app.execute(() => document.activeElement?.matches('article[data-slug="test-port"] .card-open')));
|
||||
await focusCard();
|
||||
await tap("North");
|
||||
await (await menu()).waitForDisplayed();
|
||||
// The controller moves through the menu and presses with A; right goes into a submenu, and B comes back out of it.
|
||||
const press = tap;
|
||||
const focused = (text) => until(async () => (await app.execute(() => document.activeElement?.textContent)) === text);
|
||||
await press("DPadDown");
|
||||
await focused("Play with");
|
||||
await press("DPadDown");
|
||||
await focused("Add to playlist");
|
||||
await press("DPadDown");
|
||||
await focused("Manage");
|
||||
await press("DPadRight");
|
||||
await focused("Open folder");
|
||||
await press("East");
|
||||
await focused("Manage");
|
||||
assert.ok(await (await menu()).isDisplayed(), "B closed only the submenu");
|
||||
await press("South");
|
||||
await focused("Open folder");
|
||||
await press("DPadLeft");
|
||||
await focused("Manage");
|
||||
await press("DPadDown");
|
||||
await focused("App page");
|
||||
await press("South");
|
||||
await (await (await app.$(".app-page")).$("h1=Test Port")).waitForDisplayed();
|
||||
await app.keys("Escape");
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
});
|
||||
|
||||
test("a long press on a touch screen opens it, and the tap doesn't open the app", async () => {
|
||||
await app.execute(async () => {
|
||||
const open = document.querySelector('article[data-slug="test-port"] .card-open');
|
||||
const r = open.getBoundingClientRect();
|
||||
const at = { clientX: r.left + 20, clientY: r.top + 20, pointerType: "touch", bubbles: true, isPrimary: true };
|
||||
open.dispatchEvent(new PointerEvent("pointerdown", at));
|
||||
await new Promise((done) => setTimeout(done, 700));
|
||||
open.dispatchEvent(new PointerEvent("pointerup", at));
|
||||
open.dispatchEvent(new MouseEvent("mousedown", { ...at, bubbles: true }));
|
||||
open.click();
|
||||
});
|
||||
await (await menu()).waitForDisplayed();
|
||||
assert.ok(!(await (await app.$(".app-page")).isDisplayed()), "the app's page didn't open");
|
||||
// A short tap is still a tap.
|
||||
await app.keys("Escape");
|
||||
await app.execute(async () => {
|
||||
const open = document.querySelector('article[data-slug="test-port"] .card-open');
|
||||
open.dispatchEvent(new PointerEvent("pointerdown", { pointerType: "touch", bubbles: true }));
|
||||
open.dispatchEvent(new PointerEvent("pointerup", { pointerType: "touch", bubbles: true }));
|
||||
open.click();
|
||||
});
|
||||
await (await (await app.$(".app-page")).$("h1=Test Port")).waitForDisplayed();
|
||||
assert.ok(!(await (await menu()).isExisting()));
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("Add to playlist puts the app on the player's playlists, and a new one starts with it", async () => {
|
||||
await (await menuButton()).click();
|
||||
await pick("Add to playlist");
|
||||
// Lowercase: WebKit's driver types capitals without Shift here, so "Favourites" would be saved as "favourites".
|
||||
await (await (await menu()).$("input[aria-label='New playlist']")).setValue("favourites");
|
||||
await app.keys("Enter");
|
||||
const favourites = async () => (await menu()).$("button=favourites");
|
||||
await until(async () => (await (await favourites()).getAttribute("aria-checked")) === "true");
|
||||
await (await favourites()).click();
|
||||
await until(async () => (await (await favourites()).getAttribute("aria-checked")) === "false");
|
||||
await (await favourites()).click();
|
||||
await until(async () => (await (await favourites()).getAttribute("aria-checked")) === "true");
|
||||
// Escape closes the submenu, then the menu.
|
||||
await app.keys("Escape");
|
||||
await app.keys("Escape");
|
||||
await (await menu()).waitForDisplayed({ reverse: true });
|
||||
await s.showTab("favourites");
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
await s.showTab("All");
|
||||
});
|
||||
|
||||
test("hiding from the menu moves the app to Hidden, and showing it brings it back", async () => {
|
||||
await (await menuButton()).click();
|
||||
await manage("Hide from library");
|
||||
await until(async () => !(await (await card("test-port")).isExisting()));
|
||||
await s.showTab("Hidden (1)");
|
||||
await (await menuButton()).click();
|
||||
await manage("Show in library");
|
||||
await s.showTab("All");
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
});
|
||||
|
||||
test("an update is in the menu when there is one", async () => {
|
||||
api.release("1.1.0");
|
||||
await library();
|
||||
await (await menuButton()).click();
|
||||
await pick("Update to v1.1.0");
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "1.1.0", 30000);
|
||||
api.release("1.0.0");
|
||||
});
|
||||
|
||||
test("Uninstall deletes the files and keeps the app in the library to get again", async () => {
|
||||
await (await menuButton()).click();
|
||||
await manage("Uninstall");
|
||||
await (await (await app.$("[role=dialog]")).$("button=Uninstall")).click();
|
||||
await until(() => !existsSync(join(apps, "test-port")));
|
||||
const port = await card("test-port");
|
||||
await until(async () => (await (await port.$(".card-status")).getProperty("textContent")) === "Not installed");
|
||||
await (await menuButton()).click();
|
||||
assert.deepEqual(await items(), ["Get", "Add to playlist", "Manage", "App page"]);
|
||||
await pick("Manage");
|
||||
assert.deepEqual(await items(), ["Get", "Add to playlist", "Manage", "Choose a version…", "Locate existing install…", ...onLinux("Get the Windows version (Wine)"), "Hide from library", "Remove from library", "App page"]);
|
||||
await pick("Get");
|
||||
await (await port.$(".card-open")).moveTo();
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
});
|
||||
|
||||
test("Uninstall and remove takes it out of the library", async () => {
|
||||
await (await menuButton()).click();
|
||||
await manage("Uninstall and remove");
|
||||
await (await (await app.$("[role=dialog]")).$("button=Uninstall and remove")).click();
|
||||
await until(() => !existsSync(join(apps, "test-port")));
|
||||
await until(async () => !(await (await card("test-port")).isExisting()));
|
||||
});
|
||||
@@ -1,137 +0,0 @@
|
||||
/**
|
||||
* Downloads, like Steam's: a button in the top bar in every layout, a strip
|
||||
* above the library while something is happening, and the Sidebar layout's
|
||||
* foot all open one page of what's downloading, the updates waiting, and what
|
||||
* finished since the launcher started.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, card, until;
|
||||
|
||||
before(async () => {
|
||||
// The update is found from Browse, so Browse shows apps in the library. The usage-data notice already answered: the
|
||||
// strip offering updates is one of the banners that wait behind it.
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ browseShowsLibrary: true, telemetryNoticeSeen: true }));
|
||||
s = await launch({ data });
|
||||
({ app, api, card, until } = s);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
api?.stall(false);
|
||||
return s?.close();
|
||||
});
|
||||
|
||||
const button = () => app.$(".topbar .downloads-button");
|
||||
const page = () => app.$(".downloads-page");
|
||||
const section = async (name) => (await page()).$(`section[aria-label="${name}"]`);
|
||||
/** The apps in a section of the page, by slug. */
|
||||
const rows = (name) =>
|
||||
app.execute((name) => [...document.querySelectorAll(`.downloads-page section[aria-label="${name}"] .download-row`)].map((r) => r.dataset.slug), name);
|
||||
|
||||
test("a download shows on the top-bar button, in the strip, and on the page with its Cancel", async () => {
|
||||
assert.equal(await (await button()).getAttribute("aria-label"), "Downloads");
|
||||
api.stall(true);
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await until(() => api.stalled() === 1);
|
||||
await until(async () => (await (await button()).getAttribute("aria-label")).startsWith("Downloads: 1 downloading"));
|
||||
const strip = await app.$(".downloads-strip");
|
||||
await until(async () => (await strip.getText()).startsWith("Downloading Test Port"));
|
||||
|
||||
await (await strip.$("button=See downloads")).click();
|
||||
await (await page()).waitForDisplayed();
|
||||
assert.equal(await (await button()).getAttribute("aria-current"), "page");
|
||||
assert.deepEqual(await rows("Downloading"), ["test-port"]);
|
||||
assert.ok(await (await (await section("Downloading")).$("button[aria-label='Cancel downloading Test Port']")).isDisplayed());
|
||||
assert.equal(await (await (await section("Updates available")).$(".muted")).getText(), "Everything is up to date.");
|
||||
|
||||
// It finishes while the page is open, and moves to Recently finished with its Play.
|
||||
api.stall(false);
|
||||
await until(async () => (await rows("Recently finished")).includes("test-port"), 30000);
|
||||
assert.deepEqual(await rows("Downloading"), []);
|
||||
const done = await (await section("Recently finished")).$(".download-row");
|
||||
assert.match(await (await done.$(".download-detail")).getText(), /^Installed v1\.0\.0 · Today /);
|
||||
assert.ok(await (await done.$("button*=Play")).isDisplayed());
|
||||
assert.equal(await (await button()).getAttribute("aria-label"), "Downloads");
|
||||
|
||||
// Back goes to Browse, where it started, and the strip has gone.
|
||||
await (await (await page()).$(".back-link")).click();
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
assert.ok(!(await (await app.$(".downloads-strip")).isExisting()));
|
||||
});
|
||||
|
||||
test("an update waiting shows as a count, in the strip, and on the page, which installs it", async () => {
|
||||
api.release("1.1.0");
|
||||
// Browse, opened again, brings in the new release.
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button=Browse")).click();
|
||||
await s.untilCardShows("test-port", "button=Update to v1.1.0");
|
||||
await (await app.$("button*=Library")).click();
|
||||
await until(async () => (await (await button()).getAttribute("aria-label")) === "Downloads: 1 waiting");
|
||||
assert.equal(await (await app.$(".downloads-count")).getText(), "1");
|
||||
const strip = await app.$(".downloads-strip");
|
||||
assert.equal(await (await strip.$("p")).getText(), "1 update available.");
|
||||
// Not now puts it away until another update comes.
|
||||
await (await strip.$("button=Not now")).click();
|
||||
await until(async () => !(await (await app.$(".downloads-strip")).isExisting()));
|
||||
|
||||
await (await button()).click();
|
||||
assert.deepEqual(await rows("Updates available"), ["test-port"]);
|
||||
const update = await (await section("Updates available")).$(".download-row");
|
||||
assert.equal(await (await update.$(".download-detail")).getText(), "v1.1.0 is out. You have v1.0.0.");
|
||||
// What's new in it, and Update: Play comes once it's updated.
|
||||
assert.deepEqual(await update.$$(".download-action button").map((b) => b.getText()), ["See changelog", "Update to v1.1.0"]);
|
||||
// The name opens the app's page, and Back comes back here.
|
||||
await (await update.$("button.download-name")).click();
|
||||
await (await app.$(".app-page")).waitForDisplayed();
|
||||
await (await app.$(".app-page .back-link")).click();
|
||||
await (await page()).waitForDisplayed();
|
||||
|
||||
await (await (await (await section("Updates available")).$(".download-row")).$("button=Update to v1.1.0")).click();
|
||||
await until(async () => (await rows("Updates available")).length === 0, 30000);
|
||||
await until(async () => {
|
||||
const detail = await app.$(".downloads-page section[aria-label='Recently finished'] .download-detail");
|
||||
return (await detail.isExisting()) && (await detail.getText()).startsWith("Updated to v1.1.0");
|
||||
}, 30000);
|
||||
// One row for the app, its latest download.
|
||||
assert.deepEqual(await rows("Recently finished"), ["test-port"]);
|
||||
const finished = await (await section("Recently finished")).$(".download-row");
|
||||
assert.deepEqual(await finished.$$(".download-action button").map((b) => b.getText()), ["See changelog", "Play"]);
|
||||
await (await (await section("Recently finished")).$("button=Clear all")).click();
|
||||
assert.deepEqual(await rows("Recently finished"), []);
|
||||
await app.keys("Escape");
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
api.release("1.0.0");
|
||||
});
|
||||
|
||||
test("in the Sidebar layout the way to Downloads is at the sidebar's foot, in place of the strip", async () => {
|
||||
await (await app.$("button[aria-label='View options']")).click();
|
||||
await (await (await app.$(".view-panel [aria-label='Layout']")).$("button=Sidebar")).click();
|
||||
await app.keys("Escape");
|
||||
const foot = () => app.$(".sidebar-foot .sidebar-downloads");
|
||||
await (await foot()).waitForDisplayed();
|
||||
assert.equal(await (await foot()).getText(), "Downloads");
|
||||
|
||||
api.release("1.2.0");
|
||||
await (await app.$("button=Browse")).click();
|
||||
await s.untilCardShows("test-port", "button=Update to v1.2.0");
|
||||
// Browse's strip is only for downloads under way: the updates waiting are the library's to offer.
|
||||
assert.ok(!(await (await app.$(".downloads-strip")).isExisting()));
|
||||
await (await app.$("button*=Library")).click();
|
||||
await until(async () => (await (await foot()).getText()) === "1 update available");
|
||||
assert.ok(!(await (await app.$(".downloads-strip")).isExisting()), "no strip beside the sidebar");
|
||||
|
||||
await (await foot()).click();
|
||||
await (await page()).waitForDisplayed();
|
||||
assert.deepEqual(await rows("Updates available"), ["test-port"]);
|
||||
await (await (await page()).$(".back-link")).click();
|
||||
await (await app.$(".library-sidebar")).waitForDisplayed();
|
||||
api.release("1.0.0");
|
||||
});
|
||||
@@ -1,144 +0,0 @@
|
||||
/**
|
||||
* Player feedback on an app's page, as on the website: anyone sees what
|
||||
* players said, the releases and the project's details; sharing how it ran
|
||||
* asks a signed-out player to sign in first, then saves, and saving again
|
||||
* updates it.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, until;
|
||||
|
||||
before(async () => {
|
||||
s = await launch();
|
||||
({ app, api, until } = s);
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => app.$(".page-layer:not([hidden]) .app-page");
|
||||
/** A tab of the open page, by its label. */
|
||||
const tab = async (name) => {
|
||||
const tabs = await (await page()).$$("button[role=tab]");
|
||||
for (const t of tabs) if ((await t.getText()).startsWith(name)) return t;
|
||||
throw new Error(`no ${name} tab`);
|
||||
};
|
||||
const rows = () =>
|
||||
app.execute(() =>
|
||||
[...document.querySelectorAll(".page-layer:not([hidden]) .feedback article.review")].map((r) => ({
|
||||
author: r.querySelector(".review-author strong").textContent,
|
||||
said: r.querySelector(".result-badge").textContent.trim(),
|
||||
meta: r.querySelector(".review-author small").textContent,
|
||||
})),
|
||||
);
|
||||
|
||||
test("anyone sees what players said, the releases and the project's details", async () => {
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
// What they said, in the box at the page's top; all of it on Player feedback.
|
||||
assert.match(await (await (await page()).$(".feedback-box .score")).getText(), /Runs well · 3 players/);
|
||||
await (await tab("Player feedback")).click();
|
||||
await until(async () => (await (await tab("Player feedback")).getAttribute("aria-selected")) === "true");
|
||||
assert.match(await (await tab("Player feedback")).getText(), /3/);
|
||||
await until(async () => (await rows()).length === 2);
|
||||
assert.deepEqual(
|
||||
(await rows()).map((r) => [r.author, r.said]),
|
||||
[
|
||||
["ada", "Runs well"],
|
||||
["lin", "Runs with issues"],
|
||||
],
|
||||
);
|
||||
assert.match((await rows())[0].meta, /Linux · tested on v1\.0\.0/);
|
||||
assert.ok(api.catalogQueries().some((q) => q.path === "reviews:list" && q.args.slug === "test-port"));
|
||||
// Releases, and the project's details at the top of Overview.
|
||||
await (await tab("Releases")).click();
|
||||
await until(() => app.execute(() => document.querySelector(".page-layer:not([hidden]) .release-summary strong")?.textContent === "1.0.0"));
|
||||
await (await tab("Overview")).click();
|
||||
const details = await (await page()).$("section[aria-label='Project details']");
|
||||
assert.match(await details.getText(), /MADE BY\s+Quiver Tester/i);
|
||||
assert.match(await details.getText(), /No AI use found/);
|
||||
});
|
||||
|
||||
test("sharing how it ran signs in first, then the form opens and saves", async () => {
|
||||
await (await tab("Player feedback")).click();
|
||||
assert.match(await (await (await page()).$(".share-prompt")).getText(), /Sign in to share how it runs for you/);
|
||||
await (await (await page()).$("button*=Share how it ran")).click();
|
||||
const signIn = await app.$("[role=dialog][aria-label='Sign in']");
|
||||
await signIn.waitForDisplayed({ timeout: 10000 });
|
||||
await (await signIn.$("button=Create an account")).click();
|
||||
await (await signIn.$("input[placeholder=Username]")).setValue("player");
|
||||
const password = await signIn.$("input[placeholder=Password]");
|
||||
await password.setValue("correct horse battery");
|
||||
// Its button shows what was typed, and hides it again.
|
||||
assert.equal(await password.getAttribute("type"), "password");
|
||||
await (await signIn.$("button[aria-label='Show password']")).click();
|
||||
assert.equal(await password.getAttribute("type"), "text");
|
||||
await (await signIn.$("button[aria-label='Hide password']")).click();
|
||||
assert.equal(await password.getAttribute("type"), "password");
|
||||
await (await signIn.$("form button.primary")).click();
|
||||
// Signed in, the form it asked for opens.
|
||||
await (await (await page()).$("h3=How did it go?")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await (await page()).$("button*=It ran, but I had issues")).click();
|
||||
await (await (await page()).$("textarea")).setValue("Needs the controller set up first.");
|
||||
await (await (await page()).$("button=Share")).click();
|
||||
await (await (await page()).$("p*=You've shared how it ran")).waitForDisplayed({ timeout: 10000 });
|
||||
const os = process.platform === "win32" ? "windows" : "linux";
|
||||
assert.deepEqual(api.reviews.at(-1), { entryId: "entry_test-port", result: "issues", body: "Needs the controller set up first.", platform: os, user: "player" });
|
||||
// Theirs is in the list, marked as theirs.
|
||||
await until(async () => (await rows()).some((r) => r.author === "playerYou"));
|
||||
assert.equal((await rows()).find((r) => r.author === "playerYou").said, "Runs with issues");
|
||||
});
|
||||
|
||||
test("saving again updates the player's feedback instead of adding more", async () => {
|
||||
await (await (await page()).$("button*=Update your notes")).click();
|
||||
await (await (await page()).$("h3=Update your notes")).waitForDisplayed({ timeout: 10000 });
|
||||
// What they said before is there to change.
|
||||
await until(async () => (await (await (await page()).$("textarea")).getValue()) === "Needs the controller set up first.");
|
||||
await (await (await page()).$("button*=It worked well")).click();
|
||||
await (await (await page()).$("button=Update notes")).click();
|
||||
await (await (await page()).$("p*=You've shared how it ran")).waitForDisplayed({ timeout: 10000 });
|
||||
await until(async () => (await rows()).find((r) => r.author === "playerYou")?.said === "Runs well");
|
||||
assert.equal((await rows()).filter((r) => r.author === "playerYou").length, 1);
|
||||
});
|
||||
|
||||
test("the box at the page's top closes once used, the focus going to the form's answer", async () => {
|
||||
await (await tab("Overview")).click();
|
||||
const box = await (await page()).$(".feedback-box");
|
||||
await (await box.$("button.feedback-box-toggle")).click();
|
||||
await (await box.$("button=Update your feedback")).click();
|
||||
await (await (await page()).$("h3=Update your notes")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await box.getAttribute("data-open"), null);
|
||||
// Their answer from before.
|
||||
await until(() =>
|
||||
app.execute(() => {
|
||||
const at = document.activeElement;
|
||||
return Boolean(at?.closest(".result-options") && at.getAttribute("aria-pressed") === "true" && at.textContent.startsWith("It worked well"));
|
||||
}),
|
||||
);
|
||||
await (await (await page()).$("button=Cancel")).click();
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("a newer release still being checked shows as on the website", async () => {
|
||||
await (await (await s.card("test-remake")).$(".card-open")).click();
|
||||
// Over the list of releases.
|
||||
await (await tab("Releases")).click();
|
||||
const line = await (await page()).$(".release-checking-line");
|
||||
await line.waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await line.getText(), "Version v1.1.0 is unverified · waiting for a maintainer");
|
||||
// In release order with the verified one, saying why once opened.
|
||||
await until(async () => (await (await page()).$$("article.release")).length === 2);
|
||||
const [newer, verified] = await (await page()).$$("article.release");
|
||||
assert.match(await newer.getAttribute("class"), /release-unverified/);
|
||||
const text = await newer.getText();
|
||||
assert.match(text, /^v1\.1\.0[\s\S]*Unverified/);
|
||||
assert.doesNotMatch(text, /It changes how the app is built\./);
|
||||
assert.match(await verified.getText(), /^1\.0\.0[\s\S]*Verified[\s\S]*Fixes a crash on start\./);
|
||||
await (await newer.$("button.release-summary")).click();
|
||||
await until(async () => /It changes how the app is built\./.test(await newer.getText()));
|
||||
const link = await newer.$("a*=View v1.1.0 on GitHub");
|
||||
await link.waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await link.getAttribute("href"), "https://github.com/quiver/test-remake/releases/tag/v1.1.0");
|
||||
await app.keys("Escape");
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* Choosing a folder in the launcher's own browser (file-picker.tsx), as it
|
||||
* asks in Steam's Game Mode in place of the system's dialog; QUIVER_OWN_PICKER
|
||||
* asks it here.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
// A portable 3.x somewhere the launcher doesn't look by itself.
|
||||
const old = join(home, "Downloads", "Old Stuff", "QuiverLauncher-linux");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(join(old, "Apps", "TestPort"), { recursive: true });
|
||||
writeFileSync(join(old, "Apps", "TestPort", "port.sh"), "#!/bin/sh\n", { mode: 0o755 });
|
||||
writeFileSync(join(old, "apps.json"), JSON.stringify({ Apps: [{ Name: "Test Port", Repository: "quiver/test-port", FolderName: "TestPort" }] }));
|
||||
s = await launch({ env: { HOME: home, QUIVER_OWN_PICKER: "1" } });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const picker = () => s.app.$('[role=dialog][aria-label="Choose your Quiver Launcher 3 folder"]');
|
||||
const settings = () => s.app.$("section.settings-page");
|
||||
const row = async (name) => (await (await picker()).$(".file-picker-list")).$(`button=${name}`);
|
||||
|
||||
test("a folder is chosen by going into it from a place, and Settings finds the library there", async () => {
|
||||
await s.settings("Library");
|
||||
await (await (await settings()).$("button=Choose my Quiver Launcher 3 folder…")).click();
|
||||
await (await picker()).waitForDisplayed({ timeout: 10000 });
|
||||
// It starts at home; Downloads is a place to start from.
|
||||
await (await (await (await picker()).$(".file-picker-places")).$("button=Downloads")).click();
|
||||
await (await row("Old Stuff")).click();
|
||||
await (await row("QuiverLauncher-linux")).click();
|
||||
await s.until(async () => (await (await (await picker()).$(".file-picker-path span")).getText()) === old);
|
||||
// Up goes back to the folder around it, and in again.
|
||||
await (await (await picker()).$("button*=Up")).click();
|
||||
await (await row("QuiverLauncher-linux")).click();
|
||||
await (await (await picker()).$("button=Choose this folder")).click();
|
||||
await (await picker()).waitForDisplayed({ reverse: true });
|
||||
await (await (await settings()).$("p*=1 app, already installed")).waitForDisplayed({ timeout: 10000 });
|
||||
});
|
||||
|
||||
test("Escape, a controller's B, cancels it and nothing is chosen", async () => {
|
||||
await (await (await settings()).$("button=Look in another folder…")).click();
|
||||
const looking = await s.app.$('[role=dialog][aria-label="Choose a folder to look in"]');
|
||||
await looking.waitForDisplayed({ timeout: 10000 });
|
||||
await s.app.keys("Escape");
|
||||
await looking.waitForDisplayed({ reverse: true });
|
||||
assert.ok(!(await (await (await settings()).$("p*=That folder doesn't have Quiver Launcher 3")).isExisting()));
|
||||
assert.ok(await (await settings()).isDisplayed(), "still in Settings: the Escape was the picker's");
|
||||
});
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Releases that are a Flatpak bundle, or one in a zip: installed for the
|
||||
* player with flatpak, played with `flatpak run`, and uninstalled with the
|
||||
* app. A stand-in `flatpak` on PATH records what it was asked to do.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const bin = mkdtempSync(join(tmpdir(), "quiver-bin-"));
|
||||
const log = join(mkdtempSync(join(tmpdir(), "quiver-flatpak-")), "log");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
// Installs read the bundle's ref, as flatpak does; everything is logged.
|
||||
writeFileSync(
|
||||
join(bin, "flatpak"),
|
||||
`#!/bin/sh
|
||||
echo "$*" >> "${log}"
|
||||
case "$1" in install) for last; do :; done; grep -aq "app/" "$last" || exit 1 ;; esac
|
||||
exit 0
|
||||
`,
|
||||
{ mode: 0o755 },
|
||||
);
|
||||
s = await launch({ env: { PATH: `${bin}:${process.env.PATH}` } });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => s.app.$(".page-layer:not([hidden]) .app-page");
|
||||
const ran = () => (existsSync(log) ? readFileSync(log, "utf8") : "");
|
||||
|
||||
const addFromGitHub = async (repository, file) => {
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.app.$("button*=Add an app")).click();
|
||||
await (await (await s.app.$("[role=dialog][aria-label='Add an app']")).$("button*=From GitHub")).click();
|
||||
await (await s.app.$("input[aria-label=Repository]")).setValue(repository);
|
||||
await (await s.app.$("button=Look it up")).click();
|
||||
await (await s.app.$(`p*=Downloads ${file}`)).waitForDisplayed({ timeout: 10000 });
|
||||
await (await s.app.$("button=Add and get")).click();
|
||||
};
|
||||
|
||||
for (const [repository, file, id] of [
|
||||
["someone/flat-game", "FlatGame-x86_64.flatpak", "com.example.FlatGame"],
|
||||
["someone/zipped-flat", "ZippedFlat-linux.zip", "com.example.ZippedFlat"],
|
||||
])
|
||||
test(`${file} installs with flatpak, plays with flatpak run, and uninstalls`, async () => {
|
||||
await addFromGitHub(repository, file);
|
||||
const folder = join(s.apps, repository.split("/")[1]);
|
||||
await s.until(() => existsSync(join(folder, ".quiver-flatpak")), 30000);
|
||||
assert.equal(readFileSync(join(folder, ".quiver-flatpak"), "utf8"), id);
|
||||
assert.match(ran(), new RegExp(`^install --user --noninteractive -y --bundle .*\\.flatpak$`, "m"));
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
await s.until(() => ran().includes(`run ${id}`));
|
||||
await (await (await page()).$("button=Uninstall and remove")).click();
|
||||
await (await (await s.app.$("[role=dialog]")).$("button=Uninstall and remove")).click();
|
||||
await s.until(() => ran().includes(`uninstall --user --noninteractive -y ${id}`));
|
||||
assert.ok(!existsSync(folder));
|
||||
});
|
||||
|
||||
test("without Flatpak on the computer, the install says so", async () => {
|
||||
await s.close();
|
||||
s = await launch({ env: { PATH: "/usr/bin:/bin" } });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await addFromGitHub("someone/flat-game", "FlatGame-x86_64.flatpak");
|
||||
await (await s.app.$("p*=Flatpak isn't installed on this computer")).waitForDisplayed({ timeout: 30000 });
|
||||
});
|
||||
@@ -1,197 +0,0 @@
|
||||
/**
|
||||
* App and game pages, as on quiverlauncher.com: opening and leaving pages
|
||||
* never blanks the window, a search shows the original games it matches
|
||||
* above the apps, and a game's page compares the apps that play it. The
|
||||
* catalog comes from the site's REST API.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let s, app, api, card, until;
|
||||
|
||||
before(async () => {
|
||||
// Two apps a page, so paging through the API's cursor is tried too.
|
||||
api = await startMockApi({ pageSize: 2 });
|
||||
s = await launch({ api });
|
||||
({ app, card, until } = s);
|
||||
await (await card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
// Newer WebView2 returns a Promise from scrollTo; act like it everywhere, so a page that returns it from an effect fails here too.
|
||||
await app.execute(() => {
|
||||
for (const target of [window, Element.prototype]) {
|
||||
const scroll = target.scrollTo;
|
||||
target.scrollTo = function (...args) {
|
||||
scroll.apply(this, args);
|
||||
return Promise.resolve();
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await s?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
// Pages under the top one stay mounted, hidden.
|
||||
const page = () => app.$(".page-layer:not([hidden]) .app-page");
|
||||
/** The catalog's cards, in order (under the front page's shelves, which have cards of their own). */
|
||||
const listed = () => app.execute(() => [...document.querySelectorAll("main > div:not(.page-layer) .catalog-grid article")].map((a) => a.dataset.slug));
|
||||
const text = async (selector, scope = page()) => (await (await scope).$(selector)).getText();
|
||||
const search = async (value) => {
|
||||
const box = await app.$("input[placeholder^=Search]");
|
||||
if (value) await box.setValue(value);
|
||||
else {
|
||||
// Typed away, so the page hears it.
|
||||
await box.click();
|
||||
await app.keys(["Control", "a"]);
|
||||
await app.keys("Backspace");
|
||||
}
|
||||
// On once the whole of it is searched. Typed a key at a time, a busy runner can pause past the search's wait
|
||||
// mid-word, so "test" is searched before "test po": its games show, then go for the next search's, and a button
|
||||
// found among them is left out of the page, never displayed.
|
||||
await until(async () => (await box.getValue()) === value && (api.catalogQueries().findLast((q) => q.path === "catalog:list")?.args.search ?? "") === value.trim());
|
||||
};
|
||||
const gameButton = (slug) => app.$(`.search-games button[data-game="${slug}"]`);
|
||||
/** Errors the window logged, which a blank window would have. */
|
||||
const uiErrors = () => {
|
||||
const log = join(s.data, "quiver.log");
|
||||
return existsSync(log) ? readFileSync(log, "utf8").split("\n").filter((line) => / ui: /.test(line)) : [];
|
||||
};
|
||||
const rootFilled = () => app.execute(() => document.getElementById("root").childElementCount > 0);
|
||||
|
||||
test("opening an app and going back never blanks the window", async () => {
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Port");
|
||||
await (await (await page()).$("button.back-link")).click();
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
assert.ok(await rootFilled());
|
||||
// Escape goes back too, and the catalog is still there after a second visit.
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await (await page()).waitForDisplayed();
|
||||
await app.keys("Escape");
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
assert.ok(await rootFilled());
|
||||
assert.deepEqual(uiErrors(), []);
|
||||
});
|
||||
|
||||
test("the rest of the catalog pages in with the API's cursor as Show more nears the screen", async () => {
|
||||
// Under the shelves: scrolled down to, as a player would, it goes on by itself.
|
||||
await until(async () => (await listed()).length >= 2);
|
||||
await app.execute(() => document.querySelector("main > div:not(.page-layer) .more")?.scrollIntoView({ block: "end" }));
|
||||
await until(async () => (await listed()).length === 3);
|
||||
assert.deepEqual(await listed(), ["test-port", "tampered-port", "test-remake"]);
|
||||
assert.ok(!(await app.$("button=Show more").isExisting()), "the last page has no Show more");
|
||||
// The shelves ask the API for their few apps too, without a cursor.
|
||||
const last = api.catalogQueries().filter((q) => q.path === "catalog:list" && q.args.paginationOpts?.cursor).at(-1);
|
||||
assert.deepEqual(last.args.paginationOpts, { numItems: 48, cursor: "2" });
|
||||
});
|
||||
|
||||
test("a search shows the games it matches above the apps, from the site's API", async () => {
|
||||
await search("test po");
|
||||
const section = await app.$("section[aria-label='Matching games']");
|
||||
await section.waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal((await text("h2", section)).toUpperCase(), "GAMES");
|
||||
const game = await gameButton("test-port");
|
||||
assert.match(await game.getText(), /Test Port \(original\)/);
|
||||
assert.match(await game.getText(), /2 ways to play →/);
|
||||
assert.equal(await (await app.$(".results-bar")).getText(), "Results for “test po”");
|
||||
// Apps follow under their own label.
|
||||
assert.equal(await app.execute(() => document.querySelector(".search-games").nextElementSibling.textContent.toUpperCase()), "APPS");
|
||||
assert.ok(api.catalogQueries().some((q) => q.path === "catalog:matchingGames" && q.args.search === "test po"));
|
||||
assert.ok(api.catalogQueries().some((q) => q.path === "catalog:list" && q.args.search === "test po"));
|
||||
// One letter isn't enough to look for games.
|
||||
await search("t");
|
||||
await until(async () => !(await section.isExisting()) || !(await section.isDisplayed()));
|
||||
});
|
||||
|
||||
test("a game opens as a page with its apps best first, and Back retraces the way", async () => {
|
||||
await search("test po");
|
||||
await (await gameButton("test-port")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await gameButton("test-port")).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Port (original)");
|
||||
assert.equal(await text(".eyebrow"), "THE ORIGINAL GAME");
|
||||
assert.match(await text(".game-description"), /The 1996 original\./);
|
||||
assert.equal(await text(".detail-tags"), "Nintendo 64");
|
||||
assert.match(await (await (await page()).$(".box-art img")).getAttribute("src"), /\/art\/capsule\.png$/);
|
||||
assert.match(await (await (await page()).$(".backdrop-art")).getAttribute("src"), /\/art\/hero\.png$/);
|
||||
await (await (await page()).$(".catalog-grid")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await text(".tab-count"), "2");
|
||||
assert.equal(await text(".section-top .muted"), "Best first, by player feedback");
|
||||
// The site lists Test Remake first; players say Test Port runs, so it comes first.
|
||||
const order = await app.execute(() => [...document.querySelectorAll(".game-page article")].map((a) => a.dataset.slug));
|
||||
assert.deepEqual(order, ["test-port", "test-remake"]);
|
||||
assert.equal(await text("button.back-link"), "Back to results for “test po”");
|
||||
|
||||
// An app from the game's page, from the keyboard as with a controller, and back to the game with focus where it was.
|
||||
await app.execute(() => document.querySelector('.page-layer:not([hidden]) article[data-slug="test-remake"] .card-open').focus());
|
||||
await app.keys("Enter");
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Remake");
|
||||
assert.equal(await text("button.back-link"), "Test Port (original)");
|
||||
await app.keys("Escape");
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Port (original)");
|
||||
assert.equal(await app.execute(() => document.activeElement?.closest("article")?.dataset.slug), "test-remake");
|
||||
// Its "Based on" chip goes back to the game already open, not a second copy of it.
|
||||
await (await (await (await page()).$('article[data-slug="test-remake"]')).$(".card-open")).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Remake");
|
||||
await (await (await page()).$('.app-hero button.game-chip[data-game="test-port"]')).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Test Port (original)");
|
||||
assert.equal(await text("button.back-link"), "Back to results for “test po”");
|
||||
|
||||
// Escape returns to the search as it was.
|
||||
await app.keys("Escape");
|
||||
await (await gameButton("test-port")).waitForDisplayed();
|
||||
assert.equal(await (await app.$("input[placeholder^=Search]")).getValue(), "test po");
|
||||
assert.ok(await (await card("test-port")).isDisplayed());
|
||||
assert.deepEqual(uiErrors(), []);
|
||||
});
|
||||
|
||||
test("an app's Based on chip opens its game, even one with no artwork", async () => {
|
||||
await search("");
|
||||
await (await card("tampered-port")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await (await card("tampered-port")).$(".card-open")).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Tampered Port");
|
||||
await (await (await page()).$('.app-hero button.game-chip[data-game="tampered-port"]')).click();
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Tampered Port (original)");
|
||||
await (await (await page()).$(".catalog-grid")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await text(".tab-count"), "1");
|
||||
assert.equal(await text(".section-top .muted"), "Community ports and recreations");
|
||||
assert.equal(await text("button.back-link"), "Tampered Port");
|
||||
assert.ok(!(await (await page()).$(".backdrop-art").isExisting()), "no backdrop without art");
|
||||
assert.ok(!(await (await page()).$(".game-description").isExisting()), "no empty description");
|
||||
assert.ok(await (await page()).$(".app-hero .artwork svg").isExisting(), "the placeholder icon stands in for box art");
|
||||
// Escape goes back one page at a time.
|
||||
await app.keys("Escape");
|
||||
await until(async () => (await text("h1").catch(() => "")) === "Tampered Port");
|
||||
await app.keys("Escape");
|
||||
await (await card("tampered-port")).waitForDisplayed();
|
||||
assert.deepEqual(uiErrors(), []);
|
||||
});
|
||||
|
||||
test("the Quiver logo, as on the website, goes to the library", async () => {
|
||||
const logo = await app.$(".topbar button.brand");
|
||||
await until(() => app.execute(() => document.querySelector(".topbar .brand img").naturalWidth > 0));
|
||||
await logo.click();
|
||||
await (await app.$("h2=Your library is empty")).waitForDisplayed();
|
||||
await (await app.$("button=Browse")).click();
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
});
|
||||
|
||||
// Last: it leaves an error in the log on purpose.
|
||||
test("a page that fails says so and goes back, keeping the search", async () => {
|
||||
await search("broken");
|
||||
await (await gameButton("broken-game")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await gameButton("broken-game")).click();
|
||||
const problem = await app.$(".page-layer:not([hidden]) [role=alert]");
|
||||
await problem.waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await problem.getText(), /This page hit a problem/);
|
||||
assert.equal(await text("button.back-link", problem), "Back to results for “broken”");
|
||||
await until(() => uiErrors().length > 0, 5000); // The error is in quiver.log.
|
||||
// Escape works there too, and the catalog is as it was.
|
||||
await app.keys("Escape");
|
||||
await (await gameButton("broken-game")).waitForDisplayed();
|
||||
assert.equal(await (await app.$("input[placeholder^=Search]")).getValue(), "broken");
|
||||
});
|
||||
@@ -1,28 +0,0 @@
|
||||
/**
|
||||
* A GitHub token an earlier version saved as plain text in settings.json
|
||||
* moves to where secrets are kept (account.json here, as QUIVER_DATA is set;
|
||||
* the keychain otherwise), and requests to GitHub still use it.
|
||||
*/
|
||||
import { after, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
test("a token left in settings.json moves out of it", async () => {
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ githubToken: "ghp_good" }));
|
||||
s = await launch({ data });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
const read = (name) => JSON.parse(readFileSync(join(data, name), "utf8"));
|
||||
assert.equal(read("account.json").githubToken, "ghp_good");
|
||||
assert.equal(read("settings.json").githubToken, undefined);
|
||||
await s.settings("Advanced");
|
||||
const section = await s.app.$('section.settings-page section[aria-label="GitHub token"]');
|
||||
await s.until(async () => /^4\D?999 of 5\D?000 requests left this hour/.test(await (await section.$("p[role=status]")).getText()));
|
||||
});
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* A GitHub token in Settings: one GitHub refuses isn't saved, a good one
|
||||
* raises the limit Settings shows and goes with every request to GitHub,
|
||||
* and removing it stops that.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
s = await launch();
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const section = () => s.app.$('section.settings-page section[aria-label="GitHub token"]');
|
||||
const status = async () => (await (await section()).$("p[role=status]")).getText();
|
||||
// With QUIVER_DATA set the keychain isn't used: secrets go to account.json, and never to settings.json.
|
||||
const read = (name) => {
|
||||
try {
|
||||
return JSON.parse(readFileSync(join(s.data, name), "utf8"));
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
const saved = () => {
|
||||
assert.equal(read("settings.json").githubToken, undefined);
|
||||
return read("account.json").githubToken;
|
||||
};
|
||||
const enter = async (token) => {
|
||||
await (await (await section()).$("input[aria-label='GitHub token']")).setValue(token);
|
||||
await (await (await section()).$("button=Save token")).click();
|
||||
};
|
||||
|
||||
test("a token GitHub accepts is saved and used; one it refuses isn't", async () => {
|
||||
const { app, api, until } = s;
|
||||
await s.settings("Advanced");
|
||||
await until(async () => /^59 of 60 requests left this hour/.test(await status()));
|
||||
|
||||
await enter("bad-token");
|
||||
await until(async () => /GitHub didn't accept that token, so it wasn't saved/.test(await (await section()).getText()));
|
||||
assert.equal(saved(), undefined);
|
||||
|
||||
await enter("ghp_good");
|
||||
await until(async () => /Saved\. Requests to GitHub use your token now\./.test(await (await section()).getText()));
|
||||
await until(() => saved() === "ghp_good");
|
||||
// Grouped as the system's language has it: "4,999", "4 999" or "4999".
|
||||
await until(async () => /^4\D?999 of 5\D?000 requests left this hour/.test(await status()));
|
||||
|
||||
// An app added from GitHub asks with the token.
|
||||
await app.keys("Escape");
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button*=Add an app")).click();
|
||||
await (await (await app.$("[role=dialog][aria-label='Add an app']")).$("button*=From GitHub or GitLab")).click();
|
||||
await (await app.$("input[aria-label=Repository]")).setValue("someone/homebrew");
|
||||
await (await app.$("button=Look it up")).click();
|
||||
await until(() => api.githubRequests().some((r) => r.path === "/github/repos/someone/homebrew/releases"));
|
||||
assert.equal(api.githubRequests().findLast((r) => r.path === "/github/repos/someone/homebrew/releases").token, "ghp_good");
|
||||
await app.keys("Escape");
|
||||
|
||||
// Removed, nothing is sent.
|
||||
await s.settings("Advanced");
|
||||
await (await (await section()).$("button=Remove token")).click();
|
||||
await until(() => saved() === undefined);
|
||||
await until(async () => /^59 of 60 requests left this hour/.test(await status()));
|
||||
assert.equal(api.githubRequests().at(-1).token, null);
|
||||
});
|
||||
@@ -1,303 +0,0 @@
|
||||
/**
|
||||
* A portable Quiver Launcher 3 keeps its library beside itself, wherever the
|
||||
* player put it: found by itself in the usual places (Downloads here), and
|
||||
* anywhere else from Settings.
|
||||
*/
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, renameSync, utimesSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
/**
|
||||
* A portable 3.x folder with Test Port installed in its Apps folder, as 3.x
|
||||
* writes it; without version.txt, as 3.x leaves an install it hasn't looked at.
|
||||
*/
|
||||
function portableLibrary(dir, { version = true } = {}) {
|
||||
const installed = join(dir, "Apps", "TestPort");
|
||||
mkdirSync(installed, { recursive: true });
|
||||
if (version) writeFileSync(join(installed, "version.txt"), "v1.0.0");
|
||||
writeFileSync(join(installed, "port.sh"), '#!/bin/sh\ncd "$(dirname "$0")" && echo played > launched.txt\n', { mode: 0o755 });
|
||||
writeFileSync(join(dir, "QuiverLauncher.AppImage"), "");
|
||||
writeFileSync(join(dir, "settings.json"), "{}");
|
||||
writeFileSync(join(dir, "apps.json"), JSON.stringify({ Apps: [{ Name: "Test Port", Repository: "quiver/test-port", FolderName: "TestPort" }] }));
|
||||
return installed;
|
||||
}
|
||||
|
||||
const bringOver = async (s, installed) => {
|
||||
await (await s.app.$("button=Add 1 app")).click();
|
||||
await playIt(s, installed);
|
||||
};
|
||||
|
||||
/** Plays Test Port where 3.x installed it. */
|
||||
const playIt = async ({ card, until }, installed) => {
|
||||
// The library redraws as the apps come over, so look the card up afresh until Play shows.
|
||||
const play = async () => (await card("test-port")).$("button*=Play");
|
||||
await until(() => play().then((b) => b.isDisplayed()).catch(() => false));
|
||||
await (await play()).click();
|
||||
await until(() => existsSync(join(installed, "launched.txt")));
|
||||
};
|
||||
|
||||
test("a portable 3.x in Downloads is found when the launcher starts", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const installed = portableLibrary(join(home, "Downloads", "QuiverLauncher-linux"));
|
||||
const s = await launch({ env: { HOME: home } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
const banner = await s.app.$(".old-library-notice");
|
||||
await (await banner.$("strong=Bring your apps over from Quiver Launcher 3?")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await banner.getText(), /1 app, already installed\./);
|
||||
// Nothing looks moved, so there's no folder to ask about.
|
||||
assert.ok(!(await (await banner.$("button*=folder")).isExisting()));
|
||||
await bringOver(s, installed);
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("Not now on the banner stands, and Settings can still bring the library over", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const folder = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
const installed = portableLibrary(folder);
|
||||
let s = await launch({ env: { HOME: home } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
await (await (await s.app.$(".old-library-notice")).$("button=Not now")).click();
|
||||
await s.until(async () => !(await (await s.app.$(".old-library-notice")).isExisting()));
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
s = await launch({ data: s.data, env: { HOME: home, QUIVER_PICK_FOLDER: folder } });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
assert.ok(!(await (await s.app.$(".old-library-notice")).isExisting()), "it isn't asked again");
|
||||
await s.settings("Library");
|
||||
const page = await s.app.$("section.settings-page");
|
||||
await (await page.$("button=Choose my Quiver Launcher 3 folder…")).click();
|
||||
await (await page.$("button=Add 1 app")).click();
|
||||
await (await page.$("p=Your apps are in your library.")).waitForDisplayed({ timeout: 20000 });
|
||||
await s.closeSettings();
|
||||
await playIt(s, installed);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("a banner whose installs look moved asks for the folder, and one more folder finds them", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const folder = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
portableLibrary(folder);
|
||||
const moved = join(home, "Games");
|
||||
renameSync(join(folder, "Apps"), moved);
|
||||
const s = await launch({ env: { HOME: home, QUIVER_PICK_FOLDER: moved } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
const banner = await s.app.$(".old-library-notice");
|
||||
await (await banner.$("button=Choose a folder…")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await banner.getText(), /1 app, not installed yet/);
|
||||
await (await banner.$("button=Choose a folder…")).click();
|
||||
await s.until(async () => /1 app, already installed/.test(await banner.getText()));
|
||||
assert.ok(!(await (await banner.$("button=Choose a folder…")).isExisting()));
|
||||
await bringOver(s, join(moved, "TestPort"));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("a 3.x beside the launcher is the one found, over another elsewhere", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const left = portableLibrary(join(home, "Downloads", "QuiverLauncher-linux"));
|
||||
// The player put this launcher's AppImage in the folder of the 3.x they play from.
|
||||
const copy = join(mkdtempSync(join(tmpdir(), "quiver-elsewhere-")), "Quiver");
|
||||
const installed = portableLibrary(copy);
|
||||
// Older than the other, which would otherwise win as the one 3.x saved last.
|
||||
utimesSync(join(copy, "apps.json"), new Date(2025, 0, 1), new Date(2025, 0, 1));
|
||||
const s = await launch({ env: { HOME: home, APPIMAGE: join(copy, "QuiverLauncher_4.0.0_amd64.AppImage") } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
await bringOver(s, installed);
|
||||
assert.ok(!existsSync(join(left, "launched.txt")));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* A library brought over when its installs couldn't be seen, as the first betas left a custom Apps folder; they can be
|
||||
* now. Returns where Test Port is installed, and the running launcher's home and data to open them again.
|
||||
*/
|
||||
async function broughtOverWithoutInstalls() {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const copy = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
const installed = portableLibrary(copy);
|
||||
const apps = join(copy, "Apps");
|
||||
renameSync(apps, `${apps}-away`);
|
||||
const s = await launch({ env: { HOME: home } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
await (await s.app.$("button=Add 1 app")).click();
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
// The library's saved before this copy stops.
|
||||
await s.until(async () => !(await (await s.app.$(".old-library-notice")).isExisting()));
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
renameSync(`${apps}-away`, apps);
|
||||
return { installed, home, data: s.data };
|
||||
}
|
||||
|
||||
test("installs that couldn't be seen when a library came over are offered once, and played from where they are", async () => {
|
||||
const { installed, home, data } = await broughtOverWithoutInstalls();
|
||||
let s = await launch({ data, env: { HOME: home } });
|
||||
try {
|
||||
await (await s.app.$("p*=1 app in your library shows as not installed")).waitForDisplayed({ timeout: 20000 });
|
||||
await (await s.app.$("button=Use it")).click();
|
||||
await playIt(s, installed);
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
s = await launch({ data, env: { HOME: home } });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
assert.ok(!(await (await s.app.$(".old-library-notice")).isExisting()), "it isn't asked again");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("an app in the library can be pointed at the folder it's installed in, which has to hold an app", async () => {
|
||||
const { installed, home, data } = await broughtOverWithoutInstalls();
|
||||
const locate = async (s) => {
|
||||
const port = await s.card("test-port");
|
||||
await (await port.$(".card-open")).moveTo();
|
||||
await (await port.$("button[aria-label='Test Port menu']")).click();
|
||||
const menu = () => s.app.$('[role="menu"][aria-label="Test Port menu"]');
|
||||
await (await (await menu()).$("button=Manage")).click();
|
||||
await (await (await menu()).$("button=Locate existing install…")).click();
|
||||
};
|
||||
const notNow = async (s) => {
|
||||
await (await s.app.$("p*=1 app in your library shows as not installed")).waitForDisplayed({ timeout: 20000 });
|
||||
await (await (await s.app.$(".old-library-notice")).$("button=Not now")).click();
|
||||
};
|
||||
const empty = mkdtempSync(join(tmpdir(), "quiver-empty-"));
|
||||
let s = await launch({ data, env: { HOME: home, QUIVER_PICK_FOLDER: empty } });
|
||||
try {
|
||||
await notNow(s);
|
||||
await locate(s);
|
||||
await (await s.app.$("p=That folder doesn't have an installed app in it.")).waitForDisplayed({ timeout: 10000 });
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
s = await launch({ data, env: { HOME: home, QUIVER_PICK_FOLDER: installed } });
|
||||
try {
|
||||
await locate(s);
|
||||
await playIt(s, installed);
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("an app in the library can be pointed at its folder from On this computer", async () => {
|
||||
const { installed, home, data } = await broughtOverWithoutInstalls();
|
||||
const s = await launch({ data, env: { HOME: home, QUIVER_PICK_FOLDER: installed } });
|
||||
try {
|
||||
await (await (await s.app.$(".old-library-notice")).$("button=Not now")).click();
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
const page = await s.app.$(".app-page");
|
||||
await (await page.$("button*=On this computer")).click();
|
||||
await (await (await page.$(".computer-panel")).$("button*=Locate existing install")).click();
|
||||
await (await page.$("button*=Play")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("an app that isn't in the library can be pointed at its folder from its page, and joins the library", async () => {
|
||||
const installed = portableLibrary(mkdtempSync(join(tmpdir(), "quiver-elsewhere-")));
|
||||
const s = await launch({ env: { QUIVER_PICK_FOLDER: installed } });
|
||||
try {
|
||||
await s.usageNoticeSeen();
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
await (await (await s.app.$(".app-page")).$("button*=Locate existing install")).click();
|
||||
await s.until(async () => (await (await s.app.$(".app-page")).$("button*=Add to library").isExisting()) === false && (await (await s.app.$(".app-page")).$("button*=Open folder").isExisting()));
|
||||
await (await (await s.app.$(".app-page")).$("button*=Play")).click();
|
||||
await s.until(() => existsSync(join(installed, "launched.txt")));
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("an app whose folder moved offers to find it where it went, keeping its history", async () => {
|
||||
const { installed, home, data } = await broughtOverWithoutInstalls();
|
||||
const page = () => s.app.$(".app-page");
|
||||
let s = await launch({ data, env: { HOME: home, QUIVER_PICK_FOLDER: installed } });
|
||||
try {
|
||||
await (await s.app.$("button=Use it")).click();
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
const moved = `${installed}-moved`;
|
||||
renameSync(installed, moved);
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
const alert = await (await page()).$("[role=alert]");
|
||||
await alert.waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await alert.getText(), /This app's folder isn't there any more/);
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded");
|
||||
// Back where the picker answers: the same path, as the test can only set it when the launcher starts.
|
||||
renameSync(moved, installed);
|
||||
await (await alert.$("button*=Locate existing install")).click();
|
||||
await s.until(async () => !(await (await page()).$("[role=alert]").isExisting()));
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
await s.until(() => existsSync(join(installed, "launched.txt")));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("one anywhere else is found and imported in Settings, by its folder or the folder around it", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const elsewhere = mkdtempSync(join(tmpdir(), "quiver-elsewhere-"));
|
||||
const installed = portableLibrary(join(elsewhere, "Old Launcher"), { version: false });
|
||||
const empty = mkdtempSync(join(tmpdir(), "quiver-empty-"));
|
||||
const settings = async (s) => {
|
||||
await s.settings("Library");
|
||||
await (await s.app.$("button=Choose my Quiver Launcher 3 folder…")).click();
|
||||
};
|
||||
// Nothing in the usual places: no banner.
|
||||
let s = await launch({ env: { HOME: home, QUIVER_PICK_FOLDER: empty } });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.ok(!(await (await s.app.$("button=Add 1 app")).isExisting()));
|
||||
await settings(s);
|
||||
await (await s.app.$("p*=That folder doesn't have Quiver Launcher 3 in it")).waitForDisplayed({ timeout: 10000 });
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
s = await launch({ env: { HOME: home, QUIVER_PICK_FOLDER: elsewhere } });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await s.usageNoticeSeen();
|
||||
await settings(s);
|
||||
// Settings says what it found and brings it over itself, with no banner asking as well.
|
||||
await (await (await s.app.$("section.settings-page")).$("p*=1 app, already installed")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.ok(!(await (await s.app.$(".old-library-question")).isExisting()));
|
||||
await (await (await s.app.$("section.settings-page")).$("button=Add 1 app")).click();
|
||||
await (await (await s.app.$("section.settings-page")).$("p=Your apps are in your library.")).waitForDisplayed({ timeout: 20000 });
|
||||
await s.closeSettings();
|
||||
// Installed, though 3.x never wrote its version down.
|
||||
await playIt(s, installed);
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
@@ -1,45 +0,0 @@
|
||||
/** A Quiver Launcher 3 player imports their library. */
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const old = mkdtempSync(join(tmpdir(), "quiver-v3-"));
|
||||
const installed = join(old, "Apps", "TestPort");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(installed, { recursive: true });
|
||||
writeFileSync(join(installed, "version.txt"), "v1.0.0");
|
||||
writeFileSync(join(installed, "port.sh"), '#!/bin/sh\ncd "$(dirname "$0")" && echo played > launched.txt\n', { mode: 0o755 });
|
||||
writeFileSync(
|
||||
join(old, "apps.json"),
|
||||
JSON.stringify({
|
||||
apps: [
|
||||
// Its repository moved since: the catalog entry 3.x knew it as still finds it.
|
||||
{ name: "Test Port", repository: "quiver/test-port-old-name", catalogEntryId: "entry_test-port", folderName: "TestPort" },
|
||||
// Its repository is gone (GitHub says 404): it comes over all the same, as a custom app.
|
||||
{ name: "Homebrew Thing", repository: "someone/not-in-catalog", folderName: "Homebrew" },
|
||||
// Nothing says where it's from: the one left out.
|
||||
{ name: "Mystery App", folderName: "Mystery" },
|
||||
],
|
||||
}),
|
||||
);
|
||||
s = await launch({ env: { QUIVER_V3_DATA: old } });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
test("a 3.x library is added in one click, keeping installed apps, all but an app 3.x doesn't say where it's from", async () => {
|
||||
const { app, card, until } = s;
|
||||
await s.usageNoticeSeen();
|
||||
await (await app.$("button=Add 3 apps")).click();
|
||||
await (await app.$("p*=except these, as Quiver Launcher 3 doesn't know where they come from: Mystery App.")).waitForDisplayed({ timeout: 20000 });
|
||||
await (await app.$("article*=Homebrew Thing")).waitForExist();
|
||||
const port = await card("test-port");
|
||||
await (await port.$("button*=Play")).click();
|
||||
await until(() => existsSync(join(installed, "launched.txt")));
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
});
|
||||
@@ -1,200 +0,0 @@
|
||||
/**
|
||||
* User journeys through the real app (Tauri + WebDriver). Build first with
|
||||
* `pnpm --filter @quiver/e2e build`; Linux needs tauri-driver,
|
||||
* WebKitWebDriver and a display (xvfb-run).
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, apps, card, until;
|
||||
|
||||
before(async () => {
|
||||
// These journeys come back to Browse for apps in the library, so Browse shows them (browse-owned.test.js covers leaving them out).
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ browseShowsLibrary: true }));
|
||||
s = await launch({ data });
|
||||
({ app, api, apps, card, until } = s);
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
test("a new player gets a port in one click and plays it", async () => {
|
||||
// An empty library starts in the catalog, showing ports for this computer.
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
|
||||
// Get adds it to the library and installs the verified release.
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
const folder = join(apps, "test-port");
|
||||
assert.equal(readFileSync(join(folder, ".quiver-version"), "utf8"), "1.0.0");
|
||||
assert.ok(existsSync(join(folder, "data/level1.dat")), "the wrapper folder is flattened");
|
||||
assert.ok(existsSync(join(folder, "portable.txt")), "the catalog's filesToAdd are created");
|
||||
assert.match(await (await port.$(".cover-badge")).getText(), /in library/i);
|
||||
|
||||
// It's in the library, and Play starts it.
|
||||
await (await app.$("button*=Library")).click();
|
||||
const owned = await card("test-port");
|
||||
await (await owned.$("button*=Play")).click();
|
||||
await until(() => existsSync(join(folder, "launched.txt")));
|
||||
});
|
||||
|
||||
test("a new verified release is offered as an update and installs", async () => {
|
||||
api.release("1.1.0");
|
||||
await (await app.$("button=Browse")).click();
|
||||
const port = await card("test-port");
|
||||
await (await port.$("button*=Update to v1.1.0")).click();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "1.1.0");
|
||||
assert.ok(existsSync(join(apps, "test-port", "launched.txt")), "files the app wrote are kept");
|
||||
api.release("1.0.0");
|
||||
});
|
||||
|
||||
test("an app can stay on its version, or update by itself", async () => {
|
||||
// How it updates is on its page's On this computer tab.
|
||||
const updates = async (choice) => {
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await (await (await app.$(".app-page")).$("button*=On this computer")).click();
|
||||
await (await (await app.$(".app-page")).$(".//label[span[text()='Updates']]/select")).selectByVisibleText(choice);
|
||||
await app.keys("Escape");
|
||||
};
|
||||
const reload = async () => {
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button=Browse")).click();
|
||||
};
|
||||
await updates("Always stay on v1.1.0");
|
||||
api.release("1.2.0");
|
||||
await reload();
|
||||
await s.untilCardShows("test-port", "button*=Play");
|
||||
assert.ok(!(await (await card("test-port")).$("button*=Update").isExisting()), "no update offered");
|
||||
await updates("Install automatically");
|
||||
await reload();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "1.2.0", 30000);
|
||||
|
||||
// Going back a version: Auto Update doesn't put the newer one straight back, but the next release still comes.
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
const page = await app.$(".app-page");
|
||||
await (await page.$("button*=On this computer")).click();
|
||||
await (await page.$("button=Change version")).click();
|
||||
const row = (version) => app.$(`//section[@aria-label="Versions"]//li[strong[text()="${version}"]]`);
|
||||
await (await (await row("v1.0.0")).$("button=Install")).click();
|
||||
await (await (await app.$('//section[@role="dialog"]')).$("button=Install anyway")).click();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "v1.0.0", 30000);
|
||||
assert.equal(await (await page.$(".//label[span[text()='Updates']]/select")).getValue(), "auto");
|
||||
await (await page.$("p*=put v1.2.0 back")).waitForDisplayed({ timeout: 10000 });
|
||||
await app.keys("Escape");
|
||||
await reload();
|
||||
await s.untilCardShows("test-port", "button=Update to v1.2.0", 10000);
|
||||
assert.equal(readFileSync(join(apps, "test-port", ".quiver-version"), "utf8"), "v1.0.0");
|
||||
api.release("1.3.0");
|
||||
await reload();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "1.3.0", 30000);
|
||||
api.release("1.0.0");
|
||||
});
|
||||
|
||||
test("a download that doesn't match Quiver's checksum is refused", async () => {
|
||||
await (await app.$("button=Browse")).click();
|
||||
const port = await card("tampered-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
const alert = await port.$('[role="alert"]');
|
||||
await alert.waitForDisplayed({ timeout: 30000 });
|
||||
assert.match(await alert.getText(), /doesn't match the file Quiver checked/);
|
||||
assert.ok(!existsSync(join(apps, "tampered-port")), "nothing was installed");
|
||||
// The site hears of it, once, to read that release again.
|
||||
await until(() => api.downloadProblems().length > 0);
|
||||
const [{ file, ...report }, ...more] = api.downloadProblems();
|
||||
assert.deepEqual(report, { slug: "tampered-port", version: "1.0.0", problem: "mismatch" });
|
||||
assert.match(file, /^tampered-port-(linux|windows)\.zip$/);
|
||||
assert.equal(more.length, 0);
|
||||
});
|
||||
|
||||
test("arrow keys and controllers move between cards", async () => {
|
||||
await (await app.$("input[placeholder^=Search]")).click();
|
||||
const focused = () => app.execute(() => document.activeElement?.closest("article")?.dataset.slug);
|
||||
// Down from the search box goes into the first shelf (its See all, then its cards); the sort and Filters are beside the search.
|
||||
await app.keys("ArrowDown");
|
||||
assert.equal(await app.execute(() => document.activeElement?.closest("section.shelf")?.getAttribute("aria-label")), "Players say it runs well");
|
||||
// Along the shelf, card to card.
|
||||
await app.execute(() => document.querySelector('section.shelf article[data-slug="test-port"] .card-open').focus());
|
||||
await app.keys("ArrowRight");
|
||||
assert.equal(await focused(), "tampered-port");
|
||||
// A controller's d-pad, as the Rust side reports it.
|
||||
const pad = (key, down) =>
|
||||
app.execute((key, down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key, down } }), key, down);
|
||||
await pad("DPadLeft", true);
|
||||
await pad("DPadLeft", false);
|
||||
await until(async () => (await focused()) === "test-port");
|
||||
});
|
||||
|
||||
test("search narrows the catalog", async () => {
|
||||
await (await app.$("input[placeholder^=Search]")).setValue("tampered");
|
||||
await until(async () => !(await (await card("test-port")).isExisting()));
|
||||
assert.ok(await (await card("tampered-port")).isExisting());
|
||||
});
|
||||
|
||||
test("Uninstall on an app's page deletes its files and keeps it in the library", async () => {
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await (await (await app.$(".app-actions")).$("button*=Uninstall")).click();
|
||||
// It asks first, with Cancel focused; Escape (a controller's B) says no.
|
||||
const prompt = await app.$('[role=dialog][aria-label="Uninstall Test Port"]');
|
||||
await prompt.waitForDisplayed();
|
||||
assert.equal(await app.execute(() => document.activeElement?.textContent), "Cancel");
|
||||
await app.keys("Escape");
|
||||
await prompt.waitForDisplayed({ reverse: true });
|
||||
assert.ok(existsSync(join(apps, "test-port")), "nothing was deleted");
|
||||
assert.ok(await (await app.$(".page-layer:not([hidden]) .app-page")).isExisting(), "Escape closed the prompt, not the page");
|
||||
await (await (await app.$(".app-actions")).$("button*=Uninstall")).click();
|
||||
await (await prompt.$("button=Uninstall")).click();
|
||||
await until(() => !existsSync(join(apps, "test-port")));
|
||||
// Still in the library, ready to get again from the same page.
|
||||
const page = await app.$(".app-page");
|
||||
await (await page.$("button*=Get")).waitForDisplayed();
|
||||
await (await page.$("button*=On this computer")).click();
|
||||
assert.ok(await (await page.$("button*=Remove from library")).isExisting());
|
||||
await (await page.$("button*=Get")).click();
|
||||
await (await page.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
});
|
||||
|
||||
test("removing an app uninstalls it and takes it out of the library", async () => {
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await (await (await app.$(".app-page")).$("button*=On this computer")).click();
|
||||
await (await app.$("button*=Uninstall and remove")).click();
|
||||
await (await (await app.$("[role=dialog]")).$("button=Uninstall and remove")).click();
|
||||
await until(() => !existsSync(join(apps, "test-port")));
|
||||
await until(async () => !(await (await card("test-port")).isExisting()));
|
||||
});
|
||||
|
||||
test("an app the catalog doesn't list is added from its GitHub repository", async () => {
|
||||
const fromRepository = async (address) => {
|
||||
await (await app.$("button*=Add an app")).click();
|
||||
await (await app.$("button*=From GitHub or GitLab")).click();
|
||||
await (await app.$("input[aria-label=Repository]")).setValue(address);
|
||||
await (await app.$("button=Look it up")).click();
|
||||
};
|
||||
await (await app.$("button*=Library")).click();
|
||||
// A repository the catalog lists opens the catalog's app instead.
|
||||
await fromRepository("https://github.com/quiver/test-port");
|
||||
await (await app.$("h1=Test Port")).waitForDisplayed({ timeout: 10000 });
|
||||
await app.keys("Escape");
|
||||
await fromRepository("someone/homebrew");
|
||||
await (await app.$("p*=Downloads Homebrew-")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await app.$("button=Add and get")).click();
|
||||
await (await (await app.$(".app-page")).$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
assert.equal(readFileSync(join(apps, "homebrew", ".quiver-version"), "utf8"), "v2.0");
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("settings make the interface larger, and it stays that way", async () => {
|
||||
await s.settings("General");
|
||||
// By its label: TV mode's dropdown comes before it now.
|
||||
await (await app.$("//section[contains(@class, 'settings-page')]//label[contains(., 'Interface size')]/select")).selectByVisibleText("125%");
|
||||
await s.closeSettings();
|
||||
assert.equal(await app.execute(() => document.documentElement.style.zoom), "1.25");
|
||||
await until(() => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8")).scale === 1.25);
|
||||
});
|
||||
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
* Launch options on the app page: another of the app's programs, Steam-style
|
||||
* options (environment, a wrapper, arguments), Wine or a Proton, used by Play,
|
||||
* desktop shortcuts and Steam shortcuts, and kept through an update.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const bin = mkdtempSync(join(tmpdir(), "quiver-bin-"));
|
||||
const log = join(mkdtempSync(join(tmpdir(), "quiver-ran-")), "log");
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const steamConfig = join(home, ".steam/steam/userdata/42/config");
|
||||
const proton = join(home, ".steam/steam/compatibilitytools.d/GE-Proton-Test");
|
||||
const otherProton = join(mkdtempSync(join(tmpdir(), "quiver-proton-")), "Proton-Elsewhere");
|
||||
const port = join(data, "apps", "test-port");
|
||||
let s;
|
||||
|
||||
const script = (path, body) => writeFileSync(path, `#!/bin/sh\n${body}\n`, { mode: 0o755 });
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(join(home, "Desktop"));
|
||||
mkdirSync(steamConfig, { recursive: true });
|
||||
for (const dir of [proton, otherProton]) mkdirSync(dir, { recursive: true });
|
||||
// Stand-ins that say how they were run.
|
||||
script(join(bin, "wine"), `echo "wine $*" >> "${log}"`);
|
||||
script(join(bin, "wrap"), `echo "wrap $*" >> "${log}"; exec "$@"`);
|
||||
script(join(proton, "proton"), `echo "ge-proton $* prefix=$STEAM_COMPAT_DATA_PATH" >> "${log}"`);
|
||||
script(join(otherProton, "proton"), `echo "other-proton $*" >> "${log}"`);
|
||||
s = await launch({
|
||||
data,
|
||||
env: { HOME: home, PATH: `${bin}:${process.env.PATH}`, QUIVER_PICK: join(port, "tools", "other.sh"), QUIVER_PICK_FOLDER: otherProton },
|
||||
});
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => s.app.$(".app-page");
|
||||
/** Clicks a button in the side panel, scrolled clear of the usage data notice at the bottom. */
|
||||
const press = async (button) => {
|
||||
await button.scrollIntoView({ block: "center" });
|
||||
await button.click();
|
||||
};
|
||||
const form = () => s.app.$('form[aria-label="Launch options"]');
|
||||
const ran = () => (existsSync(log) ? readFileSync(log, "utf8") : "");
|
||||
const play = async () => {
|
||||
rmSync(log, { force: true });
|
||||
await press(await (await page()).$("button*=Play"));
|
||||
await s.until(() => ran() !== "");
|
||||
return ran();
|
||||
};
|
||||
const openForm = async () => {
|
||||
await press(await (await page()).$("button*=On this computer"));
|
||||
await press(await (await page()).$("button*=Launch options"));
|
||||
await (await form()).waitForDisplayed();
|
||||
};
|
||||
const save = async () => press(await (await form()).$("button=Save"));
|
||||
|
||||
test("another of the app's programs, with environment, a wrapper and arguments", async () => {
|
||||
const { card } = s;
|
||||
const game = await card("test-port");
|
||||
await game.waitForDisplayed({ timeout: 20000 });
|
||||
await (await game.$("button=Get")).click();
|
||||
await (await game.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
mkdirSync(join(port, "tools"));
|
||||
script(join(port, "tools", "other.sh"), `echo "other $* mode=$GAME_MODE" >> "${log}"`);
|
||||
await (await game.$(".card-open")).click();
|
||||
|
||||
await openForm();
|
||||
await press(await (await form()).$("button=Choose program…"));
|
||||
await (await (await form()).$("code=tools/other.sh")).waitForDisplayed();
|
||||
await (await (await form()).$("input[aria-label='Launch flags']")).setValue('GAME_MODE=fast wrap %command% --level "two words"');
|
||||
await save();
|
||||
assert.equal(await play(), `wrap ${join(port, "tools", "other.sh")} --level two words\nother --level two words mode=fast\n`);
|
||||
assert.ok(await (await (await page()).$("button=Launch options (changed)")).isExisting());
|
||||
const installs = JSON.parse(readFileSync(join(data, "installs.json"), "utf8"));
|
||||
assert.deepEqual(installs["entry_test-port"].launch, { executable: "tools/other.sh", command: 'GAME_MODE=fast wrap %command% --level "two words"' });
|
||||
|
||||
// Shortcuts start it the same way.
|
||||
await press(await (await page()).$("button*=On this computer"));
|
||||
await press(await (await page()).$("button*=Desktop shortcut"));
|
||||
await (await s.app.$("p*=is on your desktop")).waitForDisplayed({ timeout: 10000 });
|
||||
const desktop = readFileSync(join(home, "Desktop", "Test Port.desktop"), "utf8");
|
||||
assert.match(desktop, /\nExec=env GAME_MODE=fast "wrap" ".*\/test-port\/tools\/other\.sh" "--level" "two words"\n/);
|
||||
await press(await (await page()).$("button=Add to Steam"));
|
||||
await (await s.app.$("p*=is in Steam")).waitForDisplayed({ timeout: 10000 });
|
||||
const vdf = readFileSync(join(steamConfig, "shortcuts.vdf"), "latin1");
|
||||
assert.ok(vdf.includes("tools/other.sh"), "Steam starts the chosen program");
|
||||
assert.ok(vdf.includes('GAME_MODE=fast wrap %command% --level "two words"'), vdf);
|
||||
});
|
||||
|
||||
test("Wine, a Proton Quiver found, and one chosen from a folder", async () => {
|
||||
const runWith = async (label) => {
|
||||
await openForm();
|
||||
const select = await (await form()).$("select[aria-label='Run with']");
|
||||
await select.selectByVisibleText(label);
|
||||
};
|
||||
await runWith("Wine");
|
||||
await save();
|
||||
assert.match(await play(), /^wine .*\/tools\/other\.sh --level two words\n$/m);
|
||||
|
||||
await runWith("GE-Proton-Test");
|
||||
await save();
|
||||
const prefix = join(data, "proton", "test-port");
|
||||
assert.match(await play(), new RegExp(`^ge-proton run .*/tools/other\\.sh --level two words prefix=${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\n$`, "m"));
|
||||
assert.ok(existsSync(prefix), "each app gets its own Proton prefix");
|
||||
|
||||
await runWith("Another Proton…");
|
||||
await (await (await form()).$("option=Proton-Elsewhere")).waitForExist();
|
||||
await save();
|
||||
assert.match(await play(), /^other-proton run .*\/tools\/other\.sh/m);
|
||||
});
|
||||
|
||||
test("launch options stay through an update, and Reset goes back to Quiver's choice", async () => {
|
||||
const installs = () => JSON.parse(readFileSync(join(data, "installs.json"), "utf8"))["entry_test-port"];
|
||||
s.api.release("1.1.0");
|
||||
await s.app.keys("Escape");
|
||||
// Browse fetches the catalog again as it opens; the update is on the app's library card.
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.app.$("button=Browse")).click();
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
// Update, under Play (the corner icon for it is an icon card's, hidden on this one).
|
||||
await (await (await s.card("test-port")).$("button.tile-update")).click();
|
||||
await s.until(() => readFileSync(join(port, ".quiver-version"), "utf8") === "1.1.0", 30000);
|
||||
s.api.release("1.0.0");
|
||||
await s.until(() => installs().version.endsWith("1.1.0"));
|
||||
assert.equal(installs().launch.executable, "tools/other.sh");
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
assert.match(await play(), /^other-proton run .*\/tools\/other\.sh/m);
|
||||
|
||||
// A chosen program that's gone: Play says so.
|
||||
rmSync(join(port, "tools"), { recursive: true });
|
||||
await press(await (await page()).$("button*=Play"));
|
||||
await (await s.app.$("p*=isn't in the app's folder any more")).waitForDisplayed({ timeout: 10000 });
|
||||
|
||||
await openForm();
|
||||
await press(await (await form()).$("button=Reset"));
|
||||
await (await (await page()).$("button=Launch options")).waitForDisplayed();
|
||||
await s.until(() => installs().launch === undefined);
|
||||
await press(await (await page()).$("button=Dismiss"));
|
||||
await press(await (await page()).$("button*=Play"));
|
||||
await s.until(() => existsSync(join(port, "launched.txt")));
|
||||
});
|
||||
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Quiver Launcher updating itself: offered when a newer release is out,
|
||||
* refused when its signature doesn't match, and installed (an AppImage here)
|
||||
* with the saved files backed up first. A copy that can't update itself is
|
||||
* sent to the release page.
|
||||
*/
|
||||
import { after, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
const api = await startMockApi();
|
||||
const dir = mkdtempSync(join(tmpdir(), "quiver-appimage-"));
|
||||
const image = join(dir, "Quiver_Launcher.AppImage");
|
||||
const updated = join(dir, "updated.txt");
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
let s;
|
||||
|
||||
after(async () => {
|
||||
await s?.close();
|
||||
api.close();
|
||||
});
|
||||
|
||||
const banner = () => s.app.$('[role="status"][aria-label="Launcher update"]');
|
||||
const checkInSettings = async () => {
|
||||
await s.settings("Updates");
|
||||
const section = await s.app.$('section[aria-label="Quiver Launcher"]');
|
||||
await (await section.$("button=Check for updates")).click();
|
||||
return section;
|
||||
};
|
||||
const closeSettings = () => s.closeSettings();
|
||||
|
||||
test("nothing newer: no banner, and Settings says so", async () => {
|
||||
writeFileSync(image, "#!/bin/sh\necho old\n", { mode: 0o755 });
|
||||
s = await launch({ api, data, env: { APPIMAGE: image, QUIVER_UPDATED: updated } });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
// The update's banner would wait behind it (the data folder keeps the answer for the copy started later).
|
||||
await s.usageNoticeSeen();
|
||||
assert.ok(!(await (await banner()).isExisting()));
|
||||
const section = await checkInSettings();
|
||||
assert.match(await section.getText(), /Version 4\.\d+\.\d+/);
|
||||
await (await section.$("p=You have the newest version.")).waitForDisplayed({ timeout: 10000 });
|
||||
await closeSettings();
|
||||
});
|
||||
|
||||
test("an update whose signature doesn't match isn't installed", async () => {
|
||||
api.publishLauncher({ version: "9.0.0", tampered: true });
|
||||
await checkInSettings();
|
||||
await closeSettings();
|
||||
await (await banner()).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await banner()).getText(), /Quiver Launcher 9\.0\.0 is out\./);
|
||||
await (await (await banner()).$("button=Update now")).click();
|
||||
await (await (await banner()).$("span*=signature doesn't match")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(readFileSync(image, "utf8"), "#!/bin/sh\necho old\n");
|
||||
assert.ok(!existsSync(updated));
|
||||
// What's new shows the release's notes here, with a way on to its page.
|
||||
await (await (await banner()).$("button=What's new")).click();
|
||||
const notes = await s.app.$('[role="dialog"].changelog');
|
||||
await notes.waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await notes.getText(), /What's new in 9\.0\.0/);
|
||||
assert.deepEqual(api.releasePages(), []);
|
||||
await (await notes.$("button=View v9.0.0 on GitHub")).click();
|
||||
await s.until(() => api.releasePages().includes("v9.0.0"));
|
||||
await (await notes.$("button=Close")).click();
|
||||
await notes.waitForDisplayed({ reverse: true });
|
||||
});
|
||||
|
||||
test("a signed update backs up the library, replaces the AppImage and starts it", async () => {
|
||||
api.publishLauncher({ version: "9.0.1" });
|
||||
// Not now hides it until the next check.
|
||||
await (await (await banner()).$("button=Not now")).click();
|
||||
assert.ok(!(await (await banner()).isExisting()));
|
||||
await checkInSettings();
|
||||
await closeSettings();
|
||||
await (await banner()).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await banner()).getText(), /Quiver Launcher 9\.0\.1 is out\./);
|
||||
await (await (await banner()).$("button=Update now")).click();
|
||||
// This copy closes and the new one starts.
|
||||
await s.until(() => existsSync(updated), 30000);
|
||||
assert.equal(readFileSync(updated, "utf8").trim(), "9.0.1");
|
||||
assert.match(readFileSync(image, "utf8"), /9\.0\.1/);
|
||||
const backups = readdirSync(join(data, "backups", "updates"));
|
||||
assert.equal(backups.length, 1);
|
||||
assert.match(backups[0], /-to-9\.0\.1$/);
|
||||
const saved = readdirSync(join(data, "backups", "updates", backups[0]));
|
||||
assert.ok(saved.includes("settings.json"), `backed up: ${saved}`);
|
||||
await s.close();
|
||||
s = null;
|
||||
});
|
||||
|
||||
test("a copy that can't update itself opens the release page", async () => {
|
||||
// The first copy, if the test before stopped before closing it.
|
||||
await s?.close();
|
||||
s = await launch({ api, data });
|
||||
await (await banner()).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await (await banner()).getText(), /9\.0\.1 is out\. Update Quiver Launcher the way you installed it/);
|
||||
await (await (await banner()).$("button=Open the release page")).click();
|
||||
await s.until(() => api.releasePages().includes("v9.0.1"));
|
||||
});
|
||||
@@ -1,362 +0,0 @@
|
||||
/**
|
||||
* The library's Sidebar layout: the library as a list of names down the
|
||||
* left, under headings by when each was played, with a search, Recently
|
||||
* played and Installed only buttons and a filters panel whose filters save as
|
||||
* a playlist; the app picked in it open beside it with the player's own play:
|
||||
* when they last played it and for how long.
|
||||
* Only where the window is wide enough: narrower, the library is a grid.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let api, s;
|
||||
|
||||
before(async () => {
|
||||
api = await startMockApi();
|
||||
s = await launch({ api });
|
||||
// Three apps in the library: Tampered Port's download is refused, so it stays not installed.
|
||||
for (const slug of ["test-port", "test-remake", "tampered-port"]) {
|
||||
const card = await s.card(slug);
|
||||
await card.waitForDisplayed({ timeout: 20000 });
|
||||
await (await card.$("button=Get")).click();
|
||||
await s.until(async () => (await card.$("button*=Play").isExisting()) || (await card.$('[role="alert"]').isExisting()), 30000);
|
||||
}
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.card("test-port")).waitForDisplayed();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await s?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
const settings = () => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8"));
|
||||
/** The sidebar's headings and the apps under each, by slug, as shown. */
|
||||
const listed = () =>
|
||||
s.app.execute(() =>
|
||||
[...document.querySelectorAll(".sidebar-group")].map((g) => [
|
||||
g.querySelector(".sidebar-heading-name")?.textContent ?? "",
|
||||
[...g.querySelectorAll(".sidebar-row")].map((r) => r.dataset.slug),
|
||||
]),
|
||||
);
|
||||
const slugs = async () => (await listed()).flatMap(([, apps]) => apps);
|
||||
/** The open app's name, beside the sidebar. */
|
||||
const open = () => s.app.execute(() => document.querySelector(".library-pane .app-page h1")?.textContent);
|
||||
const topbarPadding = () => s.app.execute(() => getComputedStyle(document.querySelector(".topbar")).paddingLeft);
|
||||
const row = (slug) => s.app.$(`.sidebar-row[data-slug="${slug}"]`);
|
||||
/**
|
||||
* View options' panel is under its button: when the sidebar's width moves the button, the panel follows it a frame
|
||||
* later (Popover in library.tsx), and a click before then lands where it was, outside it, closing it.
|
||||
*/
|
||||
const panelFollowed = () =>
|
||||
s.app.execute(() => {
|
||||
const button = document.querySelector(".library-sidebar button[aria-label='View options']")?.getBoundingClientRect();
|
||||
const panel = document.querySelector(".view-panel")?.getBoundingClientRect();
|
||||
return Boolean(button && panel && Math.abs(panel.left - button.left) < 1);
|
||||
});
|
||||
|
||||
test("the Sidebar layout lists the library down the left, the first app open beside it", async () => {
|
||||
await (await s.app.$("button[aria-label='View options']")).click();
|
||||
await (await (await s.app.$(".view-panel [aria-label='Layout']")).$("button=Sidebar")).click();
|
||||
await s.app.keys("Escape");
|
||||
await (await s.app.$(".library-sidebar")).waitForDisplayed();
|
||||
await s.until(() => settings().library?.layout === "sidebar");
|
||||
// None played yet: one heading, by name.
|
||||
assert.deepEqual(await listed(), [["Not played yet", ["tampered-port", "test-port", "test-remake"]]]);
|
||||
await s.until(async () => (await open()) === "Tampered Port");
|
||||
assert.equal(await (await row("tampered-port")).getAttribute("aria-current"), "true");
|
||||
// Not installed (its download refused): dimmed, saying so. No way back from a page that isn't over anything.
|
||||
assert.equal(await (await row("tampered-port")).getAttribute("data-installed"), "false");
|
||||
assert.match(await (await row("tampered-port")).$(".sidebar-line").getText(), /Tampered Port \(original\)\s+– Couldn't install/);
|
||||
assert.equal(await (await row("test-port")).getAttribute("data-installed"), "true");
|
||||
assert.equal(await (await row("test-port")).getAttribute("data-state"), "ready");
|
||||
assert.ok(!(await s.app.$(".library-pane .back-link").isExisting()));
|
||||
// The top bar's logo and buttons go to the window's edges, as the sidebar does; Settings is a gear.
|
||||
assert.equal(await topbarPadding(), "14px");
|
||||
assert.ok(await s.app.$("button[aria-label=Settings] svg.lucide-settings").isExisting());
|
||||
// The buttons at its foot have their icon and words in the middle.
|
||||
const offCentre = await s.app.execute(() =>
|
||||
[...document.querySelectorAll(".sidebar-foot button")].map((b) => {
|
||||
const box = b.getBoundingClientRect();
|
||||
// Its icon, words and labels, each as wide as it shows (a long label is cut short).
|
||||
const parts = [...b.childNodes].map((n) => {
|
||||
if (n.nodeType === Node.ELEMENT_NODE) return n.getBoundingClientRect();
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(n);
|
||||
return range.getBoundingClientRect();
|
||||
}).filter((r) => r.width);
|
||||
const [left, right] = [Math.min(...parts.map((r) => r.left)), Math.max(...parts.map((r) => r.right))];
|
||||
return Math.round(Math.abs((left + right) / 2 - (box.left + box.right) / 2));
|
||||
}),
|
||||
);
|
||||
assert.ok(offCentre.length && offCentre.every((d) => d <= 1), `off centre by ${offCentre}`);
|
||||
// No grid, tabs or Continue playing.
|
||||
assert.ok(!(await s.app.$(".library-grid").isExisting()) && !(await s.app.$(".library-bar").isExisting()));
|
||||
});
|
||||
|
||||
test("picking an app opens its page; playing it puts it under Recent with when it was played", async () => {
|
||||
await (await row("test-port")).click();
|
||||
await s.until(async () => (await open()) === "Test Port");
|
||||
const stats = () => s.app.execute(() => Object.fromEntries([...document.querySelectorAll(".library-pane .play-stats > div")].map((d) => [d.querySelector("dt").textContent, d.querySelector("dd").textContent])));
|
||||
// When it was added is the sidebar's to say, not the page's.
|
||||
assert.deepEqual(await stats(), { "Last played": "Never", Installed: "v1.0.0" });
|
||||
await (await (await s.app.$(".library-pane .app-actions")).$("button*=Play")).click();
|
||||
await s.until(async () => (await stats())["Last played"] === "Today");
|
||||
// Its play time once it closes: the test app closes straight away.
|
||||
await s.until(async () => (await stats())["Play time"] === "Under a minute");
|
||||
const labels = await s.app.execute(() => [...document.querySelectorAll(".library-pane .play-stats dt")].map((d) => d.textContent));
|
||||
assert.deepEqual(labels, ["Last played", "Play time", "Installed"]);
|
||||
await s.until(async () => JSON.stringify(await listed()) === JSON.stringify([["Recent", ["test-port"]], ["Not played yet", ["tampered-port", "test-remake"]]]));
|
||||
// The page stays on the app picked.
|
||||
assert.equal(await open(), "Test Port");
|
||||
// A heading folds its apps away.
|
||||
await (await s.app.$(".sidebar-heading*=Not played yet")).click();
|
||||
await s.until(async () => (await slugs()).join() === "test-port");
|
||||
await (await s.app.$(".sidebar-heading*=Not played yet")).click();
|
||||
await s.until(async () => (await slugs()).length === 3);
|
||||
});
|
||||
|
||||
test("a row's menu opens on a right-click or a controller's Options button, as a library card's does", async () => {
|
||||
const menu = () => s.app.$('[role="menu"][aria-label="Test Remake menu"]');
|
||||
const items = () => s.app.execute(() => [...document.querySelectorAll('[role="menu"] [role="menuitem"]')].map((b) => b.textContent));
|
||||
const focused = () => s.app.execute(() => document.activeElement?.dataset.slug ?? document.activeElement?.textContent);
|
||||
const press = async (key) => {
|
||||
for (const down of [true, false]) await s.pad(key, down);
|
||||
};
|
||||
await (await row("test-remake")).click({ button: "right" });
|
||||
await (await menu()).waitForDisplayed();
|
||||
assert.deepEqual(await items(), ["Play", "Play with", "Add to playlist", "Manage", "App page"]);
|
||||
assert.equal(await focused(), "Play");
|
||||
// A right-click doesn't pick the app, and Escape gives the row its focus back.
|
||||
assert.equal(await open(), "Test Port");
|
||||
await s.app.keys("Escape");
|
||||
await (await menu()).waitForDisplayed({ reverse: true });
|
||||
assert.equal(await focused(), "test-remake");
|
||||
// Options on a controller opens it on the focused row; App page picks the app.
|
||||
await press("North");
|
||||
await (await menu()).waitForDisplayed();
|
||||
await s.until(async () => (await focused()) === "Play");
|
||||
await press("DPadDown");
|
||||
await press("DPadDown");
|
||||
await press("DPadDown");
|
||||
await press("DPadRight");
|
||||
await s.until(async () => (await focused()) === "Open folder");
|
||||
await press("DPadLeft");
|
||||
await press("DPadDown");
|
||||
await s.until(async () => (await focused()) === "App page");
|
||||
await press("South");
|
||||
await s.until(async () => (await open()) === "Test Remake");
|
||||
await (await menu()).waitForDisplayed({ reverse: true });
|
||||
assert.equal(await focused(), "test-remake");
|
||||
});
|
||||
|
||||
test("Recently played, Installed only and the search narrow and order the list", async () => {
|
||||
const recent = await s.app.$("button[aria-label='Recently played first']");
|
||||
assert.equal(await recent.getAttribute("aria-pressed"), "true");
|
||||
await recent.click();
|
||||
// A to Z, under no headings.
|
||||
await s.until(async () => JSON.stringify(await listed()) === JSON.stringify([["", ["tampered-port", "test-port", "test-remake"]]]));
|
||||
// A to Z by the name shown on top: the game's.
|
||||
await s.until(() => settings().librarySort === "game");
|
||||
await recent.click();
|
||||
await s.until(() => settings().librarySort === undefined);
|
||||
await (await s.app.$("button[aria-label='Installed only']")).click();
|
||||
await s.until(async () => (await slugs()).sort().join() === "test-port,test-remake");
|
||||
await (await s.app.$("button[aria-label='Installed only']")).click();
|
||||
await s.until(async () => (await slugs()).length === 3);
|
||||
await (await s.app.$(".library-sidebar input[aria-label='Search your library']")).setValue("remake");
|
||||
await s.until(async () => (await slugs()).join() === "test-remake");
|
||||
// The page follows: the app open left the list.
|
||||
await s.until(async () => (await open()) === "Test Remake");
|
||||
await (await s.app.$(".library-sidebar button[aria-label='Clear search']")).click();
|
||||
await s.until(async () => (await slugs()).length === 3);
|
||||
});
|
||||
|
||||
test("Left and Right move through the search's text, and Right out of it past its end", async () => {
|
||||
const search = await s.app.$(".library-sidebar input[aria-label='Search your library']");
|
||||
const focused = () => s.app.execute(() => (document.activeElement?.getAttribute("aria-label") ?? document.activeElement?.tagName));
|
||||
const caret = () => s.app.execute((el) => [el.selectionStart, el.selectionEnd], search);
|
||||
await search.setValue("te");
|
||||
// Inside the text, the caret moves and the focus stays.
|
||||
await s.app.keys("ArrowLeft");
|
||||
assert.deepEqual(await caret(), [1, 1]);
|
||||
await s.app.keys("ArrowRight");
|
||||
assert.deepEqual(await caret(), [2, 2]);
|
||||
assert.equal(await focused(), "Search your library");
|
||||
// At its end, Right goes to what's right of the field.
|
||||
await s.app.keys("ArrowRight");
|
||||
await s.until(async () => (await focused()) !== "Search your library");
|
||||
await (await s.app.$(".library-sidebar button[aria-label='Clear search']")).click();
|
||||
await s.until(async () => (await slugs()).length === 3);
|
||||
});
|
||||
|
||||
test("each app shows its game's name over its own; View options flip them or show just one", async () => {
|
||||
const names = (slug) =>
|
||||
s.app.execute((slug) => {
|
||||
const r = document.querySelector(`.sidebar-row[data-slug="${slug}"]`);
|
||||
return [r.querySelector(".sidebar-name").textContent, r.querySelector(".sidebar-other")?.textContent ?? null];
|
||||
}, slug);
|
||||
assert.deepEqual(await names("test-port"), ["Test Port (original)", "Test Port"]);
|
||||
assert.equal(await (await row("test-port")).getAttribute("data-lines"), "2");
|
||||
await (await s.app.$(".library-sidebar button[aria-label='View options']")).click();
|
||||
const panel = await s.app.$(".view-panel");
|
||||
await (await (await panel.$("[aria-label='Name on top']")).$("button=App")).click();
|
||||
await s.until(async () => JSON.stringify(await names("test-port")) === JSON.stringify(["Test Port", "Test Port (original)"]));
|
||||
await (await panel.$("label*=Show both names")).click();
|
||||
await s.until(async () => JSON.stringify(await names("test-port")) === JSON.stringify(["Test Port", null]));
|
||||
assert.equal(await (await row("test-port")).getAttribute("data-lines"), "1");
|
||||
// One name: the game's, when picked.
|
||||
await (await (await panel.$("[aria-label='Name']")).$("button=Game")).click();
|
||||
await s.until(async () => JSON.stringify(await names("test-port")) === JSON.stringify(["Test Port (original)", null]));
|
||||
await s.until(() => settings().library?.bothNames === false);
|
||||
await (await panel.$("label*=Show both names")).click();
|
||||
await s.until(() => settings().library?.bothNames === undefined);
|
||||
await s.app.keys("Escape");
|
||||
});
|
||||
|
||||
test("the filters panel's filters save as a playlist, which the sidebar then shows", async () => {
|
||||
await (await s.app.$(".library-sidebar button[aria-label=Filters]")).click();
|
||||
const panel = await s.app.$("[aria-label='Library filters']");
|
||||
await panel.waitForDisplayed();
|
||||
assert.equal(await (await panel.$("button*=Save as playlist")).getAttribute("disabled"), "true", "nothing to save yet");
|
||||
await (await panel.$("select[aria-label=Console]")).selectByVisibleText("Super Nintendo Entertainment System");
|
||||
await s.until(async () => (await slugs()).join() === "tampered-port");
|
||||
await (await panel.$("button*=Save as playlist")).click();
|
||||
const dialog = await s.app.$("[role=dialog][aria-label='New playlist']");
|
||||
// All lowercase: typed without Shift, which in this file came out of WebKit's driver lowercase ("SNES" saved as "snes").
|
||||
await (await dialog.$("input[aria-label='Playlist name']")).setValue("retro picks");
|
||||
await (await dialog.$("button=Save")).click();
|
||||
const show = await s.app.$(".library-sidebar select[aria-label=Show]");
|
||||
await s.until(() => s.app.execute((el) => el.selectedOptions[0]?.textContent, show).then((name) => name === "retro picks"));
|
||||
assert.deepEqual(await slugs(), ["tampered-port"]);
|
||||
assert.ok(!(await s.app.$("[aria-label='Library filters']").isExisting()), "the filters went into the playlist");
|
||||
await s.until(async () => (await open()) === "Tampered Port");
|
||||
await show.selectByVisibleText("All");
|
||||
await s.until(async () => (await slugs()).length === 3);
|
||||
});
|
||||
|
||||
test("the sidebar's edge drags it wider or narrower, and the width stays", async () => {
|
||||
const width = () => s.app.execute(() => document.querySelector(".library-sidebar").offsetWidth);
|
||||
const pane = () => s.app.execute(() => document.querySelector(".library-pane").offsetWidth);
|
||||
const edge = await s.app.$(".sidebar-edge[role=separator]");
|
||||
// The driver can hold a mouse button down after the select the last test picked from: a press then comes as a
|
||||
// pointermove, not a pointerdown, so nothing starts dragging. Let go of everything first.
|
||||
await s.app.releaseActions();
|
||||
const [before, beside] = [await width(), await pane()];
|
||||
// What's at the edge's middle, where the drag starts, for CI's log if it doesn't move.
|
||||
const atEdge = await s.app.execute(() => {
|
||||
const r = document.querySelector(".sidebar-edge").getBoundingClientRect();
|
||||
const top = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
|
||||
return { rect: [r.left, r.top, r.width, r.height].map(Math.round), top: top?.outerHTML.slice(0, 140), window: [innerWidth, innerHeight], scrollY };
|
||||
});
|
||||
// Which pointer events reach the edge and the window during the drag, for the same log.
|
||||
await s.app.execute(() => {
|
||||
window.__drag = [];
|
||||
const edge = document.querySelector(".sidebar-edge");
|
||||
for (const type of ["pointerdown", "pointermove", "pointerup", "lostpointercapture", "mousedown"]) {
|
||||
edge.addEventListener(type, (e) => window.__drag.push(`edge ${type} ${e.button ?? ""}/${e.buttons ?? ""} ${Math.round(e.clientX)}`), true);
|
||||
window.addEventListener(type, (e) => window.__drag.length < 40 && window.__drag.push(`window ${type} ${e.target?.className ?? e.target?.nodeName}`), true);
|
||||
}
|
||||
});
|
||||
await s.app.action("pointer").move({ origin: edge }).down().move({ origin: "pointer", x: 120, y: 0, duration: 200 }).up().perform();
|
||||
try {
|
||||
await s.until(async () => (await width()) === before + 120);
|
||||
} catch (e) {
|
||||
console.log(`sidebar edge: ${JSON.stringify(atEdge)}; width ${before} -> ${await width()}; saved ${settings().sidebarWidth}; events ${JSON.stringify(await s.app.execute(() => window.__drag))}`);
|
||||
throw e;
|
||||
}
|
||||
// The app's page gives up the room.
|
||||
assert.equal(await pane(), beside - 120);
|
||||
await s.until(() => settings().sidebarWidth === before + 120);
|
||||
// Its line shows only under the pointer (or keyboard focus): gone once the pointer is off it.
|
||||
const line = () => s.app.execute(() => getComputedStyle(document.querySelector(".sidebar-edge"), "::after").backgroundColor);
|
||||
await s.app.action("pointer").move({ origin: await s.app.$(".library-pane h1"), duration: 50 }).perform();
|
||||
await s.until(async () => (await line()) === "rgba(0, 0, 0, 0)");
|
||||
// No wider than its widest.
|
||||
await s.app.action("pointer").move({ origin: edge }).down().move({ origin: "pointer", x: 600, y: 0, duration: 200 }).up().perform();
|
||||
await s.until(() => settings().sidebarWidth === 640);
|
||||
// The arrow keys move it too.
|
||||
await edge.click();
|
||||
await s.app.keys("ArrowLeft");
|
||||
await s.until(() => settings().sidebarWidth === 624);
|
||||
assert.equal(await width(), 624);
|
||||
// A double click fits it to the window again.
|
||||
await edge.doubleClick();
|
||||
await s.until(() => settings().sidebarWidth === undefined);
|
||||
await s.until(async () => (await width()) === before);
|
||||
});
|
||||
|
||||
test("Right from the sidebar goes past its edge to the app's page; View options set its width", async () => {
|
||||
const width = () => s.app.execute(() => document.querySelector(".library-sidebar").offsetWidth);
|
||||
const before = await width();
|
||||
await (await row("test-port")).click();
|
||||
await s.app.keys("ArrowRight");
|
||||
// One press: the edge is for the mouse (and Tab), not a stop on the way.
|
||||
await s.until(() => s.app.execute(() => !!document.activeElement?.closest(".library-pane")));
|
||||
assert.equal(await width(), before, "the edge didn't move");
|
||||
// Its widths, for a controller or the keys.
|
||||
await (await s.app.$(".library-sidebar button[aria-label='View options']")).click();
|
||||
const widths = await s.app.$(".view-panel [aria-label='Sidebar width']");
|
||||
await (await widths.$("button=Wide")).click();
|
||||
await s.until(() => settings().sidebarWidth === 420);
|
||||
await s.until(async () => (await width()) === 420);
|
||||
assert.equal(await (await widths.$("button=Wide")).getAttribute("aria-pressed"), "true");
|
||||
// A busy CI runner clicked Fit the window before the panel had followed its button over, and missed it.
|
||||
await s.until(panelFollowed);
|
||||
await (await widths.$("button=Fit the window")).click();
|
||||
await s.until(() => settings().sidebarWidth === undefined);
|
||||
await s.until(async () => (await width()) === before);
|
||||
// Enter ticks and unticks a tickbox, as Confirm does (a Steam Deck's A is Enter in its desktop).
|
||||
const both = await (await (await s.app.$(".view-panel")).$("label*=Show both names")).$("input");
|
||||
const ticked = await both.isSelected();
|
||||
await s.app.execute((el) => el.focus(), both);
|
||||
await s.app.keys("Enter");
|
||||
await s.until(async () => (await both.isSelected()) === !ticked);
|
||||
await s.app.keys("Enter");
|
||||
await s.until(async () => (await both.isSelected()) === ticked);
|
||||
await s.app.keys("Escape");
|
||||
});
|
||||
|
||||
test("a window too narrow for it shows the grid, and the sidebar comes back when it's wide again", async () => {
|
||||
const { x, y } = await s.app.getWindowRect();
|
||||
await s.app.setWindowRect(x, y, 820, 700);
|
||||
await s.until(async () => (await s.app.$(".library-grid").isExisting()) && !(await s.app.$(".library-sidebar").isExisting()));
|
||||
// The top bar stays edge to edge, as in every layout.
|
||||
assert.equal(await topbarPadding(), "14px");
|
||||
// The grid is the only layout that fits, so there's no choice to make.
|
||||
await (await s.app.$("button[aria-label='View options']")).click();
|
||||
await (await s.app.$(".view-panel")).waitForDisplayed();
|
||||
assert.ok(!(await s.app.$(".view-panel [aria-label='Layout']").isExisting()));
|
||||
await s.app.keys("Escape");
|
||||
// Still the player's choice.
|
||||
assert.equal(settings().library?.layout, "sidebar");
|
||||
await s.app.setWindowRect(x, y, 1280, 800);
|
||||
await (await s.app.$(".library-sidebar")).waitForDisplayed();
|
||||
// Saved a moment after it stops changing; the next test restarts the app, which would come back narrow.
|
||||
await s.until(() => JSON.parse(readFileSync(join(s.data, "window.json"), "utf8")).rect.width === 1280);
|
||||
});
|
||||
|
||||
test("apps installed here but not in the library add from their page, or all at once", async () => {
|
||||
// Test Port and Test Remake taken out of the library behind the launcher's back, as another account's would be.
|
||||
const data = s.data;
|
||||
await s.close();
|
||||
const file = join(data, "library.json");
|
||||
writeFileSync(file, JSON.stringify(JSON.parse(readFileSync(file, "utf8")).filter((i) => i.slug === "tampered-port")));
|
||||
s = await launch({ api, data });
|
||||
await s.until(async () => JSON.stringify((await listed()).at(-1)) === JSON.stringify(["Installed, not in your library", ["test-port", "test-remake"]]));
|
||||
// One from its page.
|
||||
await (await row("test-remake")).click();
|
||||
await s.until(async () => (await open()) === "Test Remake");
|
||||
await (await (await s.app.$(".library-pane .app-actions")).$("button*=Add to library")).click();
|
||||
await s.until(async () => JSON.stringify((await listed()).at(-1)) === JSON.stringify(["Installed, not in your library", ["test-port"]]));
|
||||
assert.ok(!(await (await s.app.$(".library-pane .app-actions")).$("button*=Add to library").isExisting()));
|
||||
// The rest at once.
|
||||
await (await s.app.$(".sidebar-group[aria-label='Installed, not in your library'] button.sidebar-group-action")).click();
|
||||
await s.until(async () => (await slugs()).sort().join() === "tampered-port,test-port,test-remake");
|
||||
assert.ok(!(await listed()).some(([heading]) => heading === "Installed, not in your library"));
|
||||
await s.until(() => JSON.parse(readFileSync(file, "utf8")).length === 3);
|
||||
});
|
||||
@@ -1,390 +0,0 @@
|
||||
/**
|
||||
* How the library looks, as each player likes it: one toolbar over the
|
||||
* library, filters as a slim row of pills, and a View menu (the same options
|
||||
* are in Settings) for cover, box art or icon cards, three
|
||||
* card sizes, names or not, a card for each game or each app, and sections by
|
||||
* console. The choice is kept on this computer.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, readFileSync, rmSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let api, s;
|
||||
|
||||
before(async () => {
|
||||
api = await startMockApi();
|
||||
s = await launch({ api });
|
||||
// Three apps in the library: Tampered Port's download is refused, so it stays not installed.
|
||||
for (const slug of ["test-port", "test-remake", "tampered-port"]) {
|
||||
const card = await s.card(slug);
|
||||
await card.waitForDisplayed({ timeout: 20000 });
|
||||
await (await card.$("button=Get")).click();
|
||||
await s.until(async () => (await card.$("button*=Play").isExisting()) || (await card.$('[role="alert"]').isExisting()), 30000);
|
||||
}
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await s?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
const library = "main > div:not(.page-layer)";
|
||||
/** The library's cards, by slug. */
|
||||
const shown = () => s.app.execute((library) => [...document.querySelectorAll(`${library} article`)].map((e) => e.dataset.slug).sort(), library);
|
||||
/** Each card's picture: the image's file name and how it sits (fill, icon, letterbox; "cover" for the catalog's cover). */
|
||||
const pictures = () =>
|
||||
s.app.execute(
|
||||
(library) =>
|
||||
Object.fromEntries(
|
||||
[...document.querySelectorAll(`${library} article`)].map((a) => {
|
||||
const img = a.querySelector(".card-cover img:not([aria-hidden])");
|
||||
return [a.dataset.slug, [img?.getAttribute("src")?.split("/art/").pop() ?? null, a.querySelector(".card-art")?.dataset.fit ?? "cover"]];
|
||||
}),
|
||||
),
|
||||
library,
|
||||
);
|
||||
/** A card's picture frame and the card, in pixels. */
|
||||
const frame = (slug) =>
|
||||
s.app.execute((slug) => {
|
||||
const card = document.querySelector(`main > div:not(.page-layer) article[data-slug="${slug}"]`);
|
||||
const r = card.querySelector(".card-cover").getBoundingClientRect();
|
||||
const c = card.getBoundingClientRect();
|
||||
return { width: Math.round(r.width), height: Math.round(r.height), card: Math.round(c.width) };
|
||||
}, slug);
|
||||
const settings = () => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8"));
|
||||
const panel = () => s.app.$(".view-panel");
|
||||
/** Picks an option in the View menu, opening it first. */
|
||||
async function choose(group, option) {
|
||||
if (!(await (await panel()).isExisting())) await (await s.app.$("button[aria-label='View options']")).click();
|
||||
await (await (await (await panel()).$(`[aria-label='${group}']`)).$(`button=${option}`)).click();
|
||||
}
|
||||
const closeView = async () => {
|
||||
if (await (await panel()).isExisting()) await s.app.keys("Escape");
|
||||
await s.until(async () => !(await (await panel()).isExisting()));
|
||||
};
|
||||
|
||||
test("the library's tools are one row, all one height, beside the playlist tabs", async () => {
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
const tools = await s.app.execute(() =>
|
||||
[...document.querySelector(".library-tools").children].map((el) => {
|
||||
const name = el.querySelector("input, select")?.getAttribute("aria-label") ?? el.getAttribute("aria-label") ?? el.textContent.trim();
|
||||
return [name, Math.round(el.getBoundingClientRect().height)];
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(
|
||||
tools.map(([name]) => name),
|
||||
["Search your library", "Sort", "Group by", "Filters", "View options", "Add an app"],
|
||||
);
|
||||
assert.equal(new Set(tools.map(([, height]) => height)).size, 1, `one height: ${JSON.stringify(tools)}`);
|
||||
// At the default window size the tabs share the row.
|
||||
const [tabs, bar] = await s.app.execute(() => [".playlists", ".library-tools"].map((q) => document.querySelector(q).getBoundingClientRect()));
|
||||
assert.ok(Math.abs(tabs.top + tabs.height / 2 - (bar.top + bar.height / 2)) < 8, "tabs and tools on one row");
|
||||
// No filter row until it's asked for, and no sections until they're picked.
|
||||
assert.ok(!(await s.app.$(".filter-bar").isExisting()));
|
||||
assert.ok(!(await s.app.$(".console-section").isExisting()));
|
||||
});
|
||||
|
||||
test("tabs that don't fit beside the tools fold into a Show menu at their start, rather than take a row", async () => {
|
||||
const folded = () => s.app.execute(() => !document.querySelector(".playlists") && Boolean(document.querySelector(".library-show select")));
|
||||
await s.app.setWindowSize(900, 700);
|
||||
await s.until(folded);
|
||||
const [menu, search] = await s.app.execute(() => [".library-show", ".library-search"].map((q) => document.querySelector(q).getBoundingClientRect().top));
|
||||
assert.ok(Math.abs(menu - search) < 2, "the menu is on the search's row");
|
||||
const choices = await s.app.execute(() => [...document.querySelector(".library-show select").options].map((o) => o.label));
|
||||
// Installed and Not installed are filters only, so they can't disagree with a tab.
|
||||
assert.equal(choices[0], "All");
|
||||
assert.ok(!choices.includes("Installed") && !choices.includes("Not installed"));
|
||||
// Wide again, the tabs are back.
|
||||
await s.app.setWindowSize(1280, 800);
|
||||
await s.until(async () => !(await folded()));
|
||||
assert.ok(await s.app.$("nav[aria-label=Playlists]").isDisplayed());
|
||||
});
|
||||
|
||||
test("arrow keys and controllers move along the tools and into the View menu", async () => {
|
||||
const focused = () => s.app.execute(() => document.activeElement?.getAttribute("aria-label") ?? document.activeElement?.textContent.trim());
|
||||
await s.app.execute(() => document.querySelector("select[aria-label=Sort]").focus());
|
||||
await s.app.keys("ArrowRight");
|
||||
assert.equal(await focused(), "Group by");
|
||||
await s.app.keys("ArrowRight");
|
||||
assert.equal(await focused(), "Filters");
|
||||
await s.app.keys("ArrowRight");
|
||||
assert.equal(await focused(), "View options");
|
||||
await s.app.keys("Enter");
|
||||
await (await panel()).waitForDisplayed();
|
||||
await s.app.keys("ArrowDown");
|
||||
assert.ok(await s.app.execute(() => Boolean(document.activeElement?.closest(".view-panel"))), "down goes into the menu");
|
||||
await s.app.keys("Escape");
|
||||
await s.until(async () => !(await (await panel()).isExisting()));
|
||||
assert.equal(await focused(), "View options");
|
||||
});
|
||||
|
||||
test("filters are a slim row of pills; one that's on can be removed, and Clear all clears them", async () => {
|
||||
await (await s.app.$("button*=Filters")).click();
|
||||
const pills = () => s.app.execute(() => [...document.querySelectorAll(".filter-bar select")].map((e) => e.getAttribute("aria-label")));
|
||||
assert.deepEqual(await pills(), ["Console", "Project type", "AI use", "Tag", "Installed"]);
|
||||
await (await s.app.$(".filter-bar select[aria-label=Console]")).selectByVisibleText("Nintendo 64");
|
||||
await s.until(async () => JSON.stringify(await shown()) === '["test-port","test-remake"]');
|
||||
assert.ok(await (await s.app.$("button[aria-label='Remove filter Nintendo 64']")).isDisplayed());
|
||||
assert.equal(await (await s.app.$(".library-tools .tool-count")).getText(), "1");
|
||||
// Closed, only the filters that are on stay.
|
||||
await (await s.app.$("button*=Filters")).click();
|
||||
await s.until(async () => JSON.stringify(await pills()) === '["Console"]');
|
||||
await (await s.app.$("button=Clear all")).click();
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
assert.ok(!(await s.app.$(".filter-bar").isExisting()), "nothing on, no filter row");
|
||||
// Removing one pill.
|
||||
await (await s.app.$("button*=Filters")).click();
|
||||
await (await s.app.$(".filter-bar select[aria-label='AI use']")).selectByVisibleText("Hide mostly AI-generated apps");
|
||||
await s.until(async () => (await shown()).length === 2);
|
||||
await (await s.app.$("button[aria-label='Remove filter Hide mostly AI-generated']")).click();
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
});
|
||||
|
||||
test("the filters still become a playlist", async () => {
|
||||
await (await s.app.$(".filter-bar select[aria-label=Console]")).selectByVisibleText("Super Nintendo Entertainment System");
|
||||
await s.until(async () => JSON.stringify(await shown()) === '["tampered-port"]');
|
||||
await (await s.app.$("button*=Save as playlist")).click();
|
||||
const dialog = await s.app.$("[role=dialog][aria-label='New playlist']");
|
||||
await (await dialog.$("input[aria-label='Playlist name']")).setValue("SNES");
|
||||
await (await dialog.$("button=Save")).click();
|
||||
await s.until(async () => (await s.openTab()) === "SNES");
|
||||
assert.deepEqual(await shown(), ["tampered-port"]);
|
||||
assert.ok(!(await s.app.$(".filter-bar").isExisting()), "the filters went into the playlist");
|
||||
await s.showTab("All");
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
});
|
||||
|
||||
test("cards show box art, the icon or the cover, falling back to the game's art and then the cover", async () => {
|
||||
// Box art unless the player picks otherwise.
|
||||
assert.deepEqual(await pictures(), {
|
||||
"test-port": ["test-port-capsule.png", "fill"],
|
||||
// No box art of its own: its game's.
|
||||
"test-remake": ["capsule.png", "fill"],
|
||||
// No box art at all: its cover, whole.
|
||||
"tampered-port": ["tampered-port-header.png", "letterbox"],
|
||||
});
|
||||
const box = await frame("test-port");
|
||||
assert.ok(box.height > box.width * 1.4, `box art is portrait: ${JSON.stringify(box)}`);
|
||||
await choose("Card image", "Icon");
|
||||
await s.until(async () => (await pictures())["test-port"][1] === "icon");
|
||||
assert.deepEqual(await pictures(), {
|
||||
"test-port": ["test-port-icon.png", "icon"],
|
||||
"test-remake": ["icon.png", "icon"],
|
||||
"tampered-port": ["tampered-port-header.png", "letterbox"],
|
||||
});
|
||||
// The whole icon shows, above the names rather than under them.
|
||||
const icon = await s.app.execute(() => {
|
||||
const card = document.querySelector(`main > div:not(.page-layer) article[data-slug="test-port"]`);
|
||||
const img = card.querySelector(".card-cover img").getBoundingClientRect();
|
||||
return { icon: Math.round(img.bottom), names: Math.round(card.querySelector(".card-body").getBoundingClientRect().top) };
|
||||
});
|
||||
assert.ok(icon.icon <= icon.names, `the icon is above the names: ${JSON.stringify(icon)}`);
|
||||
// The catalog's cover, as Browse shows it.
|
||||
await choose("Card image", "Cover");
|
||||
await s.until(async () => (await pictures())["test-port"][1] === "cover");
|
||||
assert.deepEqual(await pictures(), {
|
||||
"test-port": ["test-port-header.png", "cover"],
|
||||
"test-remake": ["test-remake-header.png", "cover"],
|
||||
"tampered-port": ["tampered-port-header.png", "cover"],
|
||||
});
|
||||
await choose("Card image", "Box art");
|
||||
await s.until(async () => (await pictures())["test-port"][1] === "fill");
|
||||
await closeView();
|
||||
});
|
||||
|
||||
test("a library card says what this computer has of the app, not the catalog's details", async () => {
|
||||
const status = () =>
|
||||
s.app.execute(
|
||||
(library) => Object.fromEntries([...document.querySelectorAll(`${library} article`)].map((a) => [a.dataset.slug, a.querySelector(".card-status")?.textContent])),
|
||||
library,
|
||||
);
|
||||
// Installed and never played, or refused and not installed.
|
||||
assert.deepEqual(await status(), {
|
||||
"test-port": "Installed, not played yet",
|
||||
"test-remake": "Installed, not played yet",
|
||||
"tampered-port": "Not installed",
|
||||
});
|
||||
const card = await s.card("test-port");
|
||||
assert.ok(!(await card.$(".based-on").isExisting()) && !(await card.$(".card-bottom").isExisting()), "no Based on, rating or release age");
|
||||
assert.ok(!(await card.$(".cover-badge").isExisting()), "not marked New");
|
||||
// Played, it says when, and it's the app to continue at the top of the library.
|
||||
assert.ok(!(await s.app.$("section[aria-label='Continue playing']").isExisting()));
|
||||
// Play shows, with the card's other buttons, while the pointer is on it.
|
||||
await (await card.$(".card-open")).moveTo();
|
||||
await (await card.$("button*=Play")).click();
|
||||
await s.until(async () => (await status())["test-port"] === "Played today");
|
||||
const resume = await s.app.$("section[aria-label='Continue playing']");
|
||||
await resume.waitForDisplayed();
|
||||
// Its name, then the version installed.
|
||||
assert.ok((await (await resume.$(".continue-title")).getText()).startsWith("Test Port"));
|
||||
// Its Play button (or, where the test app can't start, what went wrong).
|
||||
assert.ok(await (await resume.$(".continue-action > *")).isDisplayed());
|
||||
// The catalog button opens the app's page; its name is only its name.
|
||||
await (await resume.$("button[aria-label='See Test Port in the catalog']")).click();
|
||||
await (await (await s.app.$(".app-page")).$("h1=Test Port")).waitForDisplayed();
|
||||
await s.app.keys("Escape");
|
||||
await s.until(async () => !(await (await s.app.$(".app-page")).isDisplayed()));
|
||||
// View options turn it off, and back on.
|
||||
await (await s.app.$("button[aria-label='View options']")).click();
|
||||
await (await (await panel()).$("label*=Show Continue playing")).click();
|
||||
await s.until(async () => !(await s.app.$("section[aria-label='Continue playing']").isExisting()));
|
||||
await s.until(() => settings().library?.continuePlaying === false);
|
||||
await (await (await panel()).$("label*=Show Continue playing")).click();
|
||||
await (await s.app.$("section[aria-label='Continue playing']")).waitForDisplayed();
|
||||
await s.until(() => settings().library?.continuePlaying === undefined);
|
||||
await closeView();
|
||||
});
|
||||
|
||||
test("a grid card shows its names and a mark, and the rest on hover or focus", async () => {
|
||||
const port = await s.card("test-port");
|
||||
const text = async (sel) => (await port.$(sel)).getProperty("textContent");
|
||||
// The game's name large, the app's under it.
|
||||
assert.equal(await text(".card-title"), "Test Port (original)");
|
||||
assert.equal(await text(".card-subtitle"), "Test Port");
|
||||
const marks = await s.app.execute((library) => Object.fromEntries([...document.querySelectorAll(`${library} article`)].map((a) => [a.dataset.slug, a.querySelector(".tile-mark")?.dataset.copy ?? null])), library);
|
||||
// Both installed and ready to play: nothing beside their names (Get's symbol is for one not installed yet). Null, not
|
||||
// undefined, which WebKit's driver sends back as null and WebView2's leaves out.
|
||||
assert.deepEqual([marks["test-port"], marks["test-remake"]], [null, null]);
|
||||
// At rest, only the names; the pointer on it shows its versions and buttons.
|
||||
const play = await port.$("button*=Play");
|
||||
await (await s.app.$(`${library} select[aria-label=Sort]`)).moveTo();
|
||||
await s.until(async () => !(await play.isDisplayed()));
|
||||
await (await port.$(".card-open")).moveTo();
|
||||
await play.waitForDisplayed();
|
||||
assert.match(await (await port.$(".tile-facts")).getText(), /Installed v1\.0\.0\s+Verified v1\.0\.0/);
|
||||
assert.ok(await (await port.$("button*=Open folder")).isDisplayed());
|
||||
await (await s.app.$(`${library} select[aria-label=Sort]`)).moveTo();
|
||||
await s.until(async () => !(await play.isDisplayed()));
|
||||
// Focus shows them too, and a controller's Confirm plays the app rather than opening its page.
|
||||
await s.app.execute(() => document.querySelector('main > div:not(.page-layer) article[data-slug="test-port"] .card-open').focus());
|
||||
await play.waitForDisplayed();
|
||||
const launched = join(s.apps, "test-port", "launched.txt");
|
||||
rmSync(launched, { force: true });
|
||||
for (const down of [true, false])
|
||||
await s.app.execute((down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key: "South", down } }), down);
|
||||
await s.until(() => existsSync(launched));
|
||||
assert.equal(await (await s.app.$(".app-page")).isExisting(), false);
|
||||
// The app's name can be the large one instead.
|
||||
await choose("Large name", "App");
|
||||
await s.until(async () => (await text(".card-title")) === "Test Port");
|
||||
assert.equal(await text(".card-subtitle"), "Test Port (original)");
|
||||
await choose("Large name", "Game");
|
||||
await closeView();
|
||||
await s.until(() => settings().library?.nameOrder === undefined);
|
||||
});
|
||||
|
||||
test("card size changes the layout; names can be hidden", async () => {
|
||||
const medium = await frame("test-port");
|
||||
await choose("Card size", "Small");
|
||||
await s.until(async () => (await frame("test-port")).height < medium.height);
|
||||
const small = await frame("test-port");
|
||||
assert.ok(small.card < medium.card, `small cards are narrower: ${small.card} < ${medium.card}`);
|
||||
await choose("Card size", "Large");
|
||||
await s.until(async () => (await frame("test-port")).height > medium.height);
|
||||
assert.ok((await frame("test-port")).card > medium.card, "large cards are wider");
|
||||
await choose("Card size", "Medium");
|
||||
// Names off: only pictures and buttons.
|
||||
await (await s.app.$("label*=Show names on cards")).click();
|
||||
await s.until(async () => !(await (await (await s.card("test-port")).$(".card-title")).isDisplayed()));
|
||||
await (await s.app.$("label*=Show names on cards")).click();
|
||||
await s.until(async () => (await (await s.card("test-port")).$(".card-title")).isDisplayed());
|
||||
await choose("Card image", "Icon");
|
||||
await closeView();
|
||||
await s.until(() => settings().library?.image === "icon");
|
||||
assert.deepEqual(settings().library, { image: "icon" });
|
||||
});
|
||||
|
||||
test("the library sorts installed apps first or last, or by name, and keeps the choice", async () => {
|
||||
// The cards in the order they're shown.
|
||||
const order = () => s.app.execute((library) => [...document.querySelectorAll(`${library} article`)].map((e) => e.dataset.slug), library);
|
||||
const sortBy = async (label) => (await s.app.$(`${library} select[aria-label=Sort]`)).selectByVisibleText(label);
|
||||
await sortBy("Not installed first");
|
||||
await s.until(async () => (await order()).join() === "tampered-port,test-port,test-remake");
|
||||
await sortBy("Installed first");
|
||||
await s.until(async () => (await order()).join() === "test-port,test-remake,tampered-port");
|
||||
await s.until(() => settings().librarySort === "installed");
|
||||
await sortBy("Recently played");
|
||||
await s.until(() => settings().librarySort === undefined);
|
||||
});
|
||||
|
||||
test("View options can give each game one card, which lists its ports, each with its page and its button", async () => {
|
||||
const cards = () => s.app.execute((library) => [...document.querySelectorAll(`${library} article`)].map((a) => a.dataset.game ?? a.dataset.slug).sort(), library);
|
||||
const oneEach = async () => {
|
||||
if (!(await (await panel()).isExisting())) await (await s.app.$("button[aria-label='View options']")).click();
|
||||
await (await (await panel()).$("label*=One card for each game")).click();
|
||||
};
|
||||
// The library starts with a card for each app.
|
||||
await oneEach();
|
||||
// Test Port's game has Test Remake too; Tampered Port's, only it.
|
||||
await s.until(async () => JSON.stringify(await cards()) === '["tampered-port","test-port"]');
|
||||
await s.until(() => settings().library?.byGame === true);
|
||||
await closeView();
|
||||
const card = await s.app.$(`${library} article[data-game="test-port"]`);
|
||||
assert.equal(await (await card.$(".card-title")).getProperty("textContent"), "Test Port (original)");
|
||||
assert.equal(await (await card.$(".card-subtitle")).getProperty("textContent"), "2 ways to play");
|
||||
// Its ports, the one played last first, each with its button.
|
||||
await (await card.$(".card-open")).click();
|
||||
const list = await s.app.$(".port-panel");
|
||||
await list.waitForDisplayed();
|
||||
const ports = await s.app.execute(() => [...document.querySelectorAll(".port-panel .port-row")].map((r) => [r.querySelector(".port-open strong").textContent, r.querySelector(".port-action button")?.textContent.trim()]));
|
||||
assert.deepEqual(ports, [
|
||||
["Test Port", "Play"],
|
||||
["Test Remake", "Play"],
|
||||
]);
|
||||
// A port's line opens its page.
|
||||
await (await list.$("button*=Test Remake")).click();
|
||||
await (await (await s.app.$(".app-page")).$("h1=Test Remake")).waitForDisplayed();
|
||||
await s.app.keys("Escape");
|
||||
await s.until(async () => !(await (await s.app.$(".app-page")).isDisplayed()));
|
||||
// And a card for each app again.
|
||||
await oneEach();
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
await closeView();
|
||||
await s.until(() => settings().library?.byGame === undefined);
|
||||
});
|
||||
|
||||
test("Settings has the same options under Library", async () => {
|
||||
await s.settings("Library");
|
||||
const section = await s.app.$("section.settings-page [role=region][aria-label=Library]");
|
||||
await section.waitForDisplayed();
|
||||
const pressed = (group) => s.app.execute((group) => document.querySelector(`[aria-label=Settings] [aria-label='${group}'] [aria-pressed=true]`)?.textContent, group);
|
||||
assert.deepEqual([await pressed("Layout"), await pressed("Card image"), await pressed("Card size")], ["Grid", "Icon", "Medium"]);
|
||||
await (await (await section.$("[aria-label='Card image']")).$("button=Box art")).click();
|
||||
await (await (await section.$("[aria-label='Card size']")).$("button=Large")).click();
|
||||
await (await section.$("select[aria-label='Group by']")).selectByVisibleText("Group by console");
|
||||
await s.closeSettings();
|
||||
await (await s.app.$("h2=Nintendo 64")).waitForDisplayed();
|
||||
await (await s.app.$("h2=Super Nintendo Entertainment System")).waitForDisplayed();
|
||||
// Grouped, every section starts folded away.
|
||||
await (await s.app.$(`${library} button[aria-label='Expand all sections']`)).click();
|
||||
await s.until(async () => (await pictures())["test-port"][1] === "fill");
|
||||
await s.until(() => settings().groupBy === "console");
|
||||
assert.deepEqual(settings().library, { size: "large" });
|
||||
});
|
||||
|
||||
test("the view is kept on this computer through a restart", async () => {
|
||||
const data = s.data;
|
||||
await s.close();
|
||||
s = await launch({ api, data });
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
assert.equal(
|
||||
await s.app.execute(() => document.querySelector("main > div:not(.page-layer) .library-grid").className),
|
||||
"catalog-grid library-grid layout-grid image-box size-large",
|
||||
);
|
||||
await (await s.app.$("h2=Nintendo 64")).waitForDisplayed();
|
||||
assert.equal((await pictures())["test-port"][0], "test-port-capsule.png");
|
||||
});
|
||||
|
||||
test("the sort is kept through a restart too", async () => {
|
||||
await (await s.app.$(`${library} select[aria-label=Sort]`)).selectByVisibleText("Not installed first");
|
||||
await s.until(() => settings().librarySort === "not-installed");
|
||||
const data = s.data;
|
||||
await s.close();
|
||||
s = await launch({ api, data });
|
||||
await s.until(async () => (await shown()).length === 3);
|
||||
assert.equal(await (await s.app.$(`${library} select[aria-label=Sort]`)).getValue(), "not-installed");
|
||||
});
|
||||
@@ -1,97 +0,0 @@
|
||||
/**
|
||||
* An app's Media tab, as on the website: its YouTube videos in the order
|
||||
* staff set, filtered by kind, each a thumbnail until it's played, and a
|
||||
* link that opens the video on YouTube in the browser.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { chmodSync, existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, until;
|
||||
// A browser that notes the pages it's asked to open.
|
||||
const dir = mkdtempSync(join(tmpdir(), "quiver-browser-"));
|
||||
const opened = join(dir, "opened.log");
|
||||
const browser = join(dir, "browser.sh");
|
||||
writeFileSync(browser, `#!/bin/sh\necho "$1" >> "${opened}"\n`);
|
||||
chmodSync(browser, 0o755);
|
||||
|
||||
before(async () => {
|
||||
s = await launch({ env: { QUIVER_BROWSER: browser } });
|
||||
({ app, until } = s);
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => app.$(".page-layer:not([hidden]) .app-page");
|
||||
const tabs = () => app.execute(() => [...document.querySelectorAll(".page-layer:not([hidden]) .app-page [role=tab]")].map((t) => t.textContent.trim()));
|
||||
const videos = () =>
|
||||
app.execute(() =>
|
||||
[...document.querySelectorAll(".page-layer:not([hidden]) .media-card")].map((card) => ({
|
||||
kind: card.querySelector(".media-kind").textContent,
|
||||
title: card.querySelector(".media-title")?.textContent ?? null,
|
||||
thumbnail: card.querySelector(".media-play img")?.getAttribute("src") ?? null,
|
||||
player: card.querySelector("iframe")?.getAttribute("src") ?? null,
|
||||
})),
|
||||
);
|
||||
const openApp = async (slug) => {
|
||||
await (await app.$("button=Browse")).click();
|
||||
await (await (await s.card(slug)).$(".card-open")).click();
|
||||
await (await page()).waitForDisplayed();
|
||||
};
|
||||
|
||||
test("an app with videos has a Media tab after Overview, with how many", async () => {
|
||||
await openApp("test-port");
|
||||
await until(async () => (await tabs()).length === 4);
|
||||
assert.deepEqual((await tabs()).slice(0, 2), ["Overview", "Media3"]);
|
||||
});
|
||||
|
||||
test("the videos show in the order staff set, as thumbnails, and filter by kind", async () => {
|
||||
for (const t of await (await page()).$$("button[role=tab]")) if ((await t.getText()).startsWith("Media")) await t.click();
|
||||
await until(async () => (await videos()).length === 3);
|
||||
assert.deepEqual(await videos(), [
|
||||
{ kind: "Trailer", title: "Announcement trailer", thumbnail: "https://i.ytimg.com/vi/aqz-KE-bpKQ/hqdefault.jpg", player: null },
|
||||
{ kind: "Gameplay", title: "First level at 60 fps", thumbnail: "https://i.ytimg.com/vi/jNQXAC9IVRw/hqdefault.jpg", player: null },
|
||||
{ kind: "Gameplay", title: null, thumbnail: "https://i.ytimg.com/vi/M7lc1UVf-VE/hqdefault.jpg", player: null },
|
||||
]);
|
||||
// The first is shown large, the rest two to a row.
|
||||
const widths = await app.execute(() => [...document.querySelectorAll(".page-layer:not([hidden]) .media-card")].map((c) => Math.round(c.getBoundingClientRect().width)));
|
||||
assert.ok(widths[0] > widths[1] * 1.8, `first is large: ${widths}`);
|
||||
assert.equal(widths[1], widths[2]);
|
||||
|
||||
const filters = () => app.execute(() => [...document.querySelectorAll(".media-filters button")].map((b) => [b.textContent, b.getAttribute("aria-pressed")]));
|
||||
assert.deepEqual(await filters(), [["All3", "true"], ["Trailer1", "false"], ["Gameplay2", "false"]]);
|
||||
await (await (await app.$(".media-filters")).$("button*=Gameplay")).click();
|
||||
await until(async () => (await videos()).length === 2);
|
||||
assert.deepEqual((await videos()).map((v) => v.kind), ["Gameplay", "Gameplay"]);
|
||||
await (await (await app.$(".media-filters")).$("button*=All")).click();
|
||||
await until(async () => (await videos()).length === 3);
|
||||
});
|
||||
|
||||
test("playing a video loads YouTube's player in its place, through the website's page for it, one at a time", async () => {
|
||||
await (await app.$('button[aria-label="Play First level at 60 fps"]')).click();
|
||||
await until(async () => (await videos())[1].player !== null);
|
||||
assert.equal((await videos())[1].player, "https://quiverlauncher.com/embed/youtube/jNQXAC9IVRw?start=90");
|
||||
assert.equal((await videos())[0].player, null);
|
||||
await (await app.$('button[aria-label="Play Announcement trailer"]')).click();
|
||||
await until(async () => (await videos())[0].player !== null);
|
||||
assert.equal((await videos())[1].player, null, "the other stopped");
|
||||
// A video with no title is named by its kind.
|
||||
assert.ok(await (await app.$('button[aria-label="Play Gameplay video"]')).isExisting());
|
||||
});
|
||||
|
||||
test("a video's YouTube link opens it on YouTube in the browser, at its start time", async () => {
|
||||
const links = await (await page()).$$(".media-youtube");
|
||||
await links[1].click();
|
||||
await until(() => existsSync(opened) && readFileSync(opened, "utf8").includes("youtube.com"));
|
||||
assert.match(readFileSync(opened, "utf8"), /https:\/\/www\.youtube\.com\/watch\?v=jNQXAC9IVRw&t=90s/);
|
||||
});
|
||||
|
||||
test("an app without videos has no Media tab", async () => {
|
||||
await openApp("tampered-port");
|
||||
await until(async () => (await tabs()).includes("Overview"));
|
||||
assert.ok(!(await tabs()).some((t) => t.startsWith("Media")), JSON.stringify(await tabs()));
|
||||
});
|
||||
@@ -1,126 +0,0 @@
|
||||
/**
|
||||
* Mods for an installed app, from the Thunderstore community and GameBanana
|
||||
* game its catalog entry names: browsing and searching, installing with a
|
||||
* requirement, choosing one of a mod's files, updating, and uninstalling
|
||||
* only what a mod put in the mods folder.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const app = join(data, "apps", "test-port");
|
||||
const mods = join(app, "mods");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
s = await launch({ data });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const dialog = () => s.app.$('[role="dialog"][aria-label="Mods for Test Port"]');
|
||||
const press = async (button) => {
|
||||
await button.waitForDisplayed();
|
||||
await button.scrollIntoView({ block: "center" });
|
||||
await button.click();
|
||||
};
|
||||
const row = async (name) => (await dialog()).$(`li[aria-label="${name}"]`);
|
||||
const inRow = async (name, button) => (await row(name)).$(`button=${button}`);
|
||||
const shown = async (name) => (await row(name)).isExisting();
|
||||
const file = (path) => join(mods, path);
|
||||
const read = (path) => (existsSync(file(path)) ? readFileSync(file(path), "utf8") : null);
|
||||
const record = () => JSON.parse(readFileSync(join(app, ".quiver-mods.json"), "utf8")).mods;
|
||||
|
||||
test("browse, then install a mod with the mod it needs", async () => {
|
||||
const game = await s.card("test-port");
|
||||
await game.waitForDisplayed({ timeout: 20000 });
|
||||
await (await game.$("button=Get")).click();
|
||||
await (await game.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
// A file the player put there themselves.
|
||||
mkdirSync(mods, { recursive: true });
|
||||
writeFileSync(file("mine.nrm"), "mine");
|
||||
await (await game.$(".card-open")).click();
|
||||
// On the app's On this computer tab, with the rest of its setup.
|
||||
await press(await (await s.app.$(".app-page")).$("button*=On this computer"));
|
||||
await press(await (await s.app.$(".app-page")).$("button*=Mods"));
|
||||
await (await dialog()).waitForDisplayed();
|
||||
await (await (await dialog()).$('ul[aria-label="Mods to browse"]')).waitForDisplayed({ timeout: 20000 });
|
||||
|
||||
// Both sources are listed; NSFW mods only when asked for.
|
||||
for (const name of ["Big Head", "Mod Core", "Greener Bushes", "Recolor"]) assert.ok(await shown(name), `${name} is listed`);
|
||||
assert.equal(await shown("Spicy"), false);
|
||||
await press(await (await dialog()).$("label*=Include NSFW"));
|
||||
await s.until(() => shown("Spicy"));
|
||||
await press(await (await dialog()).$("label*=Include NSFW"));
|
||||
await s.until(async () => !(await shown("Spicy")));
|
||||
|
||||
await (await (await dialog()).$('input[aria-label="Search mods"]')).setValue("big");
|
||||
await s.until(async () => !(await shown("Mod Core")));
|
||||
assert.ok(await shown("Big Head"));
|
||||
|
||||
await press(await inRow("Big Head", "Install"));
|
||||
const prompt = await (await dialog()).$('[aria-label="Mod requirements"]');
|
||||
await prompt.waitForDisplayed();
|
||||
assert.match(await prompt.getText(), /Big Head needs Mod Core, which isn't installed yet/);
|
||||
await press(await prompt.$("button=Install both"));
|
||||
await s.until(() => read("BigHead.nrm") === "big head 1.1.0" && read("ModCore.nrm") === "core", 20000);
|
||||
await (await (await row("Big Head")).$("span=Installed")).waitForDisplayed();
|
||||
assert.equal(read("textures/head.png"), "head");
|
||||
// Thunderstore's own files stay out of the game's folder.
|
||||
assert.equal(read("manifest.json"), null);
|
||||
assert.equal(read("README.md"), null);
|
||||
assert.deepEqual(record().map((m) => [m.key, m.version]).sort(), [
|
||||
["thunderstore:Modder-Big_Head", "1.1.0"],
|
||||
["thunderstore:Modder-Mod_Core", "1.0.0"],
|
||||
]);
|
||||
});
|
||||
|
||||
test("a GameBanana mod with several files asks which one", async () => {
|
||||
// Typed away, so the page hears it.
|
||||
await (await (await dialog()).$('input[aria-label="Search mods"]')).click();
|
||||
await s.app.keys(["Control", "a"]);
|
||||
await s.app.keys("Backspace");
|
||||
await s.until(() => shown("Recolor"));
|
||||
await press(await (await dialog()).$("button.chip=GameBanana"));
|
||||
await s.until(async () => !(await shown("Big Head")));
|
||||
|
||||
await press(await inRow("Recolor", "Install"));
|
||||
const picker = await (await dialog()).$('[aria-label="Choose a file"]');
|
||||
await picker.waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await picker.getText(), /The blue one/);
|
||||
await press(await picker.$("button*=recolor-blue.zip"));
|
||||
await s.until(() => read("blue.pak") === "blue", 20000);
|
||||
assert.equal(read("red.pak"), null);
|
||||
|
||||
// One file installs straight away, out of the folder it came in.
|
||||
await press(await inRow("Greener Bushes", "Install"));
|
||||
await s.until(() => read("bushes.pak") === "bushes", 20000);
|
||||
assert.ok(s.api.modDownloads.includes("recolor-blue.zip") && !s.api.modDownloads.includes("recolor-red.zip"));
|
||||
});
|
||||
|
||||
test("update all, then uninstall only what a mod put there", async () => {
|
||||
s.api.publishMod({ name: "Big_Head", version: "1.2.0", dependencies: ["Modder-Mod_Core-1.0.0"], files: { "BigHead.nrm": "big head 1.2.0" } });
|
||||
await press(await (await dialog()).$("button=Refresh"));
|
||||
await press(await (await dialog()).$('button[role="tab"]*=Installed'));
|
||||
const list = await (await dialog()).$('ul[aria-label="Installed mods"]');
|
||||
await list.waitForDisplayed();
|
||||
await (await (await row("Big Head")).$("span=Update available")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await (await dialog()).getText(), /1 mod has an update/);
|
||||
|
||||
await press(await (await dialog()).$("button=Update all"));
|
||||
await s.until(() => read("BigHead.nrm") === "big head 1.2.0", 20000);
|
||||
// The file the old version had and this one doesn't is gone.
|
||||
await s.until(() => read("textures/head.png") === null);
|
||||
await (await (await row("Big Head")).$("span=Installed")).waitForDisplayed();
|
||||
|
||||
await press(await inRow("Mod Core", "Uninstall"));
|
||||
await s.until(() => read("ModCore.nrm") === null);
|
||||
await s.until(async () => !(await shown("Mod Core")));
|
||||
assert.equal(read("mine.nrm"), "mine");
|
||||
assert.equal(read("BigHead.nrm"), "big head 1.2.0");
|
||||
assert.deepEqual(record().map((m) => m.key).sort(), ["gamebanana:101", "gamebanana:102", "thunderstore:Modder-Big_Head"]);
|
||||
});
|
||||
@@ -1,134 +0,0 @@
|
||||
/**
|
||||
* Apps the player adds themselves: from a GitLab repository (picking one of
|
||||
* several games in a release), a program already on this computer, and a
|
||||
* folder they fill. Each opens its folder, and only a downloaded one is
|
||||
* ever deleted.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { chmodSync, copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const windows = process.platform === "win32";
|
||||
// A program of the player's own, somewhere outside the launcher, that leaves a mark where it starts.
|
||||
const games = mkdtempSync(join(tmpdir(), "quiver-own-"));
|
||||
const program = join(games, windows ? "Mini Game.cmd" : "Mini Game.sh");
|
||||
writeFileSync(program, windows ? "@echo played> launched.txt\r\n" : "#!/bin/sh\necho played > launched.txt\n");
|
||||
if (!windows) chmodSync(program, 0o755);
|
||||
const opened = join(games, "opened.log");
|
||||
|
||||
let s, app, api, apps, until;
|
||||
|
||||
before(async () => {
|
||||
s = await launch({ env: { QUIVER_PICK: program, QUIVER_OPENED: opened } });
|
||||
({ app, api, apps, until } = s);
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => app.$(".page-layer:not([hidden]) .app-page");
|
||||
const heading = () => page().then((p) => p.$("h1")).then((h) => h.getText()).catch(() => "");
|
||||
const dialog = () => app.$("[role=dialog][aria-label='Add an app']");
|
||||
const addAn = async (way) => {
|
||||
// In the library: Browse's button is the catalog's submission form.
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button*=Add an app")).click();
|
||||
await (await (await dialog()).$(`button*=${way}`)).click();
|
||||
};
|
||||
/** Folders the launcher was asked to show, newest last. */
|
||||
const shown = () => (existsSync(opened) ? readFileSync(opened, "utf8").trim().split("\n").map((l) => l.replace(/^\d+ /, "")) : []);
|
||||
const library = () => JSON.parse(readFileSync(join(s.data, "library.json"), "utf8"));
|
||||
|
||||
test("a GitLab repository with several games in a release: the player picks theirs, and it installs", async () => {
|
||||
await addAn("From GitHub or GitLab");
|
||||
await (await app.$("input[aria-label=Repository]")).setValue("https://gitlab.com/someone/collection/-/releases");
|
||||
await (await app.$("button=Look it up")).click();
|
||||
const files = await app.$("fieldset.pick-file");
|
||||
await files.waitForDisplayed({ timeout: 10000 });
|
||||
const os = windows ? "windows" : "linux";
|
||||
const choices = await app.execute(() => [...document.querySelectorAll("fieldset.pick-file input")].map((i) => i.value));
|
||||
assert.deepEqual(choices, [`GameA-v1.0-${os}-x64.zip`, `GameB-v1.0-${os}-x64.zip`]);
|
||||
await (await app.$(`input[value="GameB-v1.0-${os}-x64.zip"]`)).click();
|
||||
const name = await app.$("[role=dialog] input[aria-label=Name]");
|
||||
await name.setValue("Game B");
|
||||
await (await app.$("button=Add and get")).click();
|
||||
await until(async () => (await heading()) === "Game B");
|
||||
await until(() => existsSync(join(apps, "collection", ".quiver-version")), 30000);
|
||||
assert.deepEqual(api.downloads().slice(-1), [`GameB-v1.0-${os}-x64.zip`]);
|
||||
// It stays on Game B in later releases, and it's marked as one Quiver hasn't checked.
|
||||
const item = library().find((i) => i.id === "gitlab:someone/collection");
|
||||
assert.deepEqual(item.custom, { provider: "gitlab", repository: "someone/collection", name: "Game B", assetFilter: "gameb" });
|
||||
assert.match(await (await (await page()).$(".verified")).getText(), /not checked by Quiver/);
|
||||
// Open folder shows where it's installed.
|
||||
await (await (await page()).$("button*=Open folder")).click();
|
||||
await until(() => shown().at(-1) === join(apps, "collection"));
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("a program already on this computer starts where it is, and removing it leaves it there", async () => {
|
||||
await addAn("A program on this computer");
|
||||
await (await app.$("button=Choose the program…")).click();
|
||||
await (await app.$(`p=${program}`)).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await (await app.$("[role=dialog] input[aria-label=Name]")).getValue(), "Mini Game");
|
||||
await (await (await dialog()).$("button=Add")).click();
|
||||
await until(async () => (await heading()) === "Mini Game");
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
await until(() => existsSync(join(games, "launched.txt")));
|
||||
await (await (await page()).$("button*=Open folder")).click();
|
||||
await until(() => shown().at(-1)?.replace(/[\\/]$/, "") === games);
|
||||
// It's on this computer only: not in an account's library, and not in the apps folder.
|
||||
const item = library().find((i) => i.local);
|
||||
assert.deepEqual(item.local, { kind: "program", path: program, name: "Mini Game" });
|
||||
assert.equal(item.account, undefined);
|
||||
await (await (await page()).$("button*=Remove from library")).click();
|
||||
await until(() => !library().some((i) => i.local));
|
||||
assert.ok(existsSync(program), "the player's program is still there");
|
||||
// Its page went with it: Forward has nothing to open again.
|
||||
await app.keys(["Alt", "ArrowRight"]);
|
||||
await app.pause(500);
|
||||
assert.equal(await heading(), "");
|
||||
});
|
||||
|
||||
test("a folder to fill, with the game's artwork matched by name, plays once a program is in it", async () => {
|
||||
await addAn("A folder you fill yourself");
|
||||
// Never a folder that's already there, such as another app's.
|
||||
await (await app.$("[role=dialog] input[aria-label=Name]")).setValue("collection");
|
||||
await (await app.$("button=Make the folder")).click();
|
||||
await (await app.$("p*=There's already a folder named collection")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await app.$("[role=dialog] input[aria-label=Name]")).setValue("Tampered");
|
||||
// The game it plays is matched by name and picked, for its artwork and consoles.
|
||||
const match = await app.$('.art-match button[data-game="tampered-port"]');
|
||||
await match.waitForDisplayed({ timeout: 10000 });
|
||||
await until(async () => (await match.getAttribute("aria-pressed")) === "true");
|
||||
await (await app.$("button=Make the folder")).click();
|
||||
await until(async () => (await heading()) === "Tampered");
|
||||
const folder = join(apps, "Tampered");
|
||||
assert.ok(existsSync(folder));
|
||||
await until(() => shown().at(-1) === folder);
|
||||
assert.match(await (await (await page()).$(".eyebrow")).getText(), /SUPER NINTENDO ENTERTAINMENT SYSTEM/);
|
||||
assert.equal(await (await (await page()).$(".based-on .game-chip")).getText(), "Tampered Port (original)");
|
||||
// Empty, it has nothing to start yet.
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
const alert = await (await page()).$("[role=alert]");
|
||||
await alert.waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await alert.getText(), /Couldn't find a program to start/);
|
||||
await (await alert.$("button=Dismiss")).click();
|
||||
// The player puts the app in its folder, and Play starts it there.
|
||||
mkdirSync(join(folder, "bin"));
|
||||
if (windows) copyFileSync(join(process.env.SystemRoot ?? "C:\\Windows", "System32", "hostname.exe"), join(folder, "bin", "game.exe"));
|
||||
else copyFileSync(program, join(folder, "bin", "game.sh"));
|
||||
await (await (await page()).$("button*=Play")).click();
|
||||
if (windows) {
|
||||
// hostname.exe leaves no mark; starting it without a problem is enough here (Linux checks the mark).
|
||||
await new Promise((r) => setTimeout(r, 2000));
|
||||
assert.ok(!(await (await page()).$("[role=alert]").isExisting()), "Play started the program");
|
||||
} else {
|
||||
await until(() => existsSync(join(folder, "bin", "launched.txt")));
|
||||
}
|
||||
await (await (await page()).$("button*=Remove from library")).click();
|
||||
await until(() => !library().some((i) => i.local));
|
||||
assert.ok(existsSync(join(folder, "bin")), "the player's files are still there");
|
||||
});
|
||||
@@ -4,8 +4,6 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"e2e": "node --test --test-concurrency=1 --test-force-exit \"!(live|phone).test.js\"",
|
||||
"e2e:ci": "node run.js --concurrency=2 --max-failures=3",
|
||||
"live": "node --test live.test.js",
|
||||
"phone": "node --test --test-force-exit phone.test.js",
|
||||
"web": "node --test --test-force-exit \"web/*.test.js\""
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
/**
|
||||
* Journeys for what Quiver Launcher 3 could do: catalog filters, an app's
|
||||
* README, repository and versions, shortcuts, library playlists and bindings.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, api, apps, card, until;
|
||||
// A home folder with a desktop and a Steam account, so shortcuts land somewhere we can look.
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const steamConfig = join(home, ".steam/steam/userdata/42/config");
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(join(home, "Desktop"));
|
||||
mkdirSync(steamConfig, { recursive: true });
|
||||
// Browse matches the website's catalog here, apps in the library included (browse-owned.test.js covers leaving them out).
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ browseShowsLibrary: true }));
|
||||
s = await launch({ data, env: { HOME: home } });
|
||||
({ app, api, apps, card, until } = s);
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const dialog = () => app.$('[role="dialog"]');
|
||||
const page = () => app.$(".app-page");
|
||||
const open = async (slug) => (await (await card(slug)).$(".card-open")).click();
|
||||
|
||||
test("the catalog's search, sort, Filters, View options and Submit an app are one row, all one height", async () => {
|
||||
await (await card("tampered-port")).waitForDisplayed({ timeout: 20000 });
|
||||
const tools = await app.execute(() =>
|
||||
[document.querySelector(".browse-search"), ...document.querySelector(".browse-tools").children].map((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
// Filters without its count (apps in the library shown counts, as here).
|
||||
const name = el.textContent.replace(el.querySelector(".tool-count")?.textContent ?? "", "").trim();
|
||||
return [el.querySelector("input, select")?.getAttribute("aria-label") ?? el.getAttribute("aria-label") ?? name, Math.round(r.height), Math.round(r.top)];
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(
|
||||
tools.map(([name]) => name),
|
||||
["Search the catalog", "Sort", "Filters", "View options", "Submit an app"],
|
||||
);
|
||||
assert.equal(new Set(tools.map(([, height]) => height)).size, 1, `one height: ${JSON.stringify(tools)}`);
|
||||
assert.equal(new Set(tools.map(([, , top]) => top)).size, 1, `one row: ${JSON.stringify(tools)}`);
|
||||
// No filter row until it's asked for: this computer's platform is the default, not a filter.
|
||||
assert.ok(!(await app.$(".filter-bar").isExisting()));
|
||||
});
|
||||
|
||||
test("the catalog filters by console and sorts as the website does", async () => {
|
||||
await (await app.$("button*=Filters")).click();
|
||||
const pills = () => app.execute(() => [...document.querySelectorAll(".filter-bar select")].map((e) => e.getAttribute("aria-label")));
|
||||
// And whether apps in the library show, which this player has on.
|
||||
assert.deepEqual(await pills(), ["Platform", "Console", "Project type", "AI use", "Apps in your library"]);
|
||||
// Their lists take the theme's colours, not the system's light ones (as Windows draws them), here in the dark theme.
|
||||
const colours = await app.execute(() => {
|
||||
const was = document.documentElement.dataset.theme;
|
||||
document.documentElement.dataset.theme = "dark";
|
||||
const css = (el, prop) => getComputedStyle(el).getPropertyValue(prop).trim();
|
||||
const panel = document.createElement("div");
|
||||
panel.style.background = "var(--panel)";
|
||||
panel.style.color = "var(--fg)";
|
||||
document.body.append(panel);
|
||||
const want = [css(panel, "background-color"), css(panel, "color")];
|
||||
panel.remove();
|
||||
const option = [css(document.querySelector(".filter-bar select option"), "background-color"), css(document.querySelector(".filter-bar select option"), "color")];
|
||||
document.documentElement.dataset.theme = was;
|
||||
return { option, want };
|
||||
});
|
||||
assert.notEqual(colours.want[0], "rgb(255, 255, 255)");
|
||||
assert.deepEqual(colours.option, colours.want);
|
||||
await (await app.$(".filter-bar select[aria-label=Console]")).selectByVisibleText("Nintendo 64");
|
||||
await until(async () => !(await (await card("tampered-port")).isExisting()));
|
||||
assert.equal(api.lastQuery().get("console"), "n64");
|
||||
// The console, and apps in the library shown.
|
||||
assert.equal(await (await app.$(".browse-tools .tool-count")).getText(), "2");
|
||||
await (await app.$("select[aria-label=Sort]")).selectByVisibleText("Top rated");
|
||||
await until(() => api.lastQuery().get("sort") === "rating");
|
||||
// Closed, only the filters that are on stay, each removable, with the order picked first.
|
||||
await (await app.$("button*=Filters")).click();
|
||||
await until(async () => JSON.stringify(await pills()) === '["Console","Apps in your library"]');
|
||||
assert.ok(await (await app.$("button[aria-label='Remove filter Top rated']")).isExisting());
|
||||
await (await app.$("button[aria-label='Remove filter Nintendo 64']")).click();
|
||||
await (await card("tampered-port")).waitForDisplayed();
|
||||
assert.equal(api.lastQuery().get("sort"), "rating", "the sort stays");
|
||||
// Its pill too, till it's removed: then the front page again, and no filter row.
|
||||
await (await app.$("button[aria-label='Remove filter Top rated']")).click();
|
||||
await until(async () => !(await app.$(".filter-bar").isExisting()));
|
||||
});
|
||||
|
||||
test("cards show what the website's cards show", async () => {
|
||||
const port = await card("test-port");
|
||||
// A box art card, as the website's: the game it's based on under its name, then what players said.
|
||||
assert.equal(await (await port.$(".card-subtitle")).getText(), "Test Port (original)");
|
||||
assert.match(await (await port.$(".card-bottom")).getText(), /Runs well · 3 players/);
|
||||
});
|
||||
|
||||
test("an app opens as a full page, with its README and a link to its repository", async () => {
|
||||
await (await (await card("test-port")).$("button=Get")).click();
|
||||
await (await (await card("test-port")).$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
await open("test-port");
|
||||
assert.equal(await (await page()).$("h1").then((h) => h.getText()), "Test Port");
|
||||
assert.equal(await (await card("test-port")).isDisplayed(), false);
|
||||
// Back returns to the catalog as it was.
|
||||
await (await (await page()).$("button.back-link")).click();
|
||||
await (await card("test-port")).waitForDisplayed();
|
||||
await open("test-port");
|
||||
await (await (await page()).$(".readme")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await (await page()).$(".readme")).getText(), /A test port/);
|
||||
const link = await (await page()).$("a.repo-link");
|
||||
assert.match(await link.getText(), /quiver\/test-port/);
|
||||
assert.equal(await link.getAttribute("href"), "https://github.com/quiver/test-port");
|
||||
});
|
||||
|
||||
test("any release can be installed, and each says whether Quiver verified it", async () => {
|
||||
await (await (await page()).$("button*=On this computer")).click();
|
||||
await (await (await page()).$("button=Change version")).click();
|
||||
const row = (version) => app.$(`//section[@aria-label="Versions"]//li[strong[text()="${version}"]]`);
|
||||
await (await row("v0.9.0")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await row("1.0.0")).getText(), /Verified[\s\S]*Installed/);
|
||||
assert.match(await (await row("v1.1.0")).getText(), /Unverified/);
|
||||
assert.match(await (await row("v0.9.0")).getText(), /Unverified/);
|
||||
// One out on GitHub that the site hasn't seen yet.
|
||||
assert.match(await (await row("v1.1.5")).getText(), /Unverified/);
|
||||
// One a maintainer stopped says why, and has no pin.
|
||||
assert.match(await (await row("v0.8.0")).getText(), /Blocked[\s\S]*A maintainer is taking a closer look\./);
|
||||
assert.match(await (await row("v0.8.0")).getAttribute("class"), /blocked/);
|
||||
assert.ok(!(await (await (await row("v0.8.0")).$("button.pin-button")).isExisting()), "a blocked release can't be pinned");
|
||||
// One that's being checked asks first, and waiting is the easy choice.
|
||||
const warning = () => app.$(`//section[@role="dialog"][@aria-label="Install a release before it's verified"]`);
|
||||
await (await (await row("v1.1.0")).$("button=Install")).click();
|
||||
await (await warning()).waitForDisplayed({ timeout: 10000 });
|
||||
const text = await (await warning()).getText();
|
||||
assert.match(text, /Install v1\.1\.0 before it.s verified\?/);
|
||||
assert.match(text, /VirusTotal: no antivirus engine flags its files\./);
|
||||
assert.match(text, /If you wait, it.s verified in about 3[01] hours/);
|
||||
assert.equal(await app.execute(() => document.activeElement?.textContent), "Wait");
|
||||
await (await (await warning()).$("button=Wait")).click();
|
||||
await (await warning()).waitForDisplayed({ reverse: true });
|
||||
// A blocked one installs only once the player ticks that they understand, and keeping what they have is the easy choice.
|
||||
const insist = () => app.$(`//section[@role="dialog"][@aria-label="Install a blocked release"]`);
|
||||
await (await (await row("v0.8.0")).$("button=Install")).click();
|
||||
await (await insist()).waitForDisplayed({ timeout: 10000 });
|
||||
const why = await (await insist()).getText();
|
||||
assert.match(why, /Install a blocked release\?/);
|
||||
assert.match(why, /A maintainer is taking a closer look\./);
|
||||
assert.match(why, /VirusTotal: 1 of 70 engines flag one of its files\./);
|
||||
assert.equal(await app.execute(() => document.activeElement?.textContent), "Keep v1.0.0");
|
||||
const anyway = async () => (await insist()).$("button=Install v0.8.0 anyway");
|
||||
assert.equal(await (await anyway()).isEnabled(), false);
|
||||
await (await (await insist()).$("label*=I understand Quiver blocked this release")).click();
|
||||
await until(async () => (await anyway()).isEnabled());
|
||||
await (await anyway()).click();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "v0.8.0", 30000);
|
||||
assert.equal(api.downloads().at(-1), "test-port-v0.8.0-linux.zip");
|
||||
// The app says it's blocked, and why, and offers the verified release.
|
||||
await (await (await page()).$(".app-hero .release-badge.blocked")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await (await page()).$(".release-pinned-line.blocked")).getText(), /Quiver blocked v0\.8\.0: A maintainer is taking a closer look\.\s*Install the verified v1\.0\.0/);
|
||||
assert.equal(JSON.parse(readFileSync(join(s.data, "installs.json"), "utf8"))["entry_test-port"].blocked, "A maintainer is taking a closer look.");
|
||||
await (await (await page()).$("button*=On this computer")).click();
|
||||
await (await (await page()).$("button=Change version")).click();
|
||||
await (await row("v0.9.0")).waitForDisplayed({ timeout: 10000 });
|
||||
// One the site knows installs the files Quiver saw, against their checksum.
|
||||
await (await (await row("v0.9.0")).$("button=Install")).click();
|
||||
assert.match(await (await warning()).getText(), /No maintainer has checked this release\./);
|
||||
await (await (await warning()).$("button=Install anyway")).click();
|
||||
await until(() => readFileSync(join(apps, "test-port", ".quiver-version"), "utf8") === "v0.9.0", 30000);
|
||||
assert.equal(api.downloads().at(-1), "test-port-v0.9.0-linux.zip");
|
||||
// Picking a version only installs it: the verified release is still offered, and the app says it's unverified.
|
||||
assert.equal(await (await (await page()).$("select")).getValue(), "ask");
|
||||
await (await (await page()).$("button=Update to v1.0.0")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.ok(await (await (await page()).$(".app-hero .release-badge.unverified")).isExisting(), "the app says it's unverified");
|
||||
assert.equal(JSON.parse(readFileSync(join(s.data, "installs.json"), "utf8"))["entry_test-port"].unverified, true);
|
||||
assert.equal(JSON.parse(readFileSync(join(s.data, "installs.json"), "utf8"))["entry_test-port"].blocked, undefined);
|
||||
});
|
||||
|
||||
test("staying on a version is its own choice, and it shows", async () => {
|
||||
await (await (await page()).$("button*=On this computer")).click();
|
||||
await (await (await page()).$("button=Change version")).click();
|
||||
const row = (version) => app.$(`//section[@aria-label="Versions"]//li[strong[text()="${version}"]]`);
|
||||
await (await (await row("v0.9.0")).$("button.pin-button")).click();
|
||||
await until(async () => (await (await (await page()).$("select")).getValue()) === "pinned");
|
||||
assert.equal(await (await (await row("v0.9.0")).$("button.pin-button")).getAttribute("aria-pressed"), "true");
|
||||
const line = await (await page()).$(".release-pinned-line");
|
||||
assert.match(await line.getText(), /Pinned to v0\.9\.0\. v1\.0\.0 is available\./);
|
||||
assert.ok(!(await (await (await page()).$("button=Update to v1.0.0")).isExisting()), "no update offered while pinned");
|
||||
assert.ok(await (await (await page()).$(".pin-mark")).isExisting(), "the app shows it's pinned");
|
||||
// Unpinning offers the verified release again. (Mid-page, so the sticky top bar doesn't cover it.)
|
||||
const unpin = await line.$("button=Unpin");
|
||||
await unpin.scrollIntoView({ block: "center" });
|
||||
await unpin.click();
|
||||
await (await (await page()).$("button=Update to v1.0.0")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.equal(await (await (await page()).$("select")).getValue(), "ask");
|
||||
});
|
||||
|
||||
test("an unverified install turns verified once Quiver verifies the same file", async () => {
|
||||
api.release("0.9.0");
|
||||
await app.keys("Escape");
|
||||
await (await app.$("button*=Library")).click();
|
||||
await (await app.$("button=Browse")).click();
|
||||
await until(() => !JSON.parse(readFileSync(join(s.data, "installs.json"), "utf8"))["entry_test-port"].unverified, 30000);
|
||||
await open("test-port");
|
||||
assert.ok(!(await (await (await page()).$(".app-hero .release-badge.unverified")).isExisting()));
|
||||
api.release("1.0.0");
|
||||
});
|
||||
|
||||
test("a desktop shortcut and a Steam shortcut start the game", async () => {
|
||||
await (await (await page()).$("button*=On this computer")).click();
|
||||
await (await (await page()).$("button*=Desktop shortcut")).click();
|
||||
await (await app.$(".shortcuts p")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await (await app.$(".shortcuts p")).getText(), /is on your desktop/);
|
||||
const desktop = readFileSync(join(home, "Desktop", "Test Port.desktop"), "utf8");
|
||||
assert.match(desktop, /Exec=".*test-port.*port\.sh"/);
|
||||
await (await (await page()).$("button=Add to Steam")).click();
|
||||
await (await app.$("p*=is in Steam")).waitForDisplayed({ timeout: 10000 });
|
||||
const vdf = readFileSync(join(steamConfig, "shortcuts.vdf"));
|
||||
assert.ok(vdf.includes("Test Port") && vdf.includes("port.sh") && vdf.includes("QuiverLauncher"));
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("library playlists: installed or not, a hand-picked collection, and sections by console", async () => {
|
||||
// Tampered Port stays in the library, not installed (its download is refused).
|
||||
await (await (await card("tampered-port")).$("button=Get")).click();
|
||||
await (await (await card("tampered-port")).$('[role="alert"]')).waitForDisplayed({ timeout: 30000 });
|
||||
await (await app.$("button*=Library")).click();
|
||||
const playlist = (name) => s.showTab(name);
|
||||
const shown = () => app.execute(() => [...document.querySelectorAll("main article")].map((e) => e.dataset.slug).sort());
|
||||
await (await app.$(".filters-tool")).click();
|
||||
const installed = await app.$("#library-filters select[aria-label='Installed']");
|
||||
await installed.selectByVisibleText("Installed only");
|
||||
assert.deepEqual(await shown(), ["test-port"]);
|
||||
await installed.selectByVisibleText("Not installed only");
|
||||
assert.deepEqual(await shown(), ["tampered-port"]);
|
||||
await installed.selectByVisibleText("Installed or not");
|
||||
await (await app.$(".filters-tool")).click();
|
||||
await (await app.$("button[aria-label='Add a playlist']")).click();
|
||||
await (await (await app.$("[role=menu]")).$("button=New playlist")).click();
|
||||
await (await app.$("input[aria-label='Playlist name']")).setValue("Favourites");
|
||||
await (await (await dialog()).$("button=Save")).click();
|
||||
await (await app.$("p*=No apps in this playlist yet.")).waitForDisplayed();
|
||||
await playlist("All");
|
||||
await open("test-port");
|
||||
// Its playlists are on its page's On this computer tab.
|
||||
await (await (await page()).$("button*=On this computer")).click();
|
||||
await (await (await page()).$("button.chip=Favourites")).click();
|
||||
await app.keys("Escape");
|
||||
await playlist("Favourites");
|
||||
await until(async () => JSON.stringify(await shown()) === '["test-port"]');
|
||||
await playlist("All");
|
||||
// Sections by console are in the Group by menu, beside Sort. They start folded away, to open the one wanted; a
|
||||
// section's heading opens it, and folds it away again.
|
||||
await (await app.$(".library-tools select[aria-label='Group by']")).selectByVisibleText("Group by console");
|
||||
await (await app.$("h2=Nintendo 64")).waitForDisplayed();
|
||||
await (await app.$("h2=Super Nintendo Entertainment System")).waitForDisplayed();
|
||||
assert.ok(!(await (await app.$(".console-section article")).isExisting()), "every section starts folded");
|
||||
await (await app.$("h2=Nintendo 64")).$("button").then((b) => b.click());
|
||||
await (await app.$("section[aria-label='Nintendo 64'] article")).waitForDisplayed();
|
||||
assert.ok(!(await (await app.$("section[aria-label='Super Nintendo Entertainment System'] article")).isExisting()));
|
||||
await (await app.$("h2=Nintendo 64")).$("button").then((b) => b.click());
|
||||
await until(async () => !(await (await app.$("section[aria-label='Nintendo 64'] article")).isExisting()));
|
||||
const saved = JSON.parse(readFileSync(join(s.data, "collections.json"), "utf8"));
|
||||
assert.deepEqual(saved.map((c) => [c.name, c.apps]), [["Favourites", ["entry_test-port"]]]);
|
||||
});
|
||||
|
||||
test("settings show controllers and rebind keys and buttons", async () => {
|
||||
await s.settings("Controllers");
|
||||
await (await app.$("p*=No controllers detected")).waitForDisplayed();
|
||||
await (await app.$("button[aria-label='Options: keyboard']")).click();
|
||||
await app.keys("p");
|
||||
await until(async () => (await (await app.$("button[aria-label='Options: keyboard']")).getText()) === "P");
|
||||
await (await app.$("button[aria-label='Confirm / Select: controller']")).click();
|
||||
await app.execute(() => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key: "West", down: true } }));
|
||||
await until(async () => (await (await app.$("button[aria-label='Confirm / Select: controller']")).getText()) === "X");
|
||||
await until(() => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8")).pad?.confirm?.[0] === "West");
|
||||
assert.deepEqual(JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8")).keys.options, ["P"]);
|
||||
await s.closeSettings();
|
||||
});
|
||||
@@ -1,148 +0,0 @@
|
||||
/**
|
||||
* Library filters and playlists: filter the library as the catalog filters,
|
||||
* keep a filter as a playlist, add an app to a playlist by hand, share a
|
||||
* playlist that another player adds to their library, and a playlist of words
|
||||
* in apps' names with one of its apps' icons.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let api, a, b, link;
|
||||
|
||||
before(async () => {
|
||||
api = await startMockApi();
|
||||
a = await launch({ api });
|
||||
// Three apps in the library: Tampered Port's download is refused, so it stays not installed.
|
||||
for (const slug of ["test-port", "test-remake", "tampered-port"]) {
|
||||
const card = await a.card(slug);
|
||||
await card.waitForDisplayed({ timeout: 20000 });
|
||||
await (await card.$("button=Get")).click();
|
||||
await a.until(async () => (await card.$("button*=Play").isExisting()) || (await card.$('[role="alert"]').isExisting()), 30000);
|
||||
}
|
||||
await (await a.app.$("button*=Library")).click();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await a?.close();
|
||||
await b?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
/** The library's cards, in order. */
|
||||
const shown = (s) => s.app.execute(() => [...document.querySelectorAll("main > div:not(.page-layer) article")].map((e) => e.dataset.slug).sort());
|
||||
const inMenu = async (s, menu, item) => (await s.app.$(menu)).$(`button=${item}`);
|
||||
const collections = () => JSON.parse(readFileSync(join(a.data, "collections.json"), "utf8"));
|
||||
/** Whether an open menu is really on top where it is: nothing clips or covers its middle. */
|
||||
const onTop = (s, selector) =>
|
||||
s.app.execute((selector) => {
|
||||
const el = document.querySelector(selector);
|
||||
if (!el) return false;
|
||||
const r = el.getBoundingClientRect();
|
||||
return el.contains(document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2));
|
||||
}, selector);
|
||||
|
||||
test("the library filters by console and AI use, as the catalog does", async () => {
|
||||
await a.until(async () => (await shown(a)).length === 3);
|
||||
await (await a.app.$("button*=Filters")).click();
|
||||
await (await a.app.$("select[aria-label=Console]")).selectByVisibleText("Nintendo 64");
|
||||
await a.until(async () => JSON.stringify(await shown(a)) === '["test-port","test-remake"]');
|
||||
await (await a.app.$("select[aria-label='AI use']")).selectByVisibleText("Hide mostly AI-generated apps");
|
||||
await a.until(async () => JSON.stringify(await shown(a)) === '["test-port"]');
|
||||
// What's on shows as chips, each one removable.
|
||||
assert.ok(await a.app.$("button[aria-label='Remove filter Nintendo 64']").isExisting());
|
||||
assert.equal(await (await a.app.$(".library-tools .tool-count")).getText(), "2");
|
||||
});
|
||||
|
||||
test("the filters are kept as a playlist", async () => {
|
||||
await (await a.app.$("button=Save as playlist")).click();
|
||||
const dialog = await a.app.$("[role=dialog][aria-label='New playlist']");
|
||||
await (await dialog.$("input[aria-label='Playlist name']")).setValue("N64 without AI");
|
||||
await (await dialog.$("button=Save")).click();
|
||||
await a.until(async () => (await a.openTab()) === "N64 without AI");
|
||||
// The filters went into the playlist, and the playlist shows what they matched.
|
||||
assert.ok(!(await a.app.$("button=Save as playlist").isExisting()));
|
||||
assert.deepEqual(await shown(a), ["test-port"]);
|
||||
const saved = collections().find((c) => c.name === "N64 without AI");
|
||||
assert.deepEqual([saved.consoles, saved.ai], [["n64"], "no-generated"]);
|
||||
});
|
||||
|
||||
test("an app is added to a playlist by hand, from its card", async () => {
|
||||
await a.showTab("All");
|
||||
await (await (await a.card("tampered-port")).$("button[aria-label='Add to playlist']")).click();
|
||||
assert.ok(await onTop(a, "[aria-label='Playlists for this app']"), "the card's playlist picker isn't clipped");
|
||||
await (await inMenu(a, "[aria-label='Playlists for this app']", "N64 without AI")).click();
|
||||
await a.showTab("N64 without AI");
|
||||
await a.until(async () => JSON.stringify(await shown(a)) === '["tampered-port","test-port"]');
|
||||
assert.deepEqual(collections().find((c) => c.name === "N64 without AI").apps, ["entry_tampered-port"]);
|
||||
});
|
||||
|
||||
test("a playlist is shared, and another player adds it to their library", async () => {
|
||||
// Sharing needs an account.
|
||||
await (await a.app.$("button=Sign in")).click();
|
||||
await (await a.app.$("button=Create an account")).click();
|
||||
await (await a.app.$("input[placeholder=Username]")).setValue("sharer");
|
||||
await (await a.app.$("input[placeholder=Password]")).setValue("correct horse battery");
|
||||
await (await a.app.$("form button.primary")).click();
|
||||
await (await a.app.$(".account-button")).waitForDisplayed({ timeout: 10000 });
|
||||
// The playlist's menu: Share.
|
||||
await a.showTab("N64 without AI");
|
||||
await (await a.app.$("button[aria-label='N64 without AI options']")).click();
|
||||
assert.ok(await onTop(a, "[role=menu]"), "the playlist's menu isn't clipped by the tab row");
|
||||
await (await inMenu(a, "[role=menu]", "Share")).click();
|
||||
const share = await a.app.$("[role=dialog][aria-label='Share a playlist']");
|
||||
await (await share.$("button=Share")).click();
|
||||
const field = await share.$("input[aria-label='Shared playlist link']");
|
||||
await field.waitForDisplayed({ timeout: 10000 });
|
||||
link = await field.getValue();
|
||||
assert.match(link, /^https:\/\/quiverlauncher\.com\/lists\/n64-without-ai-[a-z0-9]+$/);
|
||||
const slug = link.split("/").pop();
|
||||
assert.deepEqual(api.lists.get(slug).apps.map((x) => x.entryId).sort(), ["entry_tampered-port", "entry_test-port"]);
|
||||
await (await share.$("button=Done")).click();
|
||||
|
||||
// Another player, with an empty library, adds it from the link.
|
||||
b = await launch({ api });
|
||||
await (await b.app.$("button*=Library")).click();
|
||||
await (await b.app.$("button*=Add a shared playlist")).click();
|
||||
const follow = await b.app.$("[role=dialog][aria-label='Add a shared playlist']");
|
||||
await (await follow.$("input[aria-label='Shared playlist link']")).setValue(link);
|
||||
await (await follow.$("button=Look it up")).click();
|
||||
await (await follow.$("h2=N64 without AI")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.match(await follow.getText(), /A playlist by sharer · 2 apps/);
|
||||
await (await follow.$("button=Add to my library")).click();
|
||||
await b.until(async () => (await b.openTab()) === "N64 without AI");
|
||||
await b.until(async () => JSON.stringify(await shown(b)) === '["tampered-port","test-port"]');
|
||||
// Its apps offer Get; nothing downloads by itself.
|
||||
assert.ok(await (await b.card("test-port")).$("button=Get").isExisting());
|
||||
const appsDir = b.apps;
|
||||
assert.ok(!existsSync(appsDir) || readdirSync(appsDir).filter((d) => !d.startsWith(".")).length === 0, "nothing was installed");
|
||||
assert.match(await (await b.app.$(".playlist-note")).getText(), /A playlist by sharer/);
|
||||
});
|
||||
|
||||
test("a playlist of words collects the apps with them in their name or their game's, with one's icon on its tab", async () => {
|
||||
await a.showTab("All");
|
||||
await (await a.app.$("button[aria-label='Add a playlist']")).click();
|
||||
await (await (await a.app.$("[role=menu]")).$("button=New playlist")).click();
|
||||
const dialog = await a.app.$("[role=dialog][aria-label='New playlist']");
|
||||
await (await dialog.$("input[aria-label='Playlist name']")).setValue("Test Port games");
|
||||
await (await dialog.$("input[aria-label='Names with']")).setValue("test port");
|
||||
// Its icon is one of its apps': the first, or one picked.
|
||||
const icons = await dialog.$("[role=radiogroup][aria-label='Icon on its tab']");
|
||||
await a.until(async () => (await icons.$$("[role=radio]")).length === 2);
|
||||
const remake = await icons.$("[role=radio][aria-label='Test Remake']");
|
||||
await remake.click();
|
||||
assert.equal(await remake.getAttribute("aria-checked"), "true");
|
||||
await (await dialog.$("button=Save")).click();
|
||||
await a.until(async () => (await a.openTab()) === "Test Port games");
|
||||
// Test Remake is a way to play Test Port's game; Tampered Port's names don't say "test".
|
||||
await a.until(async () => JSON.stringify(await shown(a)) === '["test-port","test-remake"]');
|
||||
// On its tab, where the tabs show as a row (folded into the Show menu, a window this size has no room for them).
|
||||
const tabs = await a.app.$("nav[aria-label=Playlists]");
|
||||
if (await tabs.isExisting()) assert.ok(await (await tabs.$("button=Test Port games")).$(".playlist-icon").isExisting());
|
||||
const saved = collections().find((c) => c.name === "Test Port games");
|
||||
// No apps picked by hand: none, or an empty list once the account has synced it.
|
||||
assert.deepEqual([saved.search, saved.icon, saved.apps ?? []], ["test port", "entry_test-remake", []]);
|
||||
});
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* Renaming an app's folder from its menu or its page: its files and Proton
|
||||
* prefix go along, Play starts it from there, and updates keep installing
|
||||
* into it. A name another folder has is refused, with nothing changed.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const apps = join(data, "apps");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
s = await launch({ data });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const installs = () => JSON.parse(readFileSync(join(data, "installs.json"), "utf8"))["entry_test-port"];
|
||||
const dialog = () => s.app.$(`[role="dialog"][aria-label="Rename Test Port's folder"]`);
|
||||
const field = async () => (await dialog()).$("input[aria-label='Folder name']");
|
||||
const page = () => s.app.$(".app-page");
|
||||
/** Clicks a button in the side panel, scrolled clear of the usage data notice at the bottom. */
|
||||
const press = async (button) => {
|
||||
await button.scrollIntoView({ block: "center" });
|
||||
await button.click();
|
||||
};
|
||||
|
||||
test("Rename folder in the card's menu moves its files and Proton prefix, and Play starts it there", async () => {
|
||||
const { app, card, until } = s;
|
||||
const port = await card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await (await port.$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
writeFileSync(join(apps, "test-port", "save.dat"), "saved");
|
||||
mkdirSync(join(data, "proton", "test-port", "pfx"), { recursive: true });
|
||||
|
||||
await (await app.$("button*=Library")).click();
|
||||
const library = await card("test-port");
|
||||
await (await library.$(".card-open")).moveTo();
|
||||
await (await library.$("button[aria-label='Test Port menu']")).click();
|
||||
const menu = await app.$('[role="menu"][aria-label="Test Port menu"]');
|
||||
await (await menu.$("button=Manage")).click();
|
||||
await (await menu.$("button=Rename folder…")).click();
|
||||
await (await dialog()).waitForDisplayed();
|
||||
assert.equal(await (await field()).getValue(), "test-port");
|
||||
// What a folder can't be named is left out.
|
||||
await (await field()).setValue("Test: Port?");
|
||||
await (await (await dialog()).$("button=Rename")).click();
|
||||
await (await app.$("p*=folder is now Test Port")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await dialog()).waitForDisplayed({ reverse: true });
|
||||
|
||||
assert.equal(readFileSync(join(apps, "Test Port", "save.dat"), "utf8"), "saved");
|
||||
assert.ok(!existsSync(join(apps, "test-port")), "the old folder is gone");
|
||||
assert.ok(existsSync(join(data, "proton", "Test Port", "pfx")), "its Proton prefix went along");
|
||||
await until(() => installs().folder === "Test Port");
|
||||
|
||||
await (await (await card("test-port")).$("button*=Play")).click();
|
||||
await until(() => existsSync(join(apps, "Test Port", "launched.txt")));
|
||||
});
|
||||
|
||||
test("an update installs into the renamed folder", async () => {
|
||||
const { app, card, until, api } = s;
|
||||
api.release("1.1.0");
|
||||
// Browse fetches the catalog again as it opens; the update is on the app's library card.
|
||||
await (await app.$("button=Browse")).click();
|
||||
await (await app.$("button*=Library")).click();
|
||||
// Update, under Play (the corner icon for it is an icon card's, hidden on this one).
|
||||
await (await (await card("test-port")).$("button.tile-update")).click();
|
||||
await until(() => existsSync(join(apps, "Test Port", ".quiver-version")) && readFileSync(join(apps, "Test Port", ".quiver-version"), "utf8") === "1.1.0", 30000);
|
||||
api.release("1.0.0");
|
||||
await until(() => installs().version.endsWith("1.1.0"));
|
||||
assert.equal(installs().folder, "Test Port");
|
||||
assert.ok(!existsSync(join(apps, "test-port")), "nothing was installed under the old name");
|
||||
});
|
||||
|
||||
test("on the app's page, a name another folder has is refused, and the folder stays as it was", async () => {
|
||||
const { app, card } = s;
|
||||
mkdirSync(join(apps, "Taken"));
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await press(await (await page()).$("button*=On this computer"));
|
||||
await press(await (await page()).$("button*=Rename folder"));
|
||||
await (await dialog()).waitForDisplayed();
|
||||
assert.equal(await (await field()).getValue(), "Test Port");
|
||||
await (await field()).setValue("Taken");
|
||||
await (await (await dialog()).$("button=Rename")).click();
|
||||
await (await (await dialog()).$("p*=already a folder named Taken")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await (await dialog()).$("button=Cancel")).click();
|
||||
await (await dialog()).waitForDisplayed({ reverse: true });
|
||||
assert.ok(existsSync(join(apps, "Test Port", "save.dat")));
|
||||
assert.equal(installs().folder, "Test Port");
|
||||
await app.keys("Escape");
|
||||
});
|
||||
|
||||
test("a drag from its text field out of the dialog leaves it open; a click outside closes it", async () => {
|
||||
const { app, card } = s;
|
||||
await (await (await card("test-port")).$(".card-open")).click();
|
||||
await press(await (await page()).$("button*=On this computer"));
|
||||
await press(await (await page()).$("button*=Rename folder"));
|
||||
await (await dialog()).waitForDisplayed();
|
||||
// The window's left edge, halfway down: the overlay, outside the dialog.
|
||||
const y = await app.execute(() => Math.round(innerHeight / 2));
|
||||
assert.ok(await app.execute((y) => document.elementFromPoint(4, y)?.classList.contains("overlay"), y));
|
||||
await app.action("pointer").move({ origin: await field() }).down().move({ x: 4, y, duration: 100 }).up().perform();
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
assert.ok(await (await dialog()).isDisplayed(), "selecting the name with a drag doesn't close it");
|
||||
await app.action("pointer").move({ x: 4, y }).down().up().perform();
|
||||
await (await dialog()).waitForDisplayed({ reverse: true });
|
||||
await app.keys("Escape");
|
||||
});
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* The end-to-end tests as `node --test` runs them, but stopping once a few have failed. A failing test waits out its
|
||||
* timeouts (20 seconds and more), so a change that broke many ran on to the CI job's time limit, which GitHub shows as
|
||||
* cancelled, not failed, and the run never got as far as saying what failed. Stopping, it ends red in a minute or two
|
||||
* with the first failures to look at; all of them are a run in WSL away (wsl.sh).
|
||||
*
|
||||
* node run.js [--concurrency=2] [--max-failures=3] [files…] no files: every one but live's and phone's
|
||||
*/
|
||||
import { readdirSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { run } from "node:test";
|
||||
import { spec } from "node:test/reporters";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
const { values, positionals } = parseArgs({
|
||||
allowPositionals: true,
|
||||
options: { concurrency: { type: "string", default: "1" }, "max-failures": { type: "string", default: "0" } },
|
||||
});
|
||||
const files = (positionals.length ? positionals : readdirSync(import.meta.dirname).filter((f) => f.endsWith(".test.js") && !/^(live|phone)\./.test(f))).map(
|
||||
(f) => resolve(import.meta.dirname, f),
|
||||
);
|
||||
const maxFailures = Number(values["max-failures"]);
|
||||
|
||||
const stop = new AbortController();
|
||||
let failed = 0;
|
||||
const tests = run({ files, concurrency: Number(values.concurrency), forceExit: true, signal: stop.signal });
|
||||
tests.on("test:fail", ({ nesting }) => {
|
||||
process.exitCode = 1;
|
||||
// A file's own tests, not their subtests (each fails its test too), nor the tests stopping cancels.
|
||||
if (nesting !== 0 || stop.signal.aborted) return;
|
||||
if (maxFailures && ++failed >= maxFailures) {
|
||||
console.log(`\nStopping: ${failed} tests failed, so the rest aren't run.\n`);
|
||||
// The test files' processes are ended, and each stops the apps it started (session.js).
|
||||
stop.abort();
|
||||
}
|
||||
});
|
||||
tests.compose(new spec()).pipe(process.stdout);
|
||||
+3
-3
@@ -20,8 +20,8 @@ const binary = resolve(import.meta.dirname, `../apps/launcher/src-tauri/target/d
|
||||
const windows = process.platform === "win32";
|
||||
|
||||
/**
|
||||
* Each copy still running, as what stops it. A test file that ends without closing one (stopped by run.js at its
|
||||
* failures or by Ctrl+C, which skips after(), or a test that never closed what it launched) stops it on its way out.
|
||||
* Each copy still running, as what stops it. A test file that ends without closing one (stopped by Ctrl+C, which
|
||||
* skips after(), or a test that never closed what it launched) stops it on its way out.
|
||||
* Left running, the app and its driver held the file's output open, so `node --test` waited on the file for good.
|
||||
*/
|
||||
const running = new Set();
|
||||
@@ -33,7 +33,7 @@ for (const signal of ["SIGINT", "SIGTERM"]) process.once(signal, () => process.e
|
||||
* copies, and `data` to reopen a copy's data folder. Each copy takes ports no
|
||||
* other is using, so any number can run at once. The first start's setup
|
||||
* (setup.tsx) is taken as done, as the tests start from the library, unless
|
||||
* `setup`: setup.test.js goes through it.
|
||||
* `setup`.
|
||||
*/
|
||||
export async function launch({ env: extra = {}, api: shared, data = mkdtempSync(join(tmpdir(), "quiver-data-")), setup = false } = {}) {
|
||||
if (!setup) {
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/**
|
||||
* Settings is a page: its sections in a list beside the one picked, or, in a
|
||||
* narrow window, the list on its own and a section at a time, where Back goes
|
||||
* to the list before it leaves Settings. A controller's B does as Escape does.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
writeFileSync(join(data, "settings.json"), JSON.stringify({ telemetryNoticeSeen: true }));
|
||||
s = await launch({ data });
|
||||
await s.app.setWindowSize(1280, 800);
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const page = () => s.app.$("section.settings-page");
|
||||
const heading = async () => (await (await page()).$("h1")).getText();
|
||||
const pane = async () => (await (await page()).$("[role=region]")).getAttribute("aria-label");
|
||||
const shown = async () => (await page()).isExisting();
|
||||
const focused = () => s.app.execute(() => document.activeElement?.textContent?.trim());
|
||||
const pad = async (key) => {
|
||||
for (const down of [true, false])
|
||||
await s.app.execute((key, down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key, down } }), key, down);
|
||||
};
|
||||
|
||||
test("side by side: General first, a section picked from the list, and Back leaves Settings", async () => {
|
||||
await s.settings();
|
||||
assert.equal(await heading(), "Settings");
|
||||
assert.equal(await pane(), "General");
|
||||
await (await s.app.$("label*=Full screen")).waitForDisplayed();
|
||||
await (await (await s.app.$('nav[aria-label="Settings sections"]')).$("button*=Updates")).click();
|
||||
assert.equal(await pane(), "Updates");
|
||||
await (await s.app.$("button=Check for updates")).waitForDisplayed();
|
||||
await s.app.keys("Escape");
|
||||
await s.until(async () => !(await shown()));
|
||||
});
|
||||
|
||||
test("narrow: the list, then one section, and Back goes to the list first", async () => {
|
||||
// 125% in the smallest window: too narrow for the list beside a section, with the top bar's gear still in the window.
|
||||
await s.settings("General");
|
||||
// By its label: TV mode's dropdown comes before it.
|
||||
await (await s.app.$("//section[contains(@class, 'settings-page')]//label[contains(., 'Interface size')]/select")).selectByVisibleText("125%");
|
||||
await s.closeSettings();
|
||||
await s.app.setWindowSize(720, 800);
|
||||
await s.settings();
|
||||
assert.equal(await (await (await page()).$("[role=region]")).isExisting(), false);
|
||||
await (await (await s.app.$('nav[aria-label="Settings sections"]')).$("button*=Controllers")).click();
|
||||
assert.equal(await heading(), "Controllers");
|
||||
assert.equal(await (await s.app.$('nav[aria-label="Settings sections"]')).isExisting(), false);
|
||||
assert.equal(await focused(), "Settings");
|
||||
await (await s.app.$("button[aria-label='Back to top: keyboard']")).waitForDisplayed();
|
||||
|
||||
await s.app.keys("Escape");
|
||||
await s.until(async () => (await heading()) === "Settings");
|
||||
assert.equal(await focused(), "Controllers");
|
||||
// A controller's B the same way: into Updates, then back to the list, then out.
|
||||
await (await (await s.app.$('nav[aria-label="Settings sections"]')).$("button*=Updates")).click();
|
||||
await pad("East");
|
||||
await s.until(async () => (await heading()) === "Settings");
|
||||
await pad("East");
|
||||
await s.until(async () => !(await shown()));
|
||||
});
|
||||
@@ -1,200 +0,0 @@
|
||||
/**
|
||||
* The first start's setup (setup.tsx): a step at a time, a Quiver Launcher 3
|
||||
* library imported on the way, and only once.
|
||||
*/
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
/** A portable 3.x folder with Test Port in its Apps folder, or wherever `apps` says. */
|
||||
function oldLibrary(dir, { apps = join(dir, "Apps"), settings = {} } = {}) {
|
||||
const installed = join(apps, "TestPort");
|
||||
mkdirSync(installed, { recursive: true });
|
||||
mkdirSync(dir, { recursive: true });
|
||||
writeFileSync(join(installed, "port.sh"), '#!/bin/sh\ncd "$(dirname "$0")" && echo played > launched.txt\n', { mode: 0o755 });
|
||||
writeFileSync(join(dir, "settings.json"), JSON.stringify(settings));
|
||||
writeFileSync(join(dir, "apps.json"), JSON.stringify({ Apps: [{ Name: "Test Port", Repository: "quiver/test-port", FolderName: "TestPort" }] }));
|
||||
return installed;
|
||||
}
|
||||
|
||||
const setup = (s) => s.app.$('[role=dialog][aria-label="Set up Quiver Launcher"]');
|
||||
const heading = async (s) => (await (await setup(s)).$("h2")).getText();
|
||||
const press = async (s, name) => (await (await setup(s)).$(`button=${name}`)).click();
|
||||
/** On to the step called `name`. */
|
||||
const onTo = async (s, name) => s.until(async () => (await heading(s)) === name);
|
||||
/** The Quiver Launcher 3 step's heading once it's found a library. */
|
||||
const BRING_OVER = "Bring your apps over from Quiver Launcher 3?";
|
||||
/** Opens the list of a library's apps, there once the library's been found. */
|
||||
const seeApps = (s) => press(s, "See which apps");
|
||||
|
||||
test("the first start asks a step at a time, importing a 3.x library on the way, and never again", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const folder = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
const installed = oldLibrary(folder);
|
||||
let s = await launch({ setup: true, env: { HOME: home } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
assert.equal(await heading(s), "Welcome to Quiver Launcher!");
|
||||
// Escape, a controller's B, never leaves it from the first step.
|
||||
await s.app.keys("Escape");
|
||||
assert.equal(await heading(s), "Welcome to Quiver Launcher!");
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
const dialog = await setup(s);
|
||||
await seeApps(s);
|
||||
assert.equal(await (await dialog.$(".old-library-folder")).getText(), `Found in ${folder}`);
|
||||
assert.match(await (await dialog.$(".old-library-apps")).getText(), new RegExp(`Test Port\\s+Installed in ${join(folder, "Apps", "TestPort")}`));
|
||||
// Escape goes back a step.
|
||||
await s.app.keys("Escape");
|
||||
await onTo(s, "Welcome to Quiver Launcher!");
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
await press(s, "Add 1 app");
|
||||
// All of it came, so it goes on by itself, and the next step says so.
|
||||
await s.until(async () => (await heading(s)) === "Where apps install", 20000);
|
||||
assert.ok(await (await (await setup(s)).$("p*=All done: your Quiver Launcher 3 apps are in your library")).isDisplayed());
|
||||
await press(s, "Next");
|
||||
await onTo(s, "Usage data");
|
||||
await press(s, "Next");
|
||||
await onTo(s, "Sign in to sync your library");
|
||||
await press(s, "Start using Quiver");
|
||||
await (await setup(s)).waitForDisplayed({ reverse: true });
|
||||
// A new player starts in Browse; with their apps imported, it's their library that shows.
|
||||
await s.until(() => s.app.execute(() => /Library/.test(document.querySelector("button[aria-current=page]")?.textContent ?? "")));
|
||||
// Each step it went through was answered: no banner asks again.
|
||||
assert.ok(!(await (await s.app.$("[aria-label='Usage data']")).isExisting()));
|
||||
assert.ok(!(await (await s.app.$(".old-library-notice")).isExisting()));
|
||||
const play = async () => (await s.card("test-port")).$("button*=Play");
|
||||
await s.until(() => play().then((b) => b.isDisplayed()).catch(() => false));
|
||||
await (await play()).click();
|
||||
await s.until(() => existsSync(join(installed, "launched.txt")));
|
||||
assert.ok(!existsSync(join(s.apps, "TestPort")), "nothing was downloaded again");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
s = await launch({ setup: true, data: s.data, env: { HOME: home } });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.ok(!(await (await setup(s)).isExisting()), "the setup is only for the first start");
|
||||
// Settings runs it again. The library has its apps now, so the Quiver Launcher 3 step asks rather than offering one.
|
||||
await s.settings("General");
|
||||
await (await (await s.app.$("section.settings-page")).$("button=Run setup again")).click();
|
||||
await onTo(s, "Welcome to Quiver Launcher!");
|
||||
await press(s, "Next");
|
||||
await onTo(s, "Coming from Quiver Launcher 3?");
|
||||
await (await (await setup(s)).$("p*=Show Quiver where your Quiver Launcher 3 folder is")).waitForDisplayed();
|
||||
await press(s, "Skip setup");
|
||||
await (await setup(s)).waitForDisplayed({ reverse: true });
|
||||
assert.ok(await (await s.app.$("section.settings-page")).isDisplayed(), "back in Settings");
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("Skip setup leaves what it didn't ask to the banners", async () => {
|
||||
const s = await launch({ setup: true, env: { HOME: mkdtempSync(join(tmpdir(), "quiver-home-")) } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
await press(s, "Skip setup");
|
||||
await (await setup(s)).waitForDisplayed({ reverse: true });
|
||||
await (await s.app.$("[aria-label='Usage data']")).waitForDisplayed();
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("a 3.x library with only some of its installs found can be pointed at the folder of the rest", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const folder = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
oldLibrary(folder);
|
||||
writeFileSync(
|
||||
join(folder, "apps.json"),
|
||||
JSON.stringify({ Apps: [{ Name: "Test Port", Repository: "quiver/test-port", FolderName: "TestPort" }, { Name: "Homebrew Thing", Repository: "someone/not-in-catalog", FolderName: "Homebrew" }] }),
|
||||
);
|
||||
const games = join(home, "Games");
|
||||
mkdirSync(join(games, "Homebrew"), { recursive: true });
|
||||
writeFileSync(join(games, "Homebrew", "port.sh"), "#!/bin/sh\n", { mode: 0o755 });
|
||||
const s = await launch({ setup: true, env: { HOME: home, QUIVER_PICK_FOLDER: games } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
const dialog = await setup(s);
|
||||
// One found and one not is an everyday library: nothing says the other moved.
|
||||
await (await dialog.$("p*=2 apps, 1 already installed.")).waitForDisplayed({ timeout: 20000 });
|
||||
await seeApps(s);
|
||||
await press(s, "Look in another folder…");
|
||||
await s.until(async () => (await (await dialog.$(".old-library-apps")).getText()).includes(`Installed in ${join(games, "Homebrew")}`));
|
||||
// What was found already stays found.
|
||||
assert.match(await (await dialog.$(".old-library-apps")).getText(), new RegExp(`Installed in ${join(folder, "Apps", "TestPort")}`));
|
||||
await (await dialog.$("p*=2 apps, all already installed")).waitForDisplayed();
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("Not now in the setup is its answer: no banner asks again", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
oldLibrary(join(home, "Downloads", "QuiverLauncher-linux"));
|
||||
const s = await launch({ setup: true, env: { HOME: home } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
await press(s, "Not now");
|
||||
await onTo(s, "Where apps install");
|
||||
await press(s, "Skip setup");
|
||||
await (await setup(s)).waitForDisplayed({ reverse: true });
|
||||
await new Promise((r) => setTimeout(r, 1000));
|
||||
assert.ok(!(await (await s.app.$(".old-library-notice")).isExisting()));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("the setup's folder choice brings over another 3.x instead, when it isn't more of this one's installs", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const downloads = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
oldLibrary(downloads);
|
||||
const other = join(mkdtempSync(join(tmpdir(), "quiver-elsewhere-")), "Old Launcher");
|
||||
const installed = oldLibrary(other);
|
||||
const s = await launch({ setup: true, env: { HOME: home, QUIVER_PICK_FOLDER: other } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
await seeApps(s);
|
||||
const dialog = await setup(s);
|
||||
assert.equal(await (await dialog.$(".old-library-folder")).getText(), `Found in ${downloads}`);
|
||||
await press(s, "Look in another folder…");
|
||||
await s.until(async () => (await (await dialog.$(".old-library-folder")).getText()) === `Found in ${other}`);
|
||||
assert.match(await (await dialog.$(".old-library-apps")).getText(), new RegExp(`Installed in ${installed}`));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("a 3.x library whose installs moved is matched to its Apps folder where it is now", async () => {
|
||||
const home = mkdtempSync(join(tmpdir(), "quiver-home-"));
|
||||
const folder = join(home, "Downloads", "QuiverLauncher-linux");
|
||||
// 3.x's settings name an Apps folder that's gone; its installs are somewhere else now.
|
||||
const moved = join(home, "Games");
|
||||
oldLibrary(folder, { apps: moved, settings: { AppsPath: "/media/old-card/Apps" } });
|
||||
const s = await launch({ setup: true, env: { HOME: home, QUIVER_PICK_FOLDER: moved } });
|
||||
try {
|
||||
await (await setup(s)).waitForDisplayed({ timeout: 20000 });
|
||||
await press(s, "Next");
|
||||
await onTo(s, BRING_OVER);
|
||||
const dialog = await setup(s);
|
||||
await (await dialog.$("p*=1 app, not installed yet")).waitForDisplayed({ timeout: 20000 });
|
||||
await seeApps(s);
|
||||
assert.match(await (await dialog.$(".old-library-apps")).getText(), /Not installed/);
|
||||
await press(s, "Choose a folder…");
|
||||
await s.until(async () => (await (await dialog.$(".old-library-apps")).getText()).includes(`Installed in ${join(moved, "TestPort")}`));
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* Library backups: a damaged or missing library opens on the backups Quiver
|
||||
* kept rather than starting over it, and Settings can restore one.
|
||||
*/
|
||||
import { after, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const library = join(data, "library.json");
|
||||
let s;
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const problem = () => s.app.$('[role="alert"][aria-label="Library problem"]');
|
||||
const restart = async () => {
|
||||
await s.close();
|
||||
s = await launch({ data });
|
||||
};
|
||||
/** Whether Test Port is in the Library tab. */
|
||||
const inLibrary = async () => {
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.app.$("main")).waitForDisplayed();
|
||||
return (await s.card("test-port")).isExisting();
|
||||
};
|
||||
// Looked up afresh until it shows: the library redraws as it comes back.
|
||||
const playable = () => s.until(async () => (await (await s.card("test-port")).$("button*=Play")).isDisplayed().catch(() => false));
|
||||
|
||||
test("a damaged library opens on its snapshots, and one puts it back", async () => {
|
||||
s = await launch({ data });
|
||||
const port = await s.card("test-port");
|
||||
await port.waitForDisplayed({ timeout: 20000 });
|
||||
await (await port.$("button=Get")).click();
|
||||
await playable();
|
||||
// A snapshot is taken as soon as an app is installed.
|
||||
const backups = join(data, "backups");
|
||||
await s.until(() => existsSync(backups) && readdirSync(backups).some((b) => existsSync(join(backups, b, "installs.json")) && readFileSync(join(backups, b, "installs.json"), "utf8").includes("test-port")));
|
||||
|
||||
await s.close();
|
||||
writeFileSync(library, '[{"id": "entry_test-port", "slu');
|
||||
s = await launch({ data });
|
||||
await (await problem()).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await (await problem()).getText(), /The file with your library is damaged/);
|
||||
const newest = await (await problem()).$("ul[aria-label=Backups] li");
|
||||
assert.match(await newest.getText(), /1 app/);
|
||||
await (await newest.$("button=Restore")).click();
|
||||
await playable();
|
||||
assert.equal(JSON.parse(readFileSync(library, "utf8")).length, 1);
|
||||
assert.ok(readdirSync(data).some((f) => f.startsWith("library.damaged-")), "the damaged file is kept aside");
|
||||
});
|
||||
|
||||
test("a missing library can be left behind, and then the launcher starts as usual", async () => {
|
||||
await s.close();
|
||||
rmSync(library);
|
||||
s = await launch({ data });
|
||||
await (await problem()).waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await (await problem()).getText(), /The file with your library is missing/);
|
||||
await (await (await problem()).$("button=Continue without restoring")).click();
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.deepEqual(JSON.parse(readFileSync(library, "utf8")), []);
|
||||
await restart();
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.ok(!(await (await problem()).isExisting()));
|
||||
// Installed, so still in the library.
|
||||
assert.ok(await inLibrary());
|
||||
});
|
||||
|
||||
test("Settings restores a backup", async () => {
|
||||
assert.deepEqual(JSON.parse(readFileSync(library, "utf8")), []);
|
||||
const settings = await s.settings("Library");
|
||||
await (await settings.$("button=Choose a backup…")).click();
|
||||
const withPort = await settings.$("li*=1 app");
|
||||
await withPort.waitForDisplayed();
|
||||
await (await withPort.$("button=Restore")).click();
|
||||
const confirm = await s.app.$('[role="group"][aria-label="Restore backup"]');
|
||||
assert.match(await confirm.getText(), /Replace your library with the one from .* \(1 app\)/);
|
||||
await (await confirm.$("button=Restore")).click();
|
||||
await s.until(() => JSON.parse(readFileSync(library, "utf8")).length === 1);
|
||||
await playable();
|
||||
// Restoring kept the library as it was too.
|
||||
assert.ok(readdirSync(join(data, "backups")).length >= 3);
|
||||
});
|
||||
@@ -1,92 +0,0 @@
|
||||
/**
|
||||
* Steam's on-screen keyboard: under Steam or Gamescope, a text field brings it
|
||||
* up only while it's being edited (Confirm on a highlighted field, as in
|
||||
* Quiver Launcher 3), and leaving the field hides it again.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const bin = mkdtempSync(join(tmpdir(), "quiver-bin-"));
|
||||
const log = join(mkdtempSync(join(tmpdir(), "quiver-opened-")), "log");
|
||||
let s;
|
||||
|
||||
before(async () => {
|
||||
// Stands in for xdg-open, which hands steam:// links to Steam.
|
||||
writeFileSync(join(bin, "xdg-open"), `#!/bin/sh\necho "$1" >> "${log}"\n`, { mode: 0o755 });
|
||||
s = await launch({ env: { SteamDeck: "1", PATH: `${bin}:${process.env.PATH}` } });
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const asked = () => (existsSync(log) ? readFileSync(log, "utf8").trim().split("\n") : []);
|
||||
/** A controller button, pressed and let go, as the Rust side reports it. */
|
||||
const pad = async (key) => {
|
||||
for (const down of [true, false])
|
||||
await s.app.execute((key, down) => window.__TAURI_INTERNALS__.invoke("plugin:event|emit", { event: "pad", payload: { key, down } }), key, down);
|
||||
};
|
||||
const focused = () => s.app.execute(() => document.activeElement?.getAttribute("placeholder") ?? document.activeElement?.closest("article")?.dataset.slug);
|
||||
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
test("Confirm on a text field brings up Steam's keyboard, and leaving the field hides it", async () => {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
// Highlighted (focused) but not being edited: no keyboard yet.
|
||||
await s.app.execute(() => document.querySelector("input[placeholder^=Search]").focus());
|
||||
assert.match(await focused(), /^Search/);
|
||||
await pause(1000);
|
||||
assert.deepEqual(asked(), []);
|
||||
|
||||
await pad("South");
|
||||
await s.until(() => asked().includes("steam://open/keyboard"));
|
||||
assert.match(await focused(), /^Search/, "the field keeps focus while it's edited");
|
||||
|
||||
// Down, out of the field (into the first shelf, its See all).
|
||||
await pad("DPadDown");
|
||||
await s.until(() => s.app.execute(() => !document.activeElement?.matches("input[placeholder^=Search]")));
|
||||
await s.until(() => asked().includes("steam://close/keyboard"));
|
||||
assert.deepEqual(asked(), ["steam://open/keyboard", "steam://close/keyboard"]);
|
||||
});
|
||||
|
||||
test("a mouse click in a text field doesn't ask for the keyboard", async () => {
|
||||
await (await s.app.$("input[placeholder^=Search]")).click();
|
||||
await (await s.app.$("input[placeholder^=Search]")).setValue("test");
|
||||
await pause(1000);
|
||||
assert.equal(asked().length, 2);
|
||||
});
|
||||
|
||||
test("Steam's keyboard taking the window's focus doesn't hide it, and A asks for it again once it's closed", async () => {
|
||||
const before = asked().length;
|
||||
const field = "input[placeholder^=Search]";
|
||||
await s.app.execute((q) => document.querySelector(q).focus(), field);
|
||||
await pad("South");
|
||||
await s.until(() => asked().length === before + 1);
|
||||
// As the window losing focus to Steam's keyboard in Game Mode does: a blur, the field still the page's focus.
|
||||
await s.app.execute((q) => document.querySelector(q).dispatchEvent(new FocusEvent("blur")), field);
|
||||
await pause(1000);
|
||||
assert.deepEqual(asked().slice(before), ["steam://open/keyboard"]);
|
||||
// Closed in Steam, the field still focused: A brings it back.
|
||||
await pad("South");
|
||||
await s.until(() => asked().length === before + 2);
|
||||
assert.deepEqual(asked().slice(before), ["steam://open/keyboard", "steam://open/keyboard"]);
|
||||
});
|
||||
|
||||
test("while Steam's keyboard is up, a dialog keeps above it, and the room goes once its field is left", async () => {
|
||||
const room = () => s.app.execute(() => document.documentElement.style.getPropertyValue("--steam-keyboard"));
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.app.$("button*=Add a shared playlist")).click();
|
||||
const field = "input[aria-label='Shared playlist link']";
|
||||
await (await s.app.$(field)).waitForDisplayed();
|
||||
await s.app.execute((q) => document.querySelector(q).focus(), field);
|
||||
await pad("South");
|
||||
await s.until(async () => (await room()) !== "");
|
||||
// The dialog ends above the part of the window the keyboard covers.
|
||||
await s.until(() =>
|
||||
s.app.execute(() => document.querySelector("[role=dialog]").getBoundingClientRect().bottom <= document.documentElement.clientHeight * 0.55 + 1),
|
||||
);
|
||||
await pad("East");
|
||||
await s.until(async () => !(await s.app.$("[role=dialog]").isExisting()));
|
||||
await s.until(async () => (await room()) === "");
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* An app the player added from its repository, before the catalog listed it,
|
||||
* switches to the catalog's app for it: its files, folder and play time stay,
|
||||
* and its updates come from the releases Quiver checks.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s, app, until;
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
// Added from github.com/quiver/test-port into a folder named after the repository, and played for an hour.
|
||||
const folder = join(data, "apps", "Test-Port");
|
||||
|
||||
before(async () => {
|
||||
mkdirSync(folder, { recursive: true });
|
||||
writeFileSync(join(folder, ".quiver-version"), "v1.0.0");
|
||||
writeFileSync(join(folder, "save.dat"), "the player's save");
|
||||
const custom = { provider: "github", repository: "quiver/Test-Port", name: "My Test Port" };
|
||||
writeFileSync(join(data, "library.json"), JSON.stringify([{ id: "github:quiver/test-port", slug: "", addedAt: 1, custom, overrides: { tags: ["favourites"] } }]));
|
||||
writeFileSync(join(data, "installs.json"), JSON.stringify({ "github:quiver/test-port": { version: "v1.0.0", releasedAt: 1, releaseId: "v1.0.0", folder: "Test-Port", executables: [], playTime: 3600, updates: "auto" } }));
|
||||
writeFileSync(join(data, "catalog.json"), JSON.stringify({}));
|
||||
s = await launch({ data });
|
||||
({ app, until } = s);
|
||||
});
|
||||
|
||||
after(() => s?.close());
|
||||
|
||||
const library = () => JSON.parse(readFileSync(join(data, "library.json"), "utf8"));
|
||||
const installs = () => JSON.parse(readFileSync(join(data, "installs.json"), "utf8"));
|
||||
|
||||
test("the app's page offers the catalog's app, and switching keeps its files and play time", async () => {
|
||||
await (await app.$("button*=Library")).click();
|
||||
const card = await app.$(".card-open");
|
||||
await card.waitForDisplayed({ timeout: 20000 });
|
||||
await card.click();
|
||||
const line = await app.$("p*=catalog lists this app now");
|
||||
await line.waitForDisplayed({ timeout: 20000 });
|
||||
await (await line.$("button=Switch to the catalog's")).click();
|
||||
// The page is the catalog's app now.
|
||||
await until(async () => (await (await app.$(".app-page h1")).getText()) === "Test Port");
|
||||
assert.ok(!(await (await app.$("p*=catalog lists this app now")).isExisting()));
|
||||
await until(() => library().some((i) => i.id === "entry_test-port"));
|
||||
const items = library();
|
||||
assert.ok(!items.some((i) => i.id === "github:quiver/test-port"));
|
||||
assert.deepEqual(items.find((i) => i.id === "entry_test-port").overrides, { tags: ["favourites"] });
|
||||
await until(() => Boolean(installs()["entry_test-port"]));
|
||||
const install = installs()["entry_test-port"];
|
||||
assert.equal(install.folder, "Test-Port");
|
||||
assert.equal(install.playTime, 3600);
|
||||
assert.equal(install.updates, "auto");
|
||||
assert.equal(installs()["github:quiver/test-port"], undefined);
|
||||
assert.equal(readFileSync(join(folder, "save.dat"), "utf8"), "the player's save");
|
||||
});
|
||||
@@ -1,200 +0,0 @@
|
||||
/** Optional sign-in: two computers, one account, one library. */
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let api, a, b;
|
||||
const titles = async (s) => {
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
return s.app.execute(() => [...document.querySelectorAll("article")].filter((e) => !e.closest(".loose")).map((e) => e.dataset.slug).sort());
|
||||
};
|
||||
const signIn = async (s, create) => {
|
||||
await (await s.app.$("button=Sign in")).click();
|
||||
if (create) await (await s.app.$("button=Create an account")).click();
|
||||
await (await s.app.$("input[placeholder=Username]")).setValue("player");
|
||||
await (await s.app.$("input[placeholder=Password]")).setValue("correct horse battery");
|
||||
await (await s.app.$(`form button.primary`)).click();
|
||||
await (await s.app.$(".account-button")).waitForDisplayed({ timeout: 10000 });
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
api = await startMockApi();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await a?.close();
|
||||
await b?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
test("a library built signed out is still there after a restart", async () => {
|
||||
a = await launch({ api });
|
||||
await (await (await a.card("test-port")).$("button=Get")).click();
|
||||
await (await (await a.card("test-port")).$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
const data = a.data;
|
||||
await a.close();
|
||||
a = await launch({ api, data });
|
||||
assert.deepEqual(await titles(a), ["test-port"]);
|
||||
});
|
||||
|
||||
test("signing in on two computers combines their libraries on both", async () => {
|
||||
b = await launch({ api });
|
||||
await (await (await b.card("tampered-port")).$("button=Get")).click();
|
||||
await (await (await b.card("tampered-port")).$('[role="alert"]')).waitForDisplayed({ timeout: 30000 });
|
||||
await signIn(a, true);
|
||||
await signIn(b, false);
|
||||
await a.until(async () => (await titles(a)).length === 2);
|
||||
await b.until(async () => (await titles(b)).length === 2);
|
||||
assert.deepEqual(await titles(b), ["tampered-port", "test-port"]);
|
||||
});
|
||||
|
||||
test("renaming an app on one computer renames it on the other", async () => {
|
||||
await (await (await a.card("test-port")).$(".card-open")).click();
|
||||
// On its page's On this computer tab, as its consoles and the way to remove it are.
|
||||
await (await (await a.app.$(".app-page")).$("button*=On this computer")).click();
|
||||
await (await a.app.$("button=Change name or artwork")).click();
|
||||
await (await a.app.$("input[aria-label=Name]")).setValue("My Port");
|
||||
await (await a.app.$("button=Save")).click();
|
||||
await (await a.app.$("h1=My Port")).waitForDisplayed();
|
||||
await a.app.keys("Escape");
|
||||
await titles(b);
|
||||
await b.until(async () => (await (await (await b.card("test-port")).$(".card-open")).getAttribute("aria-label")) === "My Port");
|
||||
});
|
||||
|
||||
test("the consoles picked for an app on one computer show on the other", async () => {
|
||||
await (await (await a.card("test-port")).$(".card-open")).click();
|
||||
await (await (await a.app.$(".app-page")).$("button*=On this computer")).click();
|
||||
await (await a.app.$(".app-page select[aria-label='Add a console']")).selectByVisibleText("Super Nintendo Entertainment System");
|
||||
await (await a.app.$(".app-page button[aria-label='Remove console Super Nintendo Entertainment System']")).waitForDisplayed();
|
||||
await a.app.keys("Escape");
|
||||
await titles(b);
|
||||
await (await (await b.card("test-port")).$(".card-open")).click();
|
||||
await (await (await b.app.$(".app-page")).$("button*=On this computer")).click();
|
||||
const consoles = await b.app.$(".app-page section[aria-label=Consoles]");
|
||||
await (await consoles.$("button[aria-label='Remove console Super Nintendo Entertainment System']")).waitForDisplayed({ timeout: 10000 });
|
||||
await b.app.keys("Escape");
|
||||
});
|
||||
|
||||
test("a collection made on one computer shows on the other", async () => {
|
||||
await (await a.app.$("button[aria-label='Add a playlist']")).click();
|
||||
await (await (await a.app.$("[role=menu]")).$("button=New playlist")).click();
|
||||
await (await a.app.$("input[aria-label='Playlist name']")).setValue("Co-op");
|
||||
await (await a.app.$("button=Save")).click();
|
||||
await titles(b);
|
||||
await b.until(async () => (await b.tabs()).includes("Co-op"), 10000);
|
||||
await a.showTab("All");
|
||||
});
|
||||
|
||||
test("removing an app on one computer removes it on the other, keeping installed files", async () => {
|
||||
// B installs test-port; A then removes both apps.
|
||||
await (await (await b.card("test-port")).$("button=Get")).click();
|
||||
await (await (await b.card("test-port")).$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
for (const slug of ["tampered-port", "test-port"]) {
|
||||
await (await (await a.card(slug)).$(".card-open")).click();
|
||||
await (await (await a.app.$(".app-page")).$("button*=On this computer")).click();
|
||||
await (await a.app.$(`button=${slug === "test-port" ? "Uninstall and remove" : "Remove from library"}`)).click();
|
||||
// Only deleting files asks first.
|
||||
if (slug === "test-port") await (await (await a.app.$("[role=dialog]")).$("button=Uninstall and remove")).click();
|
||||
}
|
||||
await b.until(async () => (await titles(b)).length === 0);
|
||||
await (await b.app.$("h2=Installed, not in your library")).waitForDisplayed();
|
||||
assert.ok(existsSync(join(b.apps, "test-port")), "sync never deletes files");
|
||||
await (await (await b.card("test-port")).$("button=Add")).click();
|
||||
await a.until(async () => (await titles(a)).includes("test-port"));
|
||||
});
|
||||
|
||||
test("a signed-in player reviews the release they installed", async () => {
|
||||
await (await (await b.card("test-port")).$(".card-open")).click();
|
||||
await (await b.app.$("button*=Player feedback")).click();
|
||||
await (await b.app.$("button*=Share how it ran")).click();
|
||||
// The release they have is the one they say they tested.
|
||||
await (await b.app.$("h3=How did it go?")).waitForDisplayed({ timeout: 10000 });
|
||||
await (await b.app.$("textarea")).setValue("Smooth at 60 fps");
|
||||
await (await b.app.$("button=Share")).click();
|
||||
await (await b.app.$("p*=You've shared how it ran")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.deepEqual(api.reviews.at(-1), {
|
||||
entryId: "entry_test-port",
|
||||
result: "runs",
|
||||
body: "Smooth at 60 fps",
|
||||
platform: process.platform === "win32" ? "windows" : "linux",
|
||||
entryReleaseId: "release_test-port_1.0.0",
|
||||
user: "player",
|
||||
});
|
||||
await b.app.keys("Escape");
|
||||
});
|
||||
|
||||
test("Browse opens with the filters saved on the website, keeping this computer's platform", async () => {
|
||||
const browse = async () => {
|
||||
await (await a.app.$("button*=Library")).click();
|
||||
await (await a.app.$("button*=Browse")).click();
|
||||
};
|
||||
// On Linux, which runs Windows' apps too, that's every platform: the catalog is asked for none (catalogOs).
|
||||
const os = process.platform === "win32" ? "windows" : undefined;
|
||||
api.setCatalogDefaults("player", { projectTypes: ["port"], console: "n64", sort: "rating", platforms: ["android"] });
|
||||
// The catalog's query with them, not the Nintendo 64 shelf's (by rating too) from the front page before they came.
|
||||
await a.until(async () => (await browse(), api.lastQuery().get("console") === "n64" && api.lastQuery().has("projectType")));
|
||||
assert.deepEqual(Object.fromEntries(api.lastQuery()), { ...(os && { os }), projectType: "port", console: "n64", sort: "rating" });
|
||||
assert.equal(await (await a.app.$(".browse-tools .tool-count")).getText(), "2");
|
||||
// Several kinds of project at once, which only the website can save.
|
||||
api.setCatalogDefaults("player", { projectTypes: ["port", "game"] });
|
||||
await a.until(() => api.lastQuery().get("projectTypes") === "port,game");
|
||||
// Removing one here wins over the saved filters until Browse opens again.
|
||||
await (await a.app.$("button[aria-label='Remove filter Port, Standalone game']")).click();
|
||||
await a.until(() => !api.lastQuery().has("projectTypes"));
|
||||
api.setCatalogDefaults("player", undefined);
|
||||
// Opened again as it waits, as above: the filters' going can reach the app after Browse opens, and a shelf's query come last.
|
||||
await a.until(async () => (await browse(), [...api.lastQuery().keys()].join() === (os ? "os,sort" : "sort")));
|
||||
});
|
||||
|
||||
test("signing out keeps the apps installed here in the library, and signing back in carries on", async () => {
|
||||
await (await b.app.$(".account-button")).click();
|
||||
await (await b.app.$("button=Sign out")).click();
|
||||
await (await b.app.$("p*=Apps installed on this computer stay in your library")).waitForDisplayed();
|
||||
assert.deepEqual(await titles(b), ["test-port"]);
|
||||
assert.equal(await (await b.app.$("h2=Installed, not in your library")).isExisting(), false);
|
||||
assert.ok(existsSync(join(b.apps, "test-port")), "installed files stay");
|
||||
await (await (await b.card("test-port")).$(".card-open")).click();
|
||||
await (await b.app.$("button*=Player feedback")).click();
|
||||
await (await b.app.$("p=Sign in to share how it runs for you.")).waitForDisplayed();
|
||||
await b.app.keys("Escape");
|
||||
await signIn(b, false);
|
||||
await b.until(async () => (await titles(b)).includes("test-port"));
|
||||
await (await (await b.card("test-port")).$("button*=Play")).waitForDisplayed();
|
||||
await (await b.app.$(".account-button")).click();
|
||||
await (await b.app.$("button=Sign out")).click();
|
||||
});
|
||||
|
||||
test("signing in with GitHub happens in the browser and comes back to the app", async () => {
|
||||
await (await b.app.$("button=Sign in")).click();
|
||||
await (await b.app.$("button=Continue with GitHub")).click();
|
||||
try {
|
||||
await (await b.app.$("span=octocat")).waitForDisplayed({ timeout: 10000 });
|
||||
} catch (e) {
|
||||
console.log("BODY", await b.app.execute(() => document.body.innerText.slice(0, 1500)));
|
||||
throw e;
|
||||
}
|
||||
// The browser tab ends on the website's page, not the launcher's loopback address.
|
||||
await b.until(async () => api.signedInPages.length > 0);
|
||||
assert.deepEqual(api.signedInPages, [""]);
|
||||
});
|
||||
|
||||
test("a sign-in whose page never came back gives way to the next, with the same or the other service", async () => {
|
||||
const lost = join(mkdtempSync(join(tmpdir(), "quiver-browser-")), "lost");
|
||||
const c = await launch({ api, env: { FAKE_BROWSER_LOSE: lost } });
|
||||
try {
|
||||
await (await c.app.$("button=Sign in")).click();
|
||||
await (await c.app.$("button=Continue with GitHub")).click();
|
||||
await c.until(async () => existsSync(lost));
|
||||
await (await c.app.$("p=Finish signing in in your browser.")).waitForDisplayed();
|
||||
// Still waiting for that one, which held the launcher's address: the other starts over rather than being refused.
|
||||
await (await c.app.$("button=Continue with Discord")).click();
|
||||
await (await c.app.$("span=octocat")).waitForDisplayed({ timeout: 10000 });
|
||||
assert.ok(!(await c.app.$("p*=Another sign-in is already open").isExisting()));
|
||||
} finally {
|
||||
await c.close();
|
||||
}
|
||||
});
|
||||
@@ -1,187 +0,0 @@
|
||||
/**
|
||||
* Usage data: on by default as on the website, said so once, off in
|
||||
* a click (here or on the account), and never a file, folder or user name.
|
||||
* Events go to the mock API's stand-in for PostHog (QUIVER_POSTHOG_HOST).
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { homedir, userInfo } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
import { startMockApi } from "./mock-api.js";
|
||||
|
||||
let api, s;
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
const events = (name) => api.telemetry().filter((e) => e.event === name);
|
||||
const notice = () => s.app.$('[aria-label="Usage data"]');
|
||||
const usageSwitch = async () => (await s.app.$("label*=Send usage data")).$("input");
|
||||
const openSettings = async () => {
|
||||
await s.settings("General");
|
||||
await (await usageSwitch()).waitForExist({ timeout: 10000 });
|
||||
};
|
||||
const signIn = async (create) => {
|
||||
await (await s.app.$("button=Sign in")).click();
|
||||
if (create) await (await s.app.$("button=Create an account")).click();
|
||||
await (await s.app.$("input[placeholder=Username]")).setValue("player");
|
||||
await (await s.app.$("input[placeholder=Password]")).setValue("correct horse battery");
|
||||
await (await s.app.$("form button.primary")).click();
|
||||
await (await s.app.$(".account-button")).waitForDisplayed({ timeout: 10000 });
|
||||
};
|
||||
/** Moves around the launcher: what would send screens if usage data were on. */
|
||||
const wander = async () => {
|
||||
await (await s.app.$("button=Browse")).click();
|
||||
await (await (await s.card("test-port")).$(".card-open")).click();
|
||||
await (await s.app.$(".app-page")).waitForDisplayed();
|
||||
await s.app.keys("Escape");
|
||||
await (await s.app.$("button*=Library")).click();
|
||||
await (await s.app.$("button=Browse")).click();
|
||||
};
|
||||
/** Nothing more arrives, even after PostHog's queue would have sent it. */
|
||||
const assertQuiet = async () => {
|
||||
// Anything captured before turning it off has gone by now.
|
||||
await sleep(5000);
|
||||
const before = api.telemetry().length;
|
||||
await wander();
|
||||
await sleep(6000);
|
||||
assert.deepEqual(api.telemetry().slice(before).map((e) => e.event), []);
|
||||
};
|
||||
|
||||
before(async () => {
|
||||
api = await startMockApi();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await s?.close();
|
||||
api?.close();
|
||||
});
|
||||
|
||||
test("usage data is on at first, says so once, and every event says it's the launcher", async () => {
|
||||
s = await launch({ api });
|
||||
const bar = await notice();
|
||||
await bar.waitForDisplayed({ timeout: 20000 });
|
||||
assert.match(await bar.getText(), /Quiver Launcher sends usage data to help improve it\. It's anonymous unless you sign in\. You can turn this off in Settings\./);
|
||||
await s.until(() => events("launcher_started").length > 0 && events("screen_viewed").length > 0, 30000);
|
||||
const [started] = events("launcher_started");
|
||||
assert.equal(started.properties.first_run, true);
|
||||
for (const event of [started, ...events("screen_viewed")]) {
|
||||
assert.equal(event.properties.app, "launcher");
|
||||
assert.match(event.properties.launcher_version, /^\d+\.\d+\.\d+/);
|
||||
assert.equal(event.properties.os, process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux");
|
||||
assert.ok(event.properties.arch);
|
||||
}
|
||||
// A new player starts in the catalog.
|
||||
assert.deepEqual(events("screen_viewed")[0].properties.screen, "browse");
|
||||
// Only the launcher's own events: nothing captured by itself.
|
||||
assert.ok(!api.telemetry().some((e) => ["$autocapture", "$pageview", "$pageleave", "$rageclick"].includes(e.event)));
|
||||
|
||||
await (await bar.$("button=OK")).click();
|
||||
await bar.waitForExist({ reverse: true });
|
||||
const data = s.data;
|
||||
await s.close();
|
||||
s = await launch({ api, data });
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await s.until(() => events("launcher_started").some((e) => e.properties.first_run === false), 30000);
|
||||
assert.equal(await (await notice()).isExisting(), false, "the notice shows once");
|
||||
});
|
||||
|
||||
test("installing and playing an app sends its slug, never a folder, a path or the user name", async () => {
|
||||
await (await (await s.card("test-port")).$("button=Get")).click();
|
||||
await (await (await s.card("test-port")).$("button*=Play")).waitForDisplayed({ timeout: 30000 });
|
||||
await (await (await s.card("test-port")).$("button*=Play")).click();
|
||||
await s.until(() => events("app_installed").length > 0 && (events("app_launched").length > 0 || events("app_launch_failed").length > 0), 30000);
|
||||
assert.deepEqual(
|
||||
{ ...events("app_install_started")[0].properties, ...events("app_installed")[0].properties }.slug,
|
||||
"test-port",
|
||||
);
|
||||
assert.equal(events("app_installed")[0].properties.version, "1.0.0");
|
||||
assert.equal(events("app_installed")[0].properties.source, "catalog");
|
||||
// Settings shows the apps folder; showing it sends nothing about it.
|
||||
await s.settings("Apps folder");
|
||||
await s.closeSettings();
|
||||
await sleep(5000);
|
||||
|
||||
const sent = api.telemetryBodies().join("\n");
|
||||
const json = (text) => JSON.stringify(text).slice(1, -1);
|
||||
for (const folder of [s.data, s.apps, homedir()]) {
|
||||
assert.ok(!sent.toLowerCase().includes(folder.toLowerCase()), `${folder} was sent`);
|
||||
assert.ok(!sent.toLowerCase().includes(json(folder).toLowerCase()), `${folder} was sent`);
|
||||
}
|
||||
assert.doesNotMatch(sent, /(?<![A-Za-z0-9])[A-Za-z]:(\\\\|\\|\/)/, "a Windows path was sent");
|
||||
assert.doesNotMatch(sent, /(?<![\w.:/-])\/(home|Users|tmp|root|var)\//, "a Linux or macOS path was sent");
|
||||
const user = userInfo().username;
|
||||
if (user.length >= 3)
|
||||
assert.doesNotMatch(sent, new RegExp(`(?<![\\p{L}\\p{N}_-])${user.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_-])`, "iu"), "the user name was sent");
|
||||
});
|
||||
|
||||
test("turning usage data off in Settings stops it, and it stays off", async () => {
|
||||
await openSettings();
|
||||
const toggle = await usageSwitch();
|
||||
assert.equal(await toggle.isSelected(), true);
|
||||
assert.match(
|
||||
await (await s.app.$("section.settings-page")).getText(),
|
||||
/Helps improve Quiver Launcher: which screens and features get used, and errors\. Never your files or folders\./,
|
||||
);
|
||||
await toggle.click();
|
||||
assert.equal(await toggle.isSelected(), false);
|
||||
await s.closeSettings();
|
||||
await assertQuiet();
|
||||
await s.until(() => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8")).telemetryOff === true);
|
||||
});
|
||||
|
||||
test("the first-run notice's Turn off turns it off", async () => {
|
||||
await s.close();
|
||||
s = await launch({ api });
|
||||
const bar = await notice();
|
||||
await bar.waitForDisplayed({ timeout: 20000 });
|
||||
await (await bar.$("button=Turn off")).click();
|
||||
await bar.waitForExist({ reverse: true });
|
||||
await openSettings();
|
||||
assert.equal(await (await usageSwitch()).isSelected(), false);
|
||||
await s.closeSettings();
|
||||
await assertQuiet();
|
||||
});
|
||||
|
||||
test("signed in, the switch saves to the account, and an opt-out here holds whatever the account says", async () => {
|
||||
await s.close();
|
||||
s = await launch({ api });
|
||||
await (await notice()).waitForDisplayed({ timeout: 20000 });
|
||||
await signIn(true);
|
||||
// Events join the account's person, as on the website.
|
||||
await s.until(() => events("$identify").some((e) => e.properties.distinct_id === "user_player"), 30000);
|
||||
const identify = events("$identify").find((e) => e.properties.distinct_id === "user_player");
|
||||
assert.deepEqual(identify.$set ?? identify.properties.$set, { name: "player", provider: "password" });
|
||||
await s.until(() => events("signed_in").some((e) => e.properties.method === "password" && e.properties.created === true));
|
||||
|
||||
await openSettings();
|
||||
assert.match(await (await s.app.$("section.settings-page")).getText(), /follows your Quiver account's setting/);
|
||||
await (await usageSwitch()).click();
|
||||
await s.until(() => api.analyticsCalls.some((c) => c.user === "player" && c.enabled === false));
|
||||
await s.closeSettings();
|
||||
await assertQuiet();
|
||||
|
||||
// Signed out, this computer remembers it was turned off. Signed back in to an account turned on elsewhere, it stays
|
||||
// off here: an opt-out never comes undone by itself.
|
||||
await (await s.app.$(".account-button")).click();
|
||||
await (await s.app.$("button=Sign out")).click();
|
||||
await (await s.app.$("button=Sign in")).waitForDisplayed({ timeout: 10000 });
|
||||
await openSettings();
|
||||
assert.equal(await (await usageSwitch()).isSelected(), false);
|
||||
await s.closeSettings();
|
||||
api.setAnalytics("player", true);
|
||||
await signIn(false);
|
||||
await (await s.app.$(".account-button")).waitForDisplayed({ timeout: 10000 });
|
||||
await openSettings();
|
||||
assert.equal(await (await usageSwitch()).isSelected(), false);
|
||||
await s.closeSettings();
|
||||
await assertQuiet();
|
||||
|
||||
// Turned back on here, it's on for both, and sends again.
|
||||
await openSettings();
|
||||
await (await usageSwitch()).click();
|
||||
await s.until(() => api.analyticsCalls.some((c) => c.user === "player" && c.enabled === true));
|
||||
await s.closeSettings();
|
||||
const before = api.telemetry().length;
|
||||
await wander();
|
||||
await s.until(() => api.telemetry().slice(before).some((e) => e.event === "screen_viewed"), 20000);
|
||||
});
|
||||
@@ -138,7 +138,7 @@ test("A opens a catalog card, and Y gets the app", async () => {
|
||||
// It has a download for each system: Y asks which.
|
||||
assert.equal(await open('article[data-slug="tampered-port"] .card-open', { key: "North" }), "dialog: Choose a download");
|
||||
await everything("Choose a download");
|
||||
// A on one starts it (what it installs is the real app's to show: journeys.test.js).
|
||||
// A on one starts it (what it installs is the real app's to show).
|
||||
assert.doesNotMatch(await reach.pressOn(app, '[role="dialog"] button', "South", { text: "linux" }), /^not reached/);
|
||||
await s.until(() => app.execute(() => window.__calls.some((c) => c.cmd === "install")));
|
||||
});
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Without the system's title bar (the default), the window's own buttons sit
|
||||
* at the right of the top bar; Settings brings the system's title bar back,
|
||||
* and the buttons go, until next time too.
|
||||
*/
|
||||
import { after, before, test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
let s;
|
||||
before(async () => {
|
||||
s = await launch();
|
||||
});
|
||||
after(() => s?.close());
|
||||
|
||||
const buttons = () => s.app.execute(() => [...document.querySelectorAll(".topbar .window-controls button")].map((b) => b.getAttribute("aria-label")));
|
||||
const titleBarSwitch = async () => (await s.app.$("label*=Use the system's title bar")).$("input");
|
||||
const saved = () => JSON.parse(readFileSync(join(s.data, "settings.json"), "utf8"));
|
||||
|
||||
test("the top bar has the window's buttons, last after Settings", async () => {
|
||||
await s.until(async () => (await buttons()).length === 3);
|
||||
assert.deepEqual(await buttons(), ["Minimize", "Maximize", "Close"]);
|
||||
const last = await s.app.execute(() => document.querySelector(".topbar").lastElementChild.className);
|
||||
assert.equal(last, "window-controls");
|
||||
// In the window's corner: the bar has no padding on that side.
|
||||
assert.equal(await s.app.execute(() => getComputedStyle(document.querySelector(".topbar")).paddingRight), "0px");
|
||||
});
|
||||
|
||||
test("the buttons are on the right before the account part has loaded", async () => {
|
||||
// At startup the account part (Sign in, or the player's name) isn't there yet.
|
||||
const gearRight = () => s.app.execute(() => Math.round(document.querySelector("button[aria-label=Settings]").getBoundingClientRect().right));
|
||||
const before = await gearRight();
|
||||
await s.app.execute(() => document.querySelector(".topbar .account").style.setProperty("display", "none"));
|
||||
assert.equal(await gearRight(), before);
|
||||
await s.app.execute(() => document.querySelector(".topbar .account").style.removeProperty("display"));
|
||||
});
|
||||
|
||||
test("Settings brings the system's title bar back, and the buttons go", async () => {
|
||||
await s.settings("General");
|
||||
const toggle = await titleBarSwitch();
|
||||
await toggle.waitForExist({ timeout: 10000 });
|
||||
assert.equal(await toggle.isSelected(), false);
|
||||
await toggle.click();
|
||||
await s.closeSettings();
|
||||
await s.until(async () => (await buttons()).length === 0);
|
||||
await s.until(() => saved().systemTitleBar === true);
|
||||
// The gear is back 6px (its own padding aside) from the window's edge.
|
||||
assert.equal(await s.app.execute(() => getComputedStyle(document.querySelector(".topbar")).paddingRight), "6px");
|
||||
});
|
||||
|
||||
test("it stays on next time, and turning it off brings the buttons back", async () => {
|
||||
const data = s.data;
|
||||
await s.close();
|
||||
s = await launch({ data });
|
||||
await (await s.app.$("button[aria-label=Settings]")).waitForDisplayed({ timeout: 20000 });
|
||||
assert.deepEqual(await buttons(), []);
|
||||
await s.settings("General");
|
||||
const toggle = await titleBarSwitch();
|
||||
await toggle.waitForExist({ timeout: 10000 });
|
||||
assert.equal(await toggle.isSelected(), true);
|
||||
await toggle.click();
|
||||
await s.closeSettings();
|
||||
await s.until(async () => (await buttons()).length === 3);
|
||||
await s.until(() => saved().systemTitleBar === false);
|
||||
});
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* The window comes back at the size and place it had when the launcher was
|
||||
* last open, kept in the launcher's data.
|
||||
*/
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { existsSync, mkdtempSync, readFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { launch } from "./session.js";
|
||||
|
||||
const data = mkdtempSync(join(tmpdir(), "quiver-data-"));
|
||||
const saved = () => (existsSync(join(data, "window.json")) ? JSON.parse(readFileSync(join(data, "window.json"), "utf8")) : null);
|
||||
|
||||
test("the window's size and place are kept for next time", async () => {
|
||||
let s = await launch({ data });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
await s.app.setWindowRect(140, 90, 1000, 640);
|
||||
await s.until(() => saved()?.rect.width === 1000 && saved()?.rect.x === 140);
|
||||
assert.equal(saved().maximized, false);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
|
||||
s = await launch({ data });
|
||||
try {
|
||||
await (await s.card("test-port")).waitForDisplayed({ timeout: 20000 });
|
||||
const rect = await s.app.getWindowRect();
|
||||
assert.deepEqual([rect.x, rect.y, rect.width], [140, 90, 1000]);
|
||||
assert.ok(Math.abs(rect.height - 640) <= 40, `about 640 high, with any title bar: ${rect.height}`);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# The Linux end-to-end tests on Windows, in WSL's Ubuntu 24.04 with WebKitGTK as on a Steam Deck. CI doesn't run
|
||||
# them, so this is where they run. From the checkout, in PowerShell or a terminal:
|
||||
#
|
||||
# wsl -d Ubuntu-24.04 -- e2e/wsl.sh setup once: Rust, Node, pnpm, cmake and tauri-driver, in ~
|
||||
# wsl -d Ubuntu-24.04 -- e2e/wsl.sh build copies the checkout to ~/quiver and builds the app
|
||||
# wsl -d Ubuntu-24.04 -- e2e/wsl.sh test journeys.test.js copies it again and runs those files (none: all but live and phone)
|
||||
#
|
||||
# test only copies: after a change to the app itself, build again. First, once, in Ubuntu 24.04's own shell, the
|
||||
# libraries CI installs:
|
||||
# sudo apt-get install -y libdbus-1-dev libwebkit2gtk-4.1-dev librsvg2-dev libayatana-appindicator3-dev libudev-dev webkit2gtk-driver xvfb build-essential curl git rsync
|
||||
set -euo pipefail
|
||||
|
||||
checkout=$(cd "$(dirname "$0")/.." && pwd)
|
||||
copy=${QUIVER_WSL_COPY:-$HOME/quiver}
|
||||
# Linux's own tools ahead of Windows' (WSL adds Windows' PATH, with a pnpm of its own).
|
||||
export PATH=$HOME/.cargo/bin:$HOME/.local/node/bin:$HOME/.local/cmake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# A build through /mnt/c crawls: the tests run from a copy in Linux's own file system, which keeps its own packages and build.
|
||||
copy_over() {
|
||||
mkdir -p "$copy"
|
||||
rsync -a --delete --exclude node_modules --exclude target --exclude .git --exclude e2e/phone-screenshots --exclude apps/launcher/dist "$checkout/" "$copy/"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
setup)
|
||||
command -v cargo >/dev/null || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||
if [ ! -x "$HOME/.local/node/bin/node" ]; then
|
||||
file=$(curl -fsSL https://nodejs.org/dist/latest-v22.x/ | grep -o 'node-v22[0-9.]*-linux-x64.tar.xz' | head -1)
|
||||
mkdir -p "$HOME/.local/node"
|
||||
curl -fsSL "https://nodejs.org/dist/latest-v22.x/$file" | tar -xJ -C "$HOME/.local/node" --strip-components=1
|
||||
fi
|
||||
corepack enable
|
||||
# The controllers' SDL builds with cmake, which GitHub's runners come with.
|
||||
if [ ! -x "$HOME/.local/cmake/bin/cmake" ]; then
|
||||
mkdir -p "$HOME/.local/cmake"
|
||||
curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz | tar -xz -C "$HOME/.local/cmake" --strip-components=1
|
||||
fi
|
||||
[ -x "$HOME/.cargo/bin/tauri-driver" ] || cargo install tauri-driver --locked
|
||||
;;
|
||||
build)
|
||||
copy_over
|
||||
cd "$copy"
|
||||
CI=true pnpm install --frozen-lockfile
|
||||
pnpm --filter @quiver/e2e build
|
||||
;;
|
||||
test)
|
||||
shift
|
||||
copy_over
|
||||
cd "$copy/e2e"
|
||||
[ $# -gt 0 ] || set -- $(ls *.test.js | grep -vE '^(live|phone)\.test\.js$')
|
||||
# Each app on a virtual display of its own (session.js), not WSLg's. WSLg mounts /tmp/.X11-unix read-only, where
|
||||
# Xvfb makes its socket: the run gets a writable one, in a mount namespace of its own. And a D-Bus session of its
|
||||
# own, as on CI.
|
||||
unset DISPLAY WAYLAND_DISPLAY
|
||||
exec unshare --user --map-root-user --mount sh -c 'mount -t tmpfs tmpfs /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix && exec dbus-run-session -- node --test --test-concurrency=1 --test-force-exit "$@"' sh "$@"
|
||||
;;
|
||||
*)
|
||||
sed -n '2,11p' "$0"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
+1
-2
@@ -6,8 +6,7 @@
|
||||
"dev": "pnpm --filter @quiver/launcher tauri dev",
|
||||
"build": "pnpm --filter @quiver/launcher tauri build",
|
||||
"typecheck": "pnpm -r typecheck",
|
||||
"test": "pnpm -r test",
|
||||
"e2e": "pnpm --filter @quiver/e2e e2e"
|
||||
"test": "pnpm -r test"
|
||||
},
|
||||
"packageManager": "pnpm@10.16.0"
|
||||
}
|
||||
Reference in new issue
Block a user