mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-11-16 04:45:33 -08:00
Fix CI: tests follow Activities starting off, findAgent fixture uses a portable path, Ghoul Rush eye test waits for the eye
AI Assisted
This commit is contained in:
1 parent
17f98e62b5
commit
8ddf37911e
6 files changed
+34
-23
No files matched your search
@@ -81,7 +81,7 @@
|
||||
{
|
||||
"name": "an install folder with %NAME% expands against vars",
|
||||
"platform": "win",
|
||||
"entry": { "command": "goose", "installDirs": { "win": ["%TOOLS%\\bin"] } },
|
||||
"entry": { "command": "goose", "installDirs": { "win": ["%TOOLS%/bin"] } },
|
||||
"dirs": { "tools": ["bin/goose.exe"] },
|
||||
"env": { "path": "", "savedPath": "", "npmBin": "", "pathext": ".EXE;.CMD", "vars": { "TOOLS": "{tools}" } },
|
||||
"state": "outside",
|
||||
|
||||
@@ -652,7 +652,8 @@ test("Ghoul Rush's dollhouse draws: the landing, the fight with the Eye in every
|
||||
standAt(r, 10);
|
||||
frame("the landing");
|
||||
standAt(r, r.spec.arena + 14);
|
||||
for (let ms = 0; ms < 1600; ms += 16) g.tick(16);
|
||||
// The House's intro runs a seed-dependent while: tick until its Eye exists, not a fixed time.
|
||||
for (let ms = 0; ms < 1600 || (!r.boss.eye && ms < 20000); ms += 16) g.tick(16);
|
||||
for (const [state, decoy] of [["flare", -1], ["flare", 6], ["open", -1], ["closing", -1], ["shut", -1]]) {
|
||||
Object.assign(r.boss.eye, { state, ms: 300, full: 1000, room: 4, decoy });
|
||||
frame(`the Eye ${state}`);
|
||||
|
||||
@@ -355,6 +355,10 @@ test("the Desktop app group shows only in the app's frame, reflects the app's sa
|
||||
});
|
||||
|
||||
test("framed, an Activities game in full screen asks the app for the whole screen, and gives it back on F, Esc and a new question", async (t) => {
|
||||
// Activities start off for a new person: save them on for this test.
|
||||
const looksFile = path.join(HOME, "looks.json");
|
||||
fs.writeFileSync(looksFile, JSON.stringify({ looks: { hideActivities: false } }));
|
||||
t.after(() => fs.rmSync(looksFile, { force: true }));
|
||||
const s = await openSession(await pages.browser(), { t, workflow: "plan", payload: { agent: { status: "working", activity: "Reading" } }, env: { PLAN2CODE_IN_APP: "1" }, init: FAKE_APP_FRAME });
|
||||
await s.page.click("#btn-activities");
|
||||
await s.page.locator('.activities-card[data-activity="snake"]').click();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import test, { beforeEach, after } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { pageSuite, openSession, drawn, itemCard, boxValue, fillBox } from "./page-test-helpers.mjs";
|
||||
import { until, HOME } from "./web-console-test-helpers.mjs";
|
||||
@@ -30,11 +30,17 @@ const suite = pageSuite(test);
|
||||
// The person's saved looks, shared by every session in this console home.
|
||||
const LOOKS_FILE = path.join(HOME, "looks.json");
|
||||
|
||||
// Starts a test from the given saved looks (none when left out) and leaves
|
||||
// none behind, so a best score or a hidden die never leaks into the next test.
|
||||
// Activities start off for a new person, so a test that saves no looks of its
|
||||
// own still starts with the die showing. savedLooks() replaces this file.
|
||||
beforeEach(() => fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { hideActivities: false } })));
|
||||
after(() => fs.rmSync(LOOKS_FILE, { force: true }));
|
||||
|
||||
// Starts a test from the given saved looks and leaves none behind, so a best
|
||||
// score or a hidden die never leaks into the next test. Activities start off
|
||||
// for a new person, so every test starts with them on (hideActivities false)
|
||||
// unless it saves its own switch.
|
||||
function savedLooks(t, looks) {
|
||||
if (looks) fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks }));
|
||||
else fs.rmSync(LOOKS_FILE, { force: true });
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { hideActivities: false, ...looks } }));
|
||||
t.after(() => fs.rmSync(LOOKS_FILE, { force: true }));
|
||||
}
|
||||
|
||||
@@ -277,7 +283,7 @@ test("a new session's picker marks the last played and puts focus on it, and a l
|
||||
assert.match(await card(s, "golf").innerText(), /Last played/);
|
||||
assert.doesNotMatch(await card(s, "snake").innerText(), /Last played/);
|
||||
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true, lastActivity: "chess" } }));
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true, hideActivities: false, lastActivity: "chess" } }));
|
||||
const again = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
|
||||
await openPicker(again);
|
||||
assert.equal(await focusedCard(again), "snake", "an unknown pick puts focus on the first card");
|
||||
@@ -2085,26 +2091,26 @@ test("saved Activities values that do not hold up fall back to their defaults",
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
|
||||
const looks = await pageLooks(s);
|
||||
assert.equal(looks.activityBestSnake, 0, "a negative best is none");
|
||||
assert.equal(looks.hideActivities, false, "a switch that is not a boolean is on");
|
||||
assert.equal(looks.hideActivities, true, "a switch that is not a boolean is off, the default");
|
||||
assert.equal(looks.lastActivity, "", "a last pick that is not a string is none");
|
||||
await iconUsable(s, "a skill screen");
|
||||
assert.ok(await s.page.locator("#btn-activities").isHidden(), "and the die stays hidden");
|
||||
|
||||
fs.writeFileSync(LOOKS_FILE, JSON.stringify({ looks: { welcomeSeen: true, activityBestSnake: 3.7 } }));
|
||||
const again = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
|
||||
assert.equal((await pageLooks(again)).activityBestSnake, 3, "a best is a whole number");
|
||||
});
|
||||
|
||||
test("Back to default turns Show Activities back on and keeps the best scores", async (t) => {
|
||||
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12, lastActivity: "snake", hideActivities: true });
|
||||
test("Back to default turns Show Activities back off and keeps the best scores", async (t) => {
|
||||
savedLooks(t, { welcomeSeen: true, activityBestSnake: 12, lastActivity: "snake", hideActivities: false });
|
||||
const s = await openSession(await suite.browser(), { t, workflow: "plan", payload: PLAN_WORKING });
|
||||
assert.ok(await s.page.locator("#btn-activities").isHidden(), "the saved switch hides the die");
|
||||
await iconUsable(s, "a skill screen with the switch saved on");
|
||||
await s.page.click("#btn-looks");
|
||||
await s.page.click("#prefs-tab-sounds");
|
||||
await s.page.locator("#looks-modal[open]").waitFor();
|
||||
await s.page.click("#looks-reset");
|
||||
await s.page.click("#looks-done");
|
||||
await iconUsable(s, "a skill screen after Back to default");
|
||||
await until(async () => (await serverLooks(s)).hideActivities === false, 5000);
|
||||
assert.ok(await s.page.locator("#btn-activities").isHidden(), "the default hides the die again");
|
||||
await until(async () => (await serverLooks(s)).hideActivities === true, 5000);
|
||||
const saved = await serverLooks(s);
|
||||
assert.equal(saved.activityBestSnake, 12, "the best score stays");
|
||||
assert.equal(saved.lastActivity, "snake", "the last pick stays");
|
||||
@@ -2139,7 +2145,7 @@ test("Show Activities in User Preferences hides the die on the dashboard and on
|
||||
await dash.page.click("#prefs-tab-sounds");
|
||||
await dash.page.locator("#looks-modal[open]").waitFor();
|
||||
const box = dash.page.locator("#looks-activities");
|
||||
assert.ok(await box.isChecked(), "on by default");
|
||||
assert.ok(await box.isChecked(), "on as saved");
|
||||
await box.uncheck();
|
||||
await dash.page.click("#looks-done");
|
||||
assert.ok(await dash.page.locator("#btn-activities").isHidden(), "the die is gone from the dashboard");
|
||||
|
||||
@@ -767,7 +767,7 @@ test("Back to default resets only the tab on screen, and is hidden on Agents & m
|
||||
await swatch(s, "violet").click();
|
||||
await s.page.click("#prefs-tab-sounds");
|
||||
await s.page.locator("#looks-sound").uncheck();
|
||||
await s.page.locator("#looks-activities").uncheck();
|
||||
await s.page.locator("#looks-activities").check();
|
||||
|
||||
await s.page.click("#prefs-tab-agents");
|
||||
assert.equal(await s.page.locator("#looks-reset").isHidden(), true, "hidden on Agents & models");
|
||||
@@ -780,18 +780,18 @@ test("Back to default resets only the tab on screen, and is hidden on Agents & m
|
||||
assert.equal(await swatch(s, "violet").getAttribute("aria-pressed"), "false");
|
||||
await s.page.click("#prefs-tab-sounds");
|
||||
assert.equal(await s.page.locator("#looks-sound").isChecked(), false, "Appearance's reset left sounds off");
|
||||
assert.equal(await s.page.locator("#looks-activities").isChecked(), false);
|
||||
assert.equal(await s.page.locator("#looks-activities").isChecked(), true, "and Activities on");
|
||||
|
||||
await s.page.click("#prefs-tab-appearance");
|
||||
await s.page.locator('input[name="looks-theme"][value="dark"]').check();
|
||||
await s.page.click("#prefs-tab-sounds");
|
||||
await s.page.click("#looks-reset");
|
||||
await s.page.locator("#looks-sound:checked").waitFor();
|
||||
assert.equal(await s.page.locator("#looks-activities").isChecked(), true);
|
||||
assert.equal(await s.page.locator("#looks-activities").isChecked(), false, "the sounds reset puts Activities back off");
|
||||
assert.equal(await root(s, "data-theme"), "dark", "the sounds reset left the dark theme");
|
||||
await s.page.waitForFunction(async () => {
|
||||
const saved = (await (await fetch("/looks")).json()).looks || {};
|
||||
return saved.sound === true && saved.hideActivities === false && saved.theme === "dark";
|
||||
return saved.sound === true && saved.hideActivities === true && saved.theme === "dark";
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -844,18 +844,18 @@ test("prefs: Back to default resets Appearance or Sounds & activities only, and
|
||||
test("looks: resetLooks(keys) changes only those keys, and the role is marked as asked", () => {
|
||||
const before = { ...looks };
|
||||
try {
|
||||
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: true, activityBestSnake: 7, lastActivity: "snake" });
|
||||
Object.assign(looks, { theme: "dark", width: "wide", accent: "violet", role: "pm", sound: false, soundQuestion: false, hideActivities: false, activityBestSnake: 7, lastActivity: "snake" });
|
||||
resetLooks(prefsResetScope("appearance"));
|
||||
assert.equal(looks.theme, DEFAULT_LOOKS.theme);
|
||||
assert.equal(looks.width, DEFAULT_LOOKS.width);
|
||||
assert.equal(looks.accent, DEFAULT_LOOKS.accent);
|
||||
assert.equal(looks.role, ROLE_NOT_SET, "cleared but marked as asked");
|
||||
assert.equal(looks.sound, false, "sounds untouched by Appearance");
|
||||
assert.equal(looks.hideActivities, true);
|
||||
assert.equal(looks.hideActivities, false);
|
||||
resetLooks(prefsResetScope("sounds"));
|
||||
assert.equal(looks.sound, true);
|
||||
assert.equal(looks.soundQuestion, true);
|
||||
assert.equal(looks.hideActivities, false);
|
||||
assert.equal(looks.hideActivities, DEFAULT_LOOKS.hideActivities);
|
||||
assert.equal(looks.activityBestSnake, 7, "best scores stay");
|
||||
assert.equal(looks.lastActivity, "snake", "the last pick stays");
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user