library: the Skills and MCP headings keep Select and put the rest under ⋯
ryanpascal on Discord: the Library › Skills heading had too many buttons, up to a dozen beside the sort. The heading now shows the sort, Select, Clean up and Update n when they apply, and a ⋯ (the app's row menu, openRowMenu) holding Check for updates, Update all, Group again, Collapse all / Expand all, Turn all on, Turn all off, By agent, Manage n in magpie and Remove all, in that order with separators. The MCP servers heading does the same with Turn all on, Turn all off, By agent and Remove all. A busy action stays in sight on the bar (Checking…, Grouping…, Updating…), so the wait is seen. Each menu item is the old button: its words, its title, greyed when it was, its click; Remove all is red as it was. No new words: ⋯ is the core's "More". barMore builds the menu from the buttons as they are when ⋯ is pressed, so a count or a greyed state is never stale; a hidden button is left out and the ⋯ itself is hidden when nothing is left. The tests that pressed these buttons on the bar (by-agent, every-skill, github-token, library-gone-agents, library-null-agents, library-servers-bulk, remove-all-skills, skill-fold-all, skill-git-source, skill-handover, skill-new-in-repo, skill-regroup) now open ⋯ and press the item. docs/subsystems/library.md says where the buttons are. Run (mote, through mote-run): - node --test library-bar-more.test.cjs: 22 pass (en, zh, zh-TW, ja, de at 420 and 1180 px, Chromium and WebKit): nothing moved is on the bar, ⋯'s label, one line at 1180, the menu's items and order in each language, the menu inside the window, a second ⋯ closes it, Turn all off's sheet, Check for updates posting once, the MCP heading's menu, no sideways scroll. - the 12 updated files plus library-bar-more: 176 pass before the usage fix below, the 22 reds all library-bar-more's (its second ⋯ click eaten, the cause fixed in the commit before this; then the wide window's tabs, which are the side nav's, fixed in the test). - skill-manual, list-sort, skill-gone, skill-update-edited, skill-how, library-hooks, library-pick-remove, library-row-remove, menu-first-second, i18n-keys, i18n-en-no-cjk: 127 pass, 1 fail, the "a plugin's words are its own" red that origin/mainfe61503e6has (#5327, #5426, #5482). - the whole GUI suite under the suite lock: 21630 tests, 21295 pass, 335 fail in 63 files. Those 62 files (i18n-keys apart) again at fresh origin/main18a9a2d88and at this head, concurrency 6: 308 fail at main, 291 here, in the same files, each with an open issue (umbrella #5475). The five red only here (account-arrange, account-mask, codex-subagent-model, connect-snippet-shell, ledger-swipe), each failing different cases each run, pass 52 of 52 run alone here. At the pushed head (rebased on origin/main361da10ee, which brought 77bda84a6's folder Check for updates: its condition and title kept, the button moved under ⋯ like the rest, and skill-new-in-repo's new folder case opens ⋯), on mote: the 17 files above plus skill-new-in-repo, 239 pass, 1 fail, the known i18n-keys red (#5332). Broken by hand: HEAD's client.js and library.css (the old bar) put back, library-bar-more red in all 22 cases ("a moved button is still on the bar", 7 !== 0). Not tried: the real app with the user's own library; the tray panel has no Library; keyboard order through the menu beyond the first item's focus (openRowMenu's, unchanged). Reported-by: ryanpascal (Discord)
This commit is contained in:
@@ -36,7 +36,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it.
|
||||
|
||||
## Runtime path
|
||||
|
||||
1. **Edit.** The Library page or `magpie library` calls an exported function such as `SaveServer`, `ServerAgents`, `InstallSkills`, `SkillAgents` or `SetSkillHow`. The skills and servers pages each have Select, Turn all on, Turn all off and Remove all. Select's bar calls `SomeSkillsAgents` or `SomeServersAgents` (`/api/library/{skills,servers}/agents-some`), Turn all on or off calls `EverySkillAgents` or `EveryServerAgents` for the agents shown, and Remove all calls `RemoveSkills` or `RemoveServers`. The hooks page has Select and Remove all too (`SomeHooksAgents`, `RemoveHooks`). Each of these is one change that takes every item out as a single removal would (#1027). Select's bar also has Remove… (#1852), which asks first, naming the count, and sends only the picked names to `RemoveSkills`, `RemoveServers` or `RemoveHooks`; ticking a group's or part's header picks all of it. A name that wasn't removed stays picked, with its error in its row's place (`pickErrs`), and the status names it; when every name fails the endpoint answers 400 and the sheet stays open. A row's agent chips start with All (`allChip` in `plugins/library/client.js`), which gives the item to every agent shown that can take it, or takes it from them all; the pickers that choose the agents before an item is added (installing skills from a repository or the market, adding, bringing in or installing a server) have the same All: most start with every agent lit, and one agent alone took a click on each of the others (#1531).
|
||||
1. **Edit.** The Library page or `magpie library` calls an exported function such as `SaveServer`, `ServerAgents`, `InstallSkills`, `SkillAgents` or `SetSkillHow`. The skills and servers pages each have Select, Turn all on, Turn all off and Remove all; the heading shows Select (and a busy Checking…, Grouping… or Updating…) and keeps the rest under its ⋯, the app's row menu (`barMore` in plugins/library/client.js). Select's bar calls `SomeSkillsAgents` or `SomeServersAgents` (`/api/library/{skills,servers}/agents-some`), Turn all on or off calls `EverySkillAgents` or `EveryServerAgents` for the agents shown, and Remove all calls `RemoveSkills` or `RemoveServers`. The hooks page has Select and Remove all too (`SomeHooksAgents`, `RemoveHooks`). Each of these is one change that takes every item out as a single removal would (#1027). Select's bar also has Remove… (#1852), which asks first, naming the count, and sends only the picked names to `RemoveSkills`, `RemoveServers` or `RemoveHooks`; ticking a group's or part's header picks all of it. A name that wasn't removed stays picked, with its error in its row's place (`pickErrs`), and the status names it; when every name fails the endpoint answers 400 and the sheet stays open. A row's agent chips start with All (`allChip` in `plugins/library/client.js`), which gives the item to every agent shown that can take it, or takes it from them all; the pickers that choose the agents before an item is added (installing skills from a repository or the market, adding, bringing in or installing a server) have the same All: most start with every agent lit, and one agent alone took a click on each of the others (#1531).
|
||||
2. **Change.** `change` edits `library.json` under the lock and calls `sync`.
|
||||
3. **Write.** For each target, `syncInstructions`, `syncMCP`, `syncHooks` and `syncSubagents` write magpie's part in the agent's format and record it in `Applied`. Skills are linked or copied into the agent's skills folder. A copy edited since it was made is taken into the library first.
|
||||
4. **Result.** The `Result` lists the agents changed, a `Problem` for each thing that couldn't be given, and the backup folder. Each change's folder is its own (`freshBackup`): named by the millisecond, with `-2`, `-3`… after it when another change took that millisecond, so a change's copy is never another's (`TestBackupsInOneMillisecond`).
|
||||
|
||||
@@ -28,6 +28,7 @@ magpie.plugin("library", (ctx) => {
|
||||
let probing = false;
|
||||
let checking = false; // asking GitHub which skills it has changed
|
||||
let autoChecked = false; // the page checked by itself, as the server said it was due (#1449)
|
||||
let updatingAll = false; // Update all, picked from the bar's menu
|
||||
let regrouping = false; // the skills' repositories fetched to group them again
|
||||
let modal = null; // what the library has open in the dialog
|
||||
const hid = new Set(); // the write failures the reader hid, by agent and what (#3745)
|
||||
@@ -1672,9 +1673,14 @@ magpie.plugin("library", (ctx) => {
|
||||
const rh = el("div", "row-head lib-serverhead");
|
||||
rh.append(el("span", "label", t("In the library")), el("span", "grow"));
|
||||
if (many) rh.append(sortBy("libServers", NAME_SORTS, fill));
|
||||
if (many && all.length) rh.append(pickButton("servers"), ...everyButtons("servers", all));
|
||||
if (by) rh.append(byAgentButton("servers"));
|
||||
if (many) rh.append(removeEveryButton("servers"));
|
||||
// the rest under ⋯, as the skills' (ryanpascal on Discord)
|
||||
if (many && all.length) rh.append(pickButton("servers"));
|
||||
rh.append(barMore([
|
||||
...many && all.length ? everyButtons("servers", all).map((b) => [b, GLYPH.power]) : [],
|
||||
by && [byAgentButton("servers"), GLYPH.person],
|
||||
null,
|
||||
many && [removeEveryButton("servers"), GLYPH.trash],
|
||||
]));
|
||||
body.append(rh);
|
||||
}
|
||||
fill();
|
||||
@@ -3597,33 +3603,21 @@ magpie.plugin("library", (ctx) => {
|
||||
const fresh = lib.skills.filter((s) => s.kind === "github" || s.kind === "git" || s.origin);
|
||||
rh.append(el("span", "grow"));
|
||||
if (lib.skills.length > 1) rh.append(sortBy("libSkills", SKILL_SORTS(), () => { if (box.isConnected) drawSkills(box, all); }));
|
||||
if (lib.skills.length > 1) rh.append(foldAllButton(box, all));
|
||||
// the groups traced again: a pack added a while ago is mostly older
|
||||
// copies its repository has edited since (White Immortal on Discord)
|
||||
if (lib.skills.length > 1 && lib.skills.some((s) => skillRepo(s))) {
|
||||
const g = button(regrouping ? t("Grouping…") : t("Group again"), "lib-regroup", () => regroupSkills());
|
||||
g.title = t("Fetch the repositories your skills came from, and group the skills they have with them");
|
||||
g.disabled = regrouping;
|
||||
if (regrouping) g.classList.add("busy");
|
||||
rh.append(g);
|
||||
}
|
||||
if (lib.skills.length > 1 && all.length) rh.append(pickButton("skills"), ...everyButtons("skills", all));
|
||||
if (byAgentRows("skills").length) rh.append(byAgentButton("skills"));
|
||||
// every one kept in ~/.agents/skills, moved into the library at once
|
||||
// (tnt1223); a row moves its own
|
||||
const kept = lib.skills.filter((s) => s.shared);
|
||||
if (kept.length > 1) rh.append(handOverButton(kept));
|
||||
if (lib.skills.length > 1) rh.append(removeEveryButton("skills"));
|
||||
// what is used now and then waits under ⋯ (ryanpascal on Discord):
|
||||
// the bar keeps the order, Select, what is going on and what a check
|
||||
// found to do
|
||||
if (lib.skills.length > 1 && all.length) rh.append(pickButton("skills"));
|
||||
let check = false, again = false, updAll = false;
|
||||
if (lib.checkFolders || lib.skills.some((s) => s.kind === "github" || s.kind === "git")) {
|
||||
const c = button(checking ? t("Checking…") : t("Check for updates"), "lib-updall", () => checkSkills());
|
||||
const c = button(checking ? t("Checking…") : t("Check for updates"), "lib-updall lib-check", () => checkSkills());
|
||||
c.title = lib.checkFolders
|
||||
? t("Look in the repositories and folders your skills came from for changes and new skills")
|
||||
: lib.skills.some((s) => s.kind === "git")
|
||||
? t("Ask the repositories your skills came from which skills changed since they were installed")
|
||||
: t("Ask GitHub which skills changed since they were installed");
|
||||
c.disabled = checking;
|
||||
if (checking) c.classList.add("busy");
|
||||
rh.append(c);
|
||||
if (checking) { c.classList.add("busy"); rh.append(c); }
|
||||
else check = [c, REAPPLY];
|
||||
}
|
||||
// not checked since magpie started, or not for a while: the page
|
||||
// checks by itself, once, after it is drawn (#1449)
|
||||
@@ -3631,6 +3625,15 @@ magpie.plugin("library", (ctx) => {
|
||||
autoChecked = true;
|
||||
setTimeout(() => checkSkills(true), 0);
|
||||
}
|
||||
// the groups traced again: a pack added a while ago is mostly older
|
||||
// copies its repository has edited since (White Immortal on Discord)
|
||||
if (lib.skills.length > 1 && lib.skills.some((s) => skillRepo(s))) {
|
||||
const g = button(regrouping ? t("Grouping…") : t("Group again"), "lib-updall lib-regroup", () => regroupSkills());
|
||||
g.title = t("Fetch the repositories your skills came from, and group the skills they have with them");
|
||||
g.disabled = regrouping;
|
||||
if (regrouping) { g.classList.add("busy"); rh.append(g); }
|
||||
else again = [g, GLYPH.folder];
|
||||
}
|
||||
// skills their source no longer has, from one place only: no group
|
||||
// heading is drawn to hold its Clean up, so the bar does
|
||||
if (skillGroups().length === 1) {
|
||||
@@ -3650,16 +3653,33 @@ magpie.plugin("library", (ctx) => {
|
||||
u.title = n === 1 ? t("Fetch {name} from GitHub again", { name: stale[0].name }) : t("Fetch the {n} skills GitHub changed again", { n });
|
||||
rh.append(u);
|
||||
} else if (fresh.length > 1) {
|
||||
const u = button(t("Update all"), "action lib-updall", async (e, b) => {
|
||||
b.classList.add("busy");
|
||||
b.textContent = t("Updating…");
|
||||
// picked from the menu: the bar says it is at work till it is done
|
||||
const u = button(updatingAll ? t("Updating…") : t("Update all"), "action lib-updall lib-updallnow", async () => {
|
||||
updatingAll = true;
|
||||
render();
|
||||
await updateAllSkills();
|
||||
b.classList.remove("busy");
|
||||
b.textContent = t("Update all");
|
||||
updatingAll = false;
|
||||
render();
|
||||
});
|
||||
u.title = t("Fetch the {n} skills from GitHub again", { n: fresh.length });
|
||||
rh.append(u);
|
||||
u.disabled = updatingAll;
|
||||
if (updatingAll) { u.classList.add("busy"); rh.append(u); }
|
||||
else updAll = [u, GLYPH.down];
|
||||
}
|
||||
// every one kept in ~/.agents/skills, moved into the library at once
|
||||
// (tnt1223); a row moves its own
|
||||
const kept = lib.skills.filter((s) => s.shared);
|
||||
const many = lib.skills.length > 1;
|
||||
rh.append(barMore([
|
||||
check, updAll, again,
|
||||
many && [foldAllButton(box, all), () => foldAllBtn?.textContent === t("Expand all") ? MOVE_DOWN : MOVE_UP],
|
||||
null,
|
||||
...many && all.length ? everyButtons("skills", all).map((b) => [b, GLYPH.power]) : [],
|
||||
byAgentRows("skills").length && [byAgentButton("skills"), GLYPH.person],
|
||||
kept.length > 1 && [handOverButton(kept), GLYPH.skill],
|
||||
null,
|
||||
many && [removeEveryButton("skills"), GLYPH.trash],
|
||||
]));
|
||||
body.append(rh);
|
||||
drawSkills(box, all);
|
||||
body.append(box);
|
||||
@@ -3994,6 +4014,41 @@ magpie.plugin("library", (ctx) => {
|
||||
// on each heading would leave them; while filtering, it folds or opens
|
||||
// the groups the filter shows, till the filter changes, as a heading's
|
||||
// click does then. A part inside a group keeps its own fold.
|
||||
// The ⋯ at a list's heading (ryanpascal on Discord): the actions used
|
||||
// now and then, the app's own row menu. Each is [button, icon], a button
|
||||
// made as the bar's own would be, so its name, title and whether it can
|
||||
// be used are read when the menu opens; null is a line between them, and
|
||||
// a hidden button, or a false one (not there), is left out. The menu's item keeps the
|
||||
// button's lib-* names, which the tests click.
|
||||
function barMore(entries) {
|
||||
const b = el("button", "text action lib-updall lib-barmore");
|
||||
b.type = "button";
|
||||
b.title = t("More");
|
||||
b.setAttribute("aria-label", t("More"));
|
||||
b.setAttribute("aria-haspopup", "menu");
|
||||
b.append(svg(DOTS, 14, 2));
|
||||
b.hidden = !entries.some(Boolean);
|
||||
b.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
if (b.classList.contains("open")) return closeAgentMenu();
|
||||
const acts = [], cls = [];
|
||||
let sep = false;
|
||||
for (const x of entries) {
|
||||
if (x === null) { sep = acts.length > 0; continue; }
|
||||
if (!x) continue;
|
||||
const [btn, icon] = x;
|
||||
if (btn.hidden) continue;
|
||||
acts.push({ name: btn.textContent, literal: true, icon: typeof icon === "function" ? icon() : icon, off: btn.disabled, tip: btn.title, sep, run: (ev) => btn.onclick(ev) });
|
||||
cls.push([...btn.classList].filter((c) => c.startsWith("lib-") && c !== "lib-updall"));
|
||||
sep = false;
|
||||
}
|
||||
if (!acts.length) return;
|
||||
openRowMenu(b, acts);
|
||||
agentMenu?.box.querySelectorAll(".rm-item").forEach((it, i) => it.classList.add(...cls[i]));
|
||||
};
|
||||
return b;
|
||||
}
|
||||
|
||||
let foldAllBtn = null;
|
||||
function foldAllButton(box, all) {
|
||||
const b = button("", "lib-updall lib-foldall", () => {
|
||||
|
||||
@@ -841,3 +841,8 @@ body.window .lib-list .lib-row { --lib-indent: 38px; }
|
||||
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
|
||||
body.web .lib-editor :is(.lib-cmd, .lib-notein) { min-height: 44px; font-size: 16px; line-height: 22px; padding: 10px 9px; }
|
||||
}
|
||||
|
||||
/* the ⋯ at a list's heading (ryanpascal on Discord), and its Remove all red as the bar's was */
|
||||
#view-library .row-head .lib-barmore { display: inline-flex; align-items: center; justify-content: center; padding: 0 7px; }
|
||||
.row-menu .rm-item.lib-everyrm, .row-menu .rm-item.lib-everyrm svg { color: var(--red); }
|
||||
.row-menu .rm-item.lib-everyrm:not(:disabled):is(:hover, :focus) { background: var(--red-soft); }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// #475: one agent's skills, or MCP servers, were a chip on every row to turn
|
||||
// off, and an agent hidden on the Agents page had no chips at all, so what it
|
||||
// was given couldn't be taken out of it. "By agent", beside "In the library",
|
||||
// opens a sheet listing each agent with how many it has, a "Turn all on" and
|
||||
// was given couldn't be taken out of it. "By agent", under the ⋯ beside "In
|
||||
// the library" (library-bar-more), opens a sheet listing each agent with how many it has, a "Turn all on" and
|
||||
// a "Turn all off": each posts that one agent to …/agents-all, and the
|
||||
// page's chips follow. A hidden agent is listed while it has any (tagged
|
||||
// Hidden, with no Turn all on), and stays listed once emptied; turning a
|
||||
@@ -106,13 +106,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator("#view-library .lib-body:not(.lib-skel) .lib-row").first().waitFor();
|
||||
return page;
|
||||
};
|
||||
// By agent waits under the heading's ⋯: the menu opened, its item
|
||||
const byAgent = async (page, head) => {
|
||||
await press(page, page.locator(`#view-library ${head} .lib-barmore`));
|
||||
const it = page.locator(".row-menu .rm-item.lib-byagent");
|
||||
await it.waitFor();
|
||||
return it;
|
||||
};
|
||||
const row = (sheet, id) => sheet.locator(`.lib-byagent-row[data-agent="${id}"]`);
|
||||
|
||||
for (const lang of ["en", "zh"]) {
|
||||
await t.test(lang + ": skills", async () => {
|
||||
const w = words[lang], posts = [];
|
||||
const page = await open(lang, posts, "skills");
|
||||
const by = page.locator("#view-library .row-head button.lib-byagent");
|
||||
const by = await byAgent(page, ".lib-skillshead");
|
||||
assert.equal((await by.textContent()).trim(), w.by);
|
||||
assert.equal(await lit(page, "copilot"), 0, "the hidden agent has no chips");
|
||||
const before = await scrolled(page);
|
||||
@@ -154,8 +161,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await t.test(lang + ": servers", async () => {
|
||||
const w = words[lang], posts = [];
|
||||
const page = await open(lang, posts, "mcp");
|
||||
const by = page.locator("#view-library .row-head button.lib-byagent");
|
||||
const before = await scrolled(page);
|
||||
const by = await byAgent(page, ".lib-serverhead");
|
||||
await press(page, by);
|
||||
const sheet = page.locator("#modal .lib-byagent-sheet");
|
||||
await sheet.waitFor();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// emo172 (#443): with 30+ skills, turning them all on or off was a row's All
|
||||
// at a time. "Turn all on" beside "In the library" posts every agent shown
|
||||
// at a time. "Turn all on", under the ⋯ beside "In the library", posts every agent shown
|
||||
// that can take skills, with on, at once; "Turn all off" asks first in the
|
||||
// page (no window.confirm), and Cancel posts nothing; each is greyed when
|
||||
// there's nothing for it to do; the clicks scroll nothing; in English and
|
||||
@@ -53,6 +53,15 @@ const press = async (page, loc) => {
|
||||
const b = await loc.boundingBox();
|
||||
await page.mouse.click(b.x + b.width / 2, b.y + b.height / 2);
|
||||
};
|
||||
// the bar's Turn all on and off wait under its ⋯ (library-bar-more): the
|
||||
// menu opened, the item; the item is read again each time it is opened
|
||||
const item = async (page, cls) => {
|
||||
if (!(await page.locator(".row-menu").count())) await press(page, page.locator("#view-library .lib-skillshead .lib-barmore"));
|
||||
const it = page.locator(".row-menu .rm-item." + cls);
|
||||
await it.waitFor();
|
||||
return it;
|
||||
};
|
||||
const shut = async (page) => { if (await page.locator(".row-menu").count()) { await page.keyboard.press("Escape"); await page.locator(".row-menu").waitFor({ state: "detached" }); } };
|
||||
const lit = (page) => page.locator("#view-library .lib-ag.on[data-agent]").count();
|
||||
|
||||
const words = {
|
||||
@@ -88,24 +97,26 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await t.test(lang, async () => {
|
||||
const w = words[lang], posts = [];
|
||||
const page = await open(lang, posts);
|
||||
const on = page.locator("#view-library .row-head button.lib-everyon");
|
||||
const off = page.locator("#view-library .row-head button.lib-everyoff");
|
||||
assert.equal((await on.textContent()).trim(), w.on);
|
||||
assert.equal((await off.textContent()).trim(), w.off);
|
||||
assert.equal(await on.getAttribute("title"), w.tip);
|
||||
const on = () => item(page, "lib-everyon");
|
||||
const off = () => item(page, "lib-everyoff");
|
||||
assert.equal((await (await on()).textContent()).trim(), w.on);
|
||||
assert.equal((await (await off()).textContent()).trim(), w.off);
|
||||
assert.equal(await (await on()).getAttribute("title"), w.tip);
|
||||
await shut(page);
|
||||
assert.equal(await lit(page), 3);
|
||||
const before = await scrolled(page);
|
||||
|
||||
await press(page, on);
|
||||
await press(page, await on());
|
||||
await page.waitForTimeout(300);
|
||||
assert.deepEqual(posts, [{ agents: ["claude", "codex", "pi"], on: true }], "one post, for the agents that take skills");
|
||||
assert.equal(await lit(page), 9, "every chip of every row is lit");
|
||||
assert.equal((await page.locator("#status").textContent()).trim(), w.onDone);
|
||||
assert.equal(await on.isDisabled(), true, "nothing left to turn on");
|
||||
assert.equal(await (await on()).isDisabled(), true, "nothing left to turn on");
|
||||
await shut(page);
|
||||
assert.equal(await scrolled(page), before, "the click scrolls nothing");
|
||||
|
||||
// off asks in the page first; Cancel leaves everything
|
||||
await press(page, off);
|
||||
await press(page, await off());
|
||||
const sheet = page.locator("#modal .lib-editor");
|
||||
await sheet.waitFor();
|
||||
assert.equal((await sheet.locator(".ehead b").textContent()).trim(), w.ask);
|
||||
@@ -115,15 +126,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(posts.length, 1, "Cancel posts nothing");
|
||||
assert.equal(await lit(page), 9);
|
||||
|
||||
await press(page, off);
|
||||
await press(page, await off());
|
||||
await sheet.waitFor();
|
||||
await sheet.locator(".bar button.danger-fill").click();
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
assert.deepEqual(posts[1], { agents: ["claude", "codex", "pi"], on: false });
|
||||
assert.equal(await lit(page), 0, "no chip is lit");
|
||||
assert.equal((await page.locator("#status").textContent()).trim(), w.offDone);
|
||||
assert.equal(await off.isDisabled(), true, "nothing left to turn off");
|
||||
assert.equal(await on.isDisabled(), false);
|
||||
assert.equal(await (await off()).isDisabled(), true, "nothing left to turn off");
|
||||
assert.equal(await (await on()).isDisabled(), false);
|
||||
await shut(page);
|
||||
assert.equal(await scrolled(page), before, "the clicks scroll nothing");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,7 +139,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=library");
|
||||
await settingsDrawn(page); // rows found are the ones that stay (#1659)
|
||||
const check = page.locator("#view-library button.lib-updall", { hasText: w.check });
|
||||
// Check for updates waits under the Skills heading's ⋯ (library-bar-more)
|
||||
await page.locator("#view-library .lib-skillshead .lib-barmore").click();
|
||||
const check = page.locator(".row-menu .rm-item.lib-check", { hasText: w.check });
|
||||
await check.waitFor();
|
||||
await check.click();
|
||||
await page.waitForFunction(() => document.querySelector("#view-library .lib-unchecked"));
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// ryanpascal on Discord: Library › Skills' heading had a dozen buttons.
|
||||
// What is used now and then waits under ⋯, the app's own row menu: Check
|
||||
// for updates, Update all, Group again, Collapse all, Turn all on and off,
|
||||
// By agent, Manage n in magpie and Remove all. The bar keeps the order,
|
||||
// Select and the ⋯, on one line at a wide window, inside a narrow one. The
|
||||
// MCP servers' heading does the same. Each item is the bar's button: its
|
||||
// name and title, greyed when it was, and its click. Five languages, narrow
|
||||
// and wide; the API is faked.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const HOME = "/Users/me";
|
||||
const agent = (id, name, icon) => ({ id, name, icon, skills: `${HOME}/.${id}/skills`, mcp: `${HOME}/.${id}/mcp.json` });
|
||||
const gh = (repo, name, extra) => ({ name, kind: "github", source: `https://github.com/${repo}/tree/main/skills/${name}`, description: "d", agents: ["claude"], ...extra });
|
||||
const srv = (name) => ({ name, command: "npx", args: ["-y", name], agents: ["claude"] });
|
||||
|
||||
function server(lang, state, posts) {
|
||||
return async (route) => {
|
||||
const req = route.request();
|
||||
const url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (req.method() === "POST") posts.push(url.pathname);
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
|
||||
if (url.pathname === "/api/library") return json(state.lib);
|
||||
if (url.pathname === "/api/library/skills/check") return json({ ...state.lib, result: {} });
|
||||
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
if (url.host !== "magpie.test") return route.fulfill({ status: 404, body: "" });
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
|
||||
};
|
||||
}
|
||||
|
||||
const SKILL_MENU = ["Check for updates", "Update all", "Group again", "Collapse all", "Turn all on", "Turn all off", "By agent", "Manage {n} in magpie", "Remove all"];
|
||||
const SERVER_MENU = ["Turn all on", "Turn all off", "By agent", "Remove all"];
|
||||
const MOVED = ".lib-check, .lib-updallnow, .lib-regroup, .lib-foldall, .lib-everyon, .lib-everyoff, .lib-byagent, .lib-handover, .lib-everyrm";
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": the rarer actions of a Library list wait under ⋯", async (t) => {
|
||||
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) for (const width of [420, 1180]) {
|
||||
await t.test(lang + " " + width, async () => {
|
||||
const state = {
|
||||
lib: {
|
||||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
|
||||
agents: [agent("claude", "Claude Code", "claudecode-color"), agent("codex", "Codex", "openai")],
|
||||
instructions: { agents: [], sets: [] }, servers: [srv("alpha"), srv("beta")], foundServers: [], projects: [], problems: [],
|
||||
skills: [gh("acme/tools", "grill", { shared: true }), gh("acme/tools", "lint", { shared: true }), gh("zed/kit", "pdf"), gh("zed/kit", "tdd", { agents: ["claude", "codex"] })],
|
||||
foundSkills: [],
|
||||
},
|
||||
};
|
||||
const posts = [];
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });
|
||||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
page.on("dialog", (d) => { errors.push("a browser dialog: " + d.message()); d.dismiss(); });
|
||||
await page.route("**/*", server(lang, state, posts));
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
await page.locator("#view-library .lib-row.lib-skill").first().waitFor();
|
||||
const tr = (words, vars) => page.evaluate(([w, v]) => w.map((x) => t(x, v)), [words, vars]);
|
||||
|
||||
const check = async (head, menu, vars) => {
|
||||
// the bar: the order, Select and ⋯, none of the moved buttons
|
||||
assert.equal(await head.locator(MOVED).count(), 0, "a moved button is still on the bar");
|
||||
await head.locator(".lib-select").waitFor();
|
||||
const more = head.locator("button.lib-barmore");
|
||||
assert.equal(await more.getAttribute("aria-label"), (await tr(["More"]))[0]);
|
||||
const tops = await head.locator(":scope > :not(.label):not(.grow)").evaluateAll((els) => els.filter((e) => e.offsetParent).map((e) => Math.round(e.getBoundingClientRect().top)));
|
||||
if (width >= 1180) assert.equal(new Set(tops).size, 1, "the bar is one line: " + tops);
|
||||
const hb = await head.boundingBox(), mb = await more.boundingBox();
|
||||
assert.ok(mb.x + mb.width <= hb.x + hb.width + 0.5, "⋯ is inside the heading");
|
||||
|
||||
await more.click();
|
||||
const box = page.locator(".row-menu");
|
||||
await box.waitFor();
|
||||
const names = await box.locator(".rm-item .rm-name").allTextContents();
|
||||
assert.deepEqual(names, await tr(menu, vars));
|
||||
const b = await box.boundingBox();
|
||||
assert.ok(b.x >= 0 && b.y >= 0 && b.x + b.width <= width + 0.5 && b.y + b.height <= 760.5, "the menu is inside the window");
|
||||
// a second click on ⋯ closes it
|
||||
await more.click();
|
||||
await box.waitFor({ state: "detached" });
|
||||
return more;
|
||||
};
|
||||
|
||||
const skills = page.locator("#view-library .lib-skillshead");
|
||||
const more = await check(skills, SKILL_MENU, { n: 2 });
|
||||
// every skill has every agent: Turn all on is greyed, as its button was
|
||||
await more.click();
|
||||
await page.locator(".row-menu .rm-item.lib-check").waitFor();
|
||||
assert.equal(await page.locator(".row-menu .rm-item.lib-everyon").isDisabled(), false);
|
||||
assert.equal(await page.locator(".row-menu .rm-item.lib-everyrm").getAttribute("title"), (await tr(["Take all {n} skills out of the library"], { n: 4 }))[0]);
|
||||
// Turn all off asks first, in the page; Cancel posts nothing
|
||||
await page.locator(".row-menu .rm-item.lib-everyoff").click();
|
||||
const sheet = page.locator("#modal .lib-editor");
|
||||
await sheet.waitFor();
|
||||
await page.keyboard.press("Escape");
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
// Check for updates asks, once
|
||||
await more.click();
|
||||
await page.locator(".row-menu .rm-item.lib-check").click();
|
||||
await page.waitForFunction(() => !document.querySelector("#view-library .lib-skillshead .lib-check.busy"));
|
||||
assert.deepEqual(posts, ["/api/library/skills/check"]);
|
||||
|
||||
const mcp = (await tr(["MCP servers"]))[0];
|
||||
await page.locator(":is(#view-library .lib-tabs .opt, .nav-s):visible", { hasText: mcp }).click(); // the tabs, or the side nav's at a wide window
|
||||
const servers = page.locator("#view-library .lib-serverhead");
|
||||
await servers.waitFor();
|
||||
await check(servers, SERVER_MENU, {});
|
||||
|
||||
assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "the page scrolls sideways");
|
||||
assert.deepEqual(errors, []);
|
||||
await ctx.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,7 +118,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// By agent: WorkBuddy as Not installed, nothing to turn on, its one
|
||||
// skill to take out
|
||||
const sheet = page.locator("#modal .lib-editor");
|
||||
await v.locator(".lib-byagent").first().click();
|
||||
await v.locator(".lib-skillshead .lib-barmore").click(); // By agent waits under ⋯ (library-bar-more)
|
||||
await page.locator(".row-menu .rm-item.lib-byagent").click();
|
||||
await sheet.waitFor();
|
||||
const ids = await sheet.locator(".lib-byagent-row").evaluateAll((rs) => rs.map((r) => r.dataset.agent));
|
||||
assert.deepEqual(ids, ["claude", "codex", "workbuddy"]);
|
||||
|
||||
@@ -104,7 +104,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const errors = [], st = {};
|
||||
const { ctx, page, v } = await open(lang, width, st, errors);
|
||||
await v.locator(".lib-body:not(.lib-skel) .lib-row").first().waitFor();
|
||||
await v.locator(".row-head button.lib-updall", { hasText: w.check }).click();
|
||||
await v.locator(".lib-skillshead .lib-barmore").click(); // Check for updates is under ⋯ (library-bar-more)
|
||||
await page.locator(".row-menu .rm-item.lib-check", { hasText: w.check }).click();
|
||||
await page.waitForFunction(() => !document.querySelector("#view-library .lib-updall.busy, #view-library .lib-updall[disabled]"));
|
||||
await page.waitForTimeout(200);
|
||||
assert.deepEqual(errors, []);
|
||||
@@ -128,7 +129,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const errors = [], st = { undrawable: true };
|
||||
const { ctx, page, v } = await open(lang, width, st, errors);
|
||||
await v.locator(".lib-body:not(.lib-skel) .lib-row").first().waitFor();
|
||||
await v.locator(".row-head button.lib-updall", { hasText: w.check }).click();
|
||||
await v.locator(".lib-skillshead .lib-barmore").click(); // Check for updates is under ⋯ (library-bar-more)
|
||||
await page.locator(".row-menu .rm-item.lib-check", { hasText: w.check }).click();
|
||||
await page.waitForTimeout(500);
|
||||
assert.deepEqual(errors, [], "no uncaught error");
|
||||
const s = page.locator("#status");
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// order, each under an "In the library" heading of its own, so with both
|
||||
// the page showed the heading twice; turning every server on or off, or
|
||||
// removing them, was a chip or a row at a time. It now has the skills
|
||||
// page's: one heading holding the order, Select, Turn all on, Turn all off,
|
||||
// By agent and Remove all. Turn all on posts every agent shown (not a
|
||||
// page's: one heading holding the order, Select and a ⋯ menu with Turn all
|
||||
// on, Turn all off, By agent and Remove all (library-bar-more). Turn all on posts every agent shown (not a
|
||||
// hidden one) to servers/agents-all; Turn all off asks first, in the page,
|
||||
// and Cancel posts nothing. Select puts a box on each row, a row's click
|
||||
// ticks it rather than opening the editor, and the bar's chips post the
|
||||
@@ -138,8 +138,19 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await v.locator(".lib-server").first().waitFor();
|
||||
// the state can come after the list: the hidden Copilot CLI is then
|
||||
// left out once it has, from the count and from Turn all on
|
||||
await page.waitForFunction((tip) => document.querySelector("#view-library .lib-serverhead .lib-everyon")?.title === tip,
|
||||
w("Give every server to all {n} agents, each the ones it can reach", { n: 3 }));
|
||||
// the heading's ⋯ menu, opened afresh for each look: its item
|
||||
const menu = page.locator(".row-menu");
|
||||
const shut = async () => { if (await menu.count()) { await page.keyboard.press("Escape"); await menu.waitFor({ state: "detached" }); } };
|
||||
const item = async (cls) => {
|
||||
await shut();
|
||||
await press(page, v.locator(".lib-serverhead .lib-barmore"));
|
||||
const it = menu.locator(".rm-item." + cls);
|
||||
await it.waitFor();
|
||||
return it;
|
||||
};
|
||||
const tipNow = w("Give every server to all {n} agents, each the ones it can reach", { n: 3 });
|
||||
for (let i = 0; i < 40 && await (await item("lib-everyon")).getAttribute("title") !== tipNow; i++) await page.waitForTimeout(100);
|
||||
await shut();
|
||||
const row = (name) => v.locator(".lib-server").filter({ has: page.locator(".name", { hasText: new RegExp("^" + name) }) });
|
||||
const agentsOf = (name) => state.servers.find((s) => s.name === name)?.agents;
|
||||
|
||||
@@ -148,23 +159,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(heads.filter((x) => x === w("In the library")), [w("In the library")], "one In the library heading: " + heads);
|
||||
const head = v.locator(".row-head.lib-serverhead");
|
||||
assert.equal((await head.locator(".lib-select").textContent()).trim(), w("Select"));
|
||||
assert.equal((await head.locator(".lib-everyon").textContent()).trim(), w("Turn all on"));
|
||||
assert.equal((await head.locator(".lib-everyoff").textContent()).trim(), w("Turn all off"));
|
||||
assert.equal((await head.locator(".lib-byagent").textContent()).trim(), w("By agent"));
|
||||
assert.equal((await head.locator(".lib-everyrm").textContent()).trim(), w("Remove all"));
|
||||
assert.equal(await head.locator(".lib-everyon").getAttribute("title"), w("Give every server to all {n} agents, each the ones it can reach", { n: 3 }));
|
||||
assert.equal(await head.locator(".lib-everyrm").getAttribute("title"), w("Take all {n} servers out of the library", { n: 3 }));
|
||||
assert.equal((await (await item("lib-everyon")).textContent()).trim(), w("Turn all on"));
|
||||
assert.equal((await menu.locator(".lib-everyoff").textContent()).trim(), w("Turn all off"));
|
||||
assert.equal((await menu.locator(".lib-byagent").textContent()).trim(), w("By agent"));
|
||||
assert.equal((await menu.locator(".lib-everyrm").textContent()).trim(), w("Remove all"));
|
||||
assert.equal(await menu.locator(".lib-everyon").getAttribute("title"), tipNow);
|
||||
assert.equal(await menu.locator(".lib-everyrm").getAttribute("title"), w("Take all {n} servers out of the library", { n: 3 }));
|
||||
await shut();
|
||||
assert.deepEqual(await sideways(page), [], "sideways scroll with the heading");
|
||||
|
||||
// Turn all on: every agent shown, the hidden Copilot CLI left alone
|
||||
await press(page, head.locator(".lib-everyon"));
|
||||
await press(page, await item("lib-everyon"));
|
||||
await page.locator("#status").filter({ hasText: w("{n} servers are on for all {m} agents", { n: 3, m: 3 }) }).waitFor();
|
||||
assert.deepEqual(posts.shift(), { what: "servers/agents-all", body: { agents: ["claude", "codex", "gemini"], on: true } });
|
||||
assert.deepEqual(agentsOf("web"), ["claude", "gemini"], "SSE is no server for Codex");
|
||||
await page.waitForFunction(() => document.querySelector("#view-library .lib-serverhead .lib-everyon")?.disabled);
|
||||
assert.equal(await (await item("lib-everyon")).isDisabled(), true);
|
||||
await shut();
|
||||
|
||||
// Turn all off asks first; Cancel posts nothing
|
||||
await press(page, v.locator(".lib-serverhead .lib-everyoff"));
|
||||
await press(page, await item("lib-everyoff"));
|
||||
const sheet = page.locator("#modal .lib-editor");
|
||||
await sheet.waitFor();
|
||||
await settled(page);
|
||||
@@ -174,7 +187,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
await page.waitForTimeout(150);
|
||||
assert.deepEqual(posts, [], "Cancel posts nothing");
|
||||
await press(page, v.locator(".lib-serverhead .lib-everyoff"));
|
||||
await press(page, await item("lib-everyoff"));
|
||||
await sheet.waitFor();
|
||||
await settled(page);
|
||||
await sheet.locator(".bar button.danger-fill").click();
|
||||
@@ -239,7 +252,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal((await v.locator(".lib-serverhead .lib-select").textContent()).trim(), w("Select"));
|
||||
|
||||
// Remove all asks first, saying what goes; Cancel posts nothing
|
||||
await press(page, v.locator(".lib-serverhead .lib-everyrm"));
|
||||
await press(page, await item("lib-everyrm"));
|
||||
await sheet.waitFor();
|
||||
await settled(page);
|
||||
assert.equal((await sheet.locator(".ehead b").textContent()).trim(), w("Remove all {n} servers?", { n: 3 }));
|
||||
@@ -256,7 +269,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(posts, [], "Cancel posts nothing");
|
||||
assert.equal(await v.locator(".lib-server").count(), 3);
|
||||
|
||||
await press(page, v.locator(".lib-serverhead .lib-everyrm"));
|
||||
await press(page, await item("lib-everyrm"));
|
||||
await sheet.waitFor();
|
||||
await settled(page);
|
||||
const go = sheet.locator(".bar button.danger-fill");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// #449: taking every skill out of the library was a row's Remove at a time.
|
||||
// "Remove all" beside "Turn all on/off" is red, asks first in the page (no
|
||||
// "Remove all", last in the heading's ⋯ menu (library-bar-more), is red,
|
||||
// asks first in the page (no
|
||||
// window.confirm) saying which agents lose them and where their folders go,
|
||||
// and Cancel posts nothing; confirming posts every skill's name at once;
|
||||
// the clicks scroll nothing; in English and Chinese. No backend: the API is
|
||||
@@ -88,13 +89,20 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await t.test(lang, async () => {
|
||||
const w = words[lang], posts = [];
|
||||
const page = await open(lang, posts);
|
||||
const rm = page.locator("#view-library .row-head button.lib-everyrm");
|
||||
// the item under the heading's ⋯, the menu opened for each click
|
||||
const item = async () => {
|
||||
await press(page, page.locator("#view-library .lib-skillshead .lib-barmore"));
|
||||
const it = page.locator(".row-menu .rm-item.lib-everyrm");
|
||||
await it.waitFor();
|
||||
return it;
|
||||
};
|
||||
const rm = await item();
|
||||
assert.equal((await rm.textContent()).trim(), w.rm);
|
||||
assert.equal(await rm.getAttribute("title"), w.tip);
|
||||
const red = await page.evaluate(() => getComputedStyle(document.body).getPropertyValue("--red").trim());
|
||||
const color = await rm.evaluate((b) => getComputedStyle(b).color);
|
||||
const probe = await page.evaluate((c) => { const d = document.createElement("i"); d.style.color = c; document.body.append(d); const v = getComputedStyle(d).color; d.remove(); return v; }, red);
|
||||
assert.equal(color, probe, "the button is red");
|
||||
assert.equal(color, probe, "the item is red");
|
||||
assert.equal(await rows(page), 3);
|
||||
const before = await scrolled(page);
|
||||
|
||||
@@ -114,7 +122,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(posts, [], "Cancel posts nothing");
|
||||
assert.equal(await rows(page), 3);
|
||||
|
||||
await press(page, rm);
|
||||
await press(page, await item());
|
||||
await sheet.waitFor();
|
||||
const go = sheet.locator(".bar button.danger-fill");
|
||||
assert.equal((await go.textContent()).trim(), w.go);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// #1862 (WardLu): Library › Skills has Collapse all / Expand all beside the
|
||||
// sort, for a library of many groups. Collapse all folds every group the
|
||||
// #1862 (WardLu): Library › Skills has Collapse all / Expand all in its
|
||||
// heading's ⋯ menu (library-bar-more), for a library of many groups. Collapse all folds every group the
|
||||
// list shows and keeps it, as a click on each heading would; the button
|
||||
// then says Expand all, which opens them again. While filtering it folds
|
||||
// or opens only the groups the filter shows, till the filter changes, and
|
||||
// leaves the kept folds alone. It changes nothing an agent has, so it
|
||||
// sends nothing, and a click on it doesn't move the page. With one group
|
||||
// (A→Z, or a filter that one group matches) there is nothing to fold all,
|
||||
// and it isn't shown. Five languages, narrow and wide; the API is faked.
|
||||
// and it isn't in the menu. Five languages, narrow and wide; the API is faked.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -84,7 +84,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
const heads = page.locator("#view-library .lib-grouphead");
|
||||
await heads.first().waitFor();
|
||||
const btn = page.locator("#view-library .lib-skillshead .lib-foldall");
|
||||
// the item in the heading's ⋯ menu, opened for each look and click
|
||||
const more = page.locator("#view-library .lib-skillshead .lib-barmore");
|
||||
const menu = page.locator(".row-menu");
|
||||
const shut = async () => { if (await menu.count()) { await page.keyboard.press("Escape"); await menu.waitFor({ state: "detached" }); } };
|
||||
const item = async () => { await shut(); await more.click(); await menu.waitFor(); return menu.locator(".rm-item.lib-foldall"); };
|
||||
const btn = {
|
||||
isVisible: async () => { const n = await (await item()).count(); await shut(); return n > 0; },
|
||||
textContent: async () => { const v = await (await item()).textContent(); await shut(); return v; },
|
||||
click: async () => (await item()).click(),
|
||||
boundingBox: async () => { const b = await (await item()).boundingBox(); await shut(); return b; },
|
||||
};
|
||||
const openOf = () => heads.evaluateAll((hs) => hs.map((h) => [h.querySelector(".name").textContent, h.classList.contains("open")]));
|
||||
const rows = () => page.locator("#view-library .lib-row.lib-skill").count();
|
||||
// how far anything on the page is scrolled down
|
||||
@@ -97,7 +107,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await btn.isVisible(), true);
|
||||
assert.equal((await btn.textContent()).trim(), collapse);
|
||||
const box = await btn.boundingBox();
|
||||
assert.ok(box.x >= 0 && box.x + box.width <= width, "the button is inside the window");
|
||||
assert.ok(box.x >= 0 && box.x + box.width <= width, "the item is inside the window");
|
||||
|
||||
// Collapse all: every group folded, kept, and the button turns over
|
||||
assert.equal(await scrolled(), 0);
|
||||
|
||||
@@ -92,8 +92,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal((await ssh.textContent()).trim(), SSH);
|
||||
assert.equal(await row("pdf").locator(".lib-rowacts button.lib-icon").first().getAttribute("title"), w.upd);
|
||||
assert.equal((await row("review").locator(".lib-rowacts button.lib-icon").first().getAttribute("title")).split("\n")[0], w.updSSH);
|
||||
const check = v.locator(".row-head button.lib-updall", { hasText: w.check });
|
||||
// under the heading's ⋯ (library-bar-more)
|
||||
await v.locator(".lib-skillshead .lib-barmore").click();
|
||||
const check = page.locator(".row-menu .rm-item.lib-check", { hasText: w.check });
|
||||
assert.equal(await check.count(), 1, "Check for updates is offered");
|
||||
await page.keyboard.press("Escape");
|
||||
await page.locator(".row-menu").waitFor({ state: "detached" });
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), true, "no sideways scroll");
|
||||
|
||||
await row("pdf").locator(".lib-rowacts button.lib-icon").first().click();
|
||||
|
||||
@@ -154,7 +154,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.route("**/*", server("en", posts, st));
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
const all = page.locator("#view-library .lib-skillshead button.lib-handover");
|
||||
// Manage n in magpie waits under the heading's ⋯ (library-bar-more)
|
||||
const more = page.locator("#view-library .lib-skillshead .lib-barmore");
|
||||
await more.click();
|
||||
const all = page.locator(".row-menu .rm-item.lib-handover");
|
||||
await all.waitFor();
|
||||
assert.equal((await all.textContent()).trim(), w.all);
|
||||
await all.click();
|
||||
@@ -165,8 +168,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await sheet.locator(".bar button.primary").click();
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
assert.deepEqual(posts, [{ what: "hand-over", body: { names: ["orca", "grill"] } }]);
|
||||
await all.waitFor({ state: "detached" });
|
||||
assert.equal((await page.locator("#status").textContent()).trim(), w.doneAll);
|
||||
// none left kept there: the menu has no Manage n any more
|
||||
await more.click();
|
||||
await page.locator(".row-menu").waitFor();
|
||||
assert.equal(await page.locator(".row-menu .rm-item.lib-handover").count(), 0);
|
||||
await ctx.close();
|
||||
});
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
@@ -94,7 +94,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const v = page.locator("#view-library");
|
||||
assert.equal(await v.locator(".lib-newskill").count(), 0, "nothing offered before a check");
|
||||
|
||||
await v.locator(".row-head button.lib-updall", { hasText: w.check }).click();
|
||||
// Check for updates waits under the heading's ⋯ (library-bar-more)
|
||||
await v.locator(".lib-skillshead .lib-barmore").click();
|
||||
await page.locator(".row-menu .rm-item.lib-check", { hasText: w.check }).click();
|
||||
await v.locator(".lib-newskill").first().waitFor();
|
||||
assert.equal((await page.locator("#status").textContent()).trim(), w.said);
|
||||
assert.equal((await v.locator(".lib-newhead .label").textContent()).trim(), w.head);
|
||||
@@ -168,7 +170,8 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
await page.locator("#view-library .lib-body:not(.lib-skel) .lib-row").first().waitFor();
|
||||
const v = page.locator("#view-library");
|
||||
const check = v.locator(".row-head button.lib-updall", { hasText: w.check });
|
||||
await v.locator(".lib-skillshead .lib-barmore").click();
|
||||
const check = page.locator(".row-menu .rm-item.lib-check", { hasText: w.check });
|
||||
assert.equal(await check.getAttribute("title"), w.tip);
|
||||
await check.click();
|
||||
await v.locator(".lib-newskill").first().waitFor();
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// Group again (White Immortal on Discord: of mattpocock/skills added a while
|
||||
// ago only 20 were grouped, the rest under On this computer, and nothing
|
||||
// to group them again by). The Skills head has Group again, which asks
|
||||
// to group them again by). The Skills head's ⋯ menu has Group again
|
||||
// (library-bar-more), which asks
|
||||
// magpie to trace the skills to their repositories once more and draws
|
||||
// the page it answers with: the 18 join the 20, and the status says how
|
||||
// many did. Every language, at a narrow width too, in Chromium and WebKit;
|
||||
// many did. While it works, the bar shows Grouping… in its place. Every language, at a narrow width too, in Chromium and WebKit;
|
||||
// the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
@@ -90,18 +91,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.match((await heads())[0], /20/);
|
||||
assert.match((await heads())[1], /18/);
|
||||
|
||||
const b = v.locator(".lib-skillshead .lib-regroup");
|
||||
// under the heading's ⋯
|
||||
const item = async () => {
|
||||
await v.locator(".lib-skillshead .lib-barmore").click();
|
||||
const it = page.locator(".row-menu .rm-item.lib-regroup");
|
||||
await it.waitFor();
|
||||
return it;
|
||||
};
|
||||
const b = await item();
|
||||
assert.equal((await b.textContent()).trim(), w.button);
|
||||
assert.ok((await b.getAttribute("title")).length > 0);
|
||||
// the button is on the page at a narrow width, nothing wider than it
|
||||
// the item is on the page at a narrow width, nothing wider than it
|
||||
const box = await b.boundingBox();
|
||||
assert.ok(box && box.x >= 0 && box.x + box.width <= width, `button at ${JSON.stringify(box)} in ${width}`);
|
||||
assert.ok(box && box.x >= 0 && box.x + box.width <= width, `item at ${JSON.stringify(box)} in ${width}`);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth), true);
|
||||
|
||||
await b.click();
|
||||
// busy while magpie fetches the repositories
|
||||
await page.waitForFunction(() => document.querySelector(".lib-regroup")?.disabled);
|
||||
assert.equal((await v.locator(".lib-regroup").textContent()).trim(), w.busy);
|
||||
// busy on the bar while magpie fetches the repositories
|
||||
await page.waitForFunction(() => document.querySelector("#view-library .lib-skillshead .lib-regroup")?.disabled);
|
||||
assert.equal((await v.locator(".lib-skillshead .lib-regroup").textContent()).trim(), w.busy);
|
||||
state.answer();
|
||||
await page.waitForFunction((text) => document.querySelector("#status").textContent.trim() === text, w.done).catch(async () => {
|
||||
assert.equal((await page.locator("#status").textContent()).trim(), w.done);
|
||||
@@ -109,8 +117,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// one group now, all 38 of it
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-library .lib-grouphead").length === 0);
|
||||
await page.waitForFunction(() => document.querySelectorAll("#view-library .lib-skill").length === 38);
|
||||
assert.equal((await v.locator(".lib-regroup").textContent()).trim(), w.button);
|
||||
assert.equal(await v.locator(".lib-regroup").isDisabled(), false);
|
||||
assert.equal(await v.locator(".lib-skillshead .lib-regroup").count(), 0, "done, it is back under ⋯");
|
||||
const again = await item();
|
||||
assert.equal((await again.textContent()).trim(), w.button);
|
||||
assert.equal(await again.isDisabled(), false);
|
||||
assert.deepEqual(posts, ["POST"]);
|
||||
assert.deepEqual(errors, []);
|
||||
await ctx.close();
|
||||
|
||||
Reference in New Issue
Block a user