plugins: Discover is one market, with this week's picks on top
The owner asked for one market instead of three (magpie's community, other npm authors and repositories tagged magpie-plugin on GitHub) and approved the mockup: every plugin is the same card, its source said under its name, a strip picks the kind and a menu the source. The top is the week's picks: one a day from the community's most downloaded not installed yet, the most downloaded and the most starred. A search looks through every source at once, most used first. GitHub's slower answer shows a word that it is being asked, and a failed ask a quiet line with another go. The GUI tests that named the three sections now find the cards by source. plugin-manual-float picks Subscriptions so all 40 cards draw (Discover's shelves cap at 6). plugin-github waits for WebKit's wheel scroll to come to rest after reaching a card: it went on after the last wheel, and the scroll that was measured as the click's was its own (logged before, settled, open and closed: it moved before the click, never after). Run at 563b3dd92, the pushed head's tree (only messages changed since), on origin/main40fbec705: - mote: gofmt -l internal/gui empty; go vet ./internal/gui, GOOS=linux go vet -tags nogui, GOOS=windows go vet; go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok. go test ./internal/gui ./internal/plugin ok (TestCoreScriptBudget in it). - mote GUI, plugin*, old-webkit, market*, builtins, skill-edit, i18n*, gui-*, about*, agent-plugin* files: 1,283 ok, 50 not ok, in plugin-move-unserved (#4410), market-have (#5997), old-webkit's app.css :has() (#5919), gui-ja's {model} (#5943), plugin-signin-no-url (#5938), plugin-signed-out-account (#5998) and plugin-card-update once; each red the same alone at origin/main90f9f01a2, where plugin-card-update was red too. - Rebased onto459405960(c4da9a97d's title-bar drag in app.js and app.css among it): gofmt, go vet ./internal/gui and the Budget and Script tests of internal/gui again: ok. - Before the rebase (on783cd0f84): the whole GUI suite on magpie-desktop (WSL), its 132 red files again beside main: 95 red the same on main (#4600, commented), key-replace red 3 of 3 alone on main too; old-webkit's color-mix and plugin-github were this change's and are fixed; library-hooks, -items, -loading and -subagents red the same alone on main (#5997). Not tried: the real app; screenshots come from the GUI test pages.
This commit is contained in:
@@ -1,21 +1,19 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// GitHub answers after the rest of the plugins page, seconds after on a
|
||||
// slow line, and the Unofficial section wasn't drawn until it did, so it
|
||||
// read as there being no unofficial plugins (yetone: 当还没加载完的时候,
|
||||
// 压根就不显示,会让那些网慢的用户以为没有非官方插件). While
|
||||
// /api/plugins/github is held here, Discover shows the section in its
|
||||
// place, before the field, with its head, a word that it is looking and
|
||||
// cards still to come; let go, its cards come in where those were and the
|
||||
// word goes. A search while it waits shows the same. When the ask fails,
|
||||
// the section says so with Try again, which asks again. magpie answering
|
||||
// with an error beside the list (GitHub unreachable from the reader's
|
||||
// desktop: till on Discord, where the section just wasn't there) is said
|
||||
// too: with no list, in the section's place with why and Try again, which
|
||||
// has magpie ask GitHub at once (?again=1); with the cards it could give,
|
||||
// a line over them saying how many more couldn't be read, and why. English, Chinese,
|
||||
// Japanese and German, wide and 440px, in Chromium and WebKit; nothing
|
||||
// scrolls on a click. MAGPIE_WAIT_ASSETS names an older assets directory,
|
||||
// to see this fail on the code before it.
|
||||
// slow line, and its plugins weren't shown until it did, so it read as
|
||||
// there being no unofficial plugins (yetone: 当还没加载完的时候,压根就不显示,
|
||||
// 会让那些网慢的用户以为没有非官方插件). While /api/plugins/github is held
|
||||
// here, Discover's browse bar says it is looking on GitHub, and picking
|
||||
// the GitHub origin shows cards still to come; let go, its cards come in
|
||||
// and the word goes. A search while it waits says the same. When the ask
|
||||
// fails, a line says so with Try again, which asks again. magpie
|
||||
// answering with an error beside the list (GitHub unreachable from the
|
||||
// reader's desktop: till on Discord) is said too: with no list, why and
|
||||
// Try again, which has magpie ask GitHub at once (?again=1); with the
|
||||
// cards it could give, how many more couldn't be read, and why. English,
|
||||
// Chinese, Japanese and German, wide and 440px, in Chromium and WebKit;
|
||||
// nothing scrolls on a click. MAGPIE_WAIT_ASSETS names an older assets
|
||||
// directory, to see this fail on the code before it.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
@@ -99,100 +97,99 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const view = page.locator("#view-plugins");
|
||||
await view.waitFor({ state: "visible" });
|
||||
await view.locator(".pm-card", { hasText: "Zed" }).waitFor();
|
||||
const sec = view.locator(".pm-sec", { has: page.locator("h3", { hasText: w.section }) });
|
||||
return { ctx, page, view, sec, errors };
|
||||
return { ctx, page, view, errors };
|
||||
};
|
||||
// the unofficial cards: each says it is unreviewed
|
||||
const ghCards = (view) => view.locator(".pm-card:not(.ghost)", { has: view.page().locator(".pm-by .pm-chip.warn") });
|
||||
const scrolls = (page) => page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join());
|
||||
|
||||
// held: the section is there, before the field, looking
|
||||
// held: the bar says it is looking
|
||||
const wait = held();
|
||||
const { ctx, page, view, sec, errors } = await open([wait]);
|
||||
const { ctx, page, view, errors } = await open([wait]);
|
||||
t.after(() => ctx.close());
|
||||
await sec.waitFor();
|
||||
const order = await view.locator(".pm-body > *").evaluateAll((es) => es.map((e) => e.className));
|
||||
assert.ok(order.findIndex((c) => c.includes("pm-ghsec")) < order.findIndex((c) => c.includes("pm-manual")), "before the field: " + order);
|
||||
assert.equal(await sec.getAttribute("aria-busy"), "true");
|
||||
assert.match(await sec.locator(".pm-sechead > span").first().innerText(), /magpie-plugin/);
|
||||
const look = sec.locator(".pm-ghlook");
|
||||
const look = view.locator(".pm-bar .pm-ghlook");
|
||||
await look.waitFor();
|
||||
assert.equal((await look.innerText()).trim(), w.look);
|
||||
assert.equal(await look.getAttribute("role"), "status");
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
||||
// the GitHub origin picked: cards still to come
|
||||
await view.locator(".pm-bar .pm-pop").first().click();
|
||||
await page.locator(".proto-menu .pm-item", { hasText: w.section }).click();
|
||||
await view.locator(".pm-card.ghost").first().waitFor();
|
||||
assert.equal(await view.locator(".pm-card.ghost").count(), 3);
|
||||
// the light moves: a ghost's bar is animated, and each card a beat after the last
|
||||
const anim = await sec.locator(".pm-card.ghost .sk").evaluateAll((es) => es.map((e) => [getComputedStyle(e).animationName, getComputedStyle(e).animationDelay]));
|
||||
const anim = await view.locator(".pm-card.ghost .sk").evaluateAll((es) => es.map((e) => [getComputedStyle(e).animationName, getComputedStyle(e).animationDelay]));
|
||||
assert.ok(anim.every(([n]) => n === "pm-sheen"), "sheen: " + JSON.stringify(anim));
|
||||
assert.notEqual(anim[0][1], anim.at(-1)[1], "a beat apart");
|
||||
// a ghost is laid out as a card: nothing spills at this width
|
||||
for (const g of await sec.locator(".pm-card.ghost").all()) {
|
||||
for (const g of await view.locator(".pm-card.ghost").all()) {
|
||||
assert.ok(await g.evaluate((e) => e.scrollWidth <= e.clientWidth + 1 && e.getBoundingClientRect().height > 70), "ghost fits");
|
||||
}
|
||||
await shot(sec, `wait-${engine}-${lang}-${width}`);
|
||||
await shot(view, `wait-${engine}-${lang}-${width}`);
|
||||
|
||||
// a search while it waits: the same section, waiting
|
||||
// a search while it waits: still looking
|
||||
const q = view.locator(".pm-head .pm-find input");
|
||||
await q.fill("claude");
|
||||
await sec.locator(".pm-ghlook").waitFor();
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 3);
|
||||
await view.locator(".pm-ghlook").waitFor();
|
||||
await q.fill("");
|
||||
await sec.locator(".pm-ghlook").waitFor();
|
||||
await look.waitFor();
|
||||
|
||||
// let go: its cards in the ghosts' place, the word gone
|
||||
wait.go();
|
||||
await sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
assert.equal(await sec.locator(".pm-card.ghost").count(), 0);
|
||||
assert.equal(await sec.locator(".pm-ghlook").count(), 0);
|
||||
assert.equal(await sec.getAttribute("aria-busy"), null);
|
||||
assert.deepEqual(await sec.locator(".pm-card .pm-name b").allInnerTexts(), ["opencode-claude-auth", "agy-staff"]);
|
||||
await ghCards(view).first().waitFor();
|
||||
assert.equal(await view.locator(".pm-card.ghost").count(), 0);
|
||||
assert.equal(await view.locator(".pm-ghlook").count(), 0);
|
||||
assert.deepEqual((await ghCards(view).locator(".pm-name b").allInnerTexts()).sort(), ["agy-staff", "opencode-claude-auth"]);
|
||||
await page.waitForFunction(() => !document.querySelector(".pm-arrive"));
|
||||
await shot(sec, `came-${engine}-${lang}-${width}`);
|
||||
await shot(view, `came-${engine}-${lang}-${width}`);
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
// failed: said so, and Try again asks again
|
||||
const again = held();
|
||||
const f = await open(["fail", again]);
|
||||
t.after(() => f.ctx.close());
|
||||
await f.sec.locator(".pm-ghnone").waitFor();
|
||||
assert.match(await f.sec.locator(".pm-ghnone").innerText(), w.failed);
|
||||
assert.equal(await f.sec.locator(".pm-card").count(), 0);
|
||||
await shot(f.sec, `failed-${engine}-${lang}-${width}`);
|
||||
const before = await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join());
|
||||
await f.sec.getByRole("button", { name: w.again }).click();
|
||||
await f.sec.locator(".pm-ghlook").waitFor();
|
||||
assert.equal(await f.page.evaluate(() => [window.scrollY, ...[...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0).map((e) => (e.id || e.className) + ":" + e.scrollTop)].join()), before, "nothing scrolls on Try again");
|
||||
const fLine = f.view.locator(".pm-ghwarn");
|
||||
await fLine.waitFor();
|
||||
assert.match(await fLine.innerText(), w.failed);
|
||||
assert.equal(await ghCards(f.view).count(), 0);
|
||||
await shot(f.view, `failed-${engine}-${lang}-${width}`);
|
||||
const before = await scrolls(f.page);
|
||||
await fLine.getByRole("button", { name: w.again }).click();
|
||||
await f.view.locator(".pm-bar .pm-ghlook").waitFor();
|
||||
assert.equal(await scrolls(f.page), before, "nothing scrolls on Try again");
|
||||
again.go();
|
||||
await f.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
assert.equal(await f.sec.locator(".pm-ghnone").count(), 0);
|
||||
await ghCards(f.view).first().waitFor();
|
||||
assert.equal(await f.view.locator(".pm-ghwarn").count(), 0);
|
||||
assert.deepEqual(f.errors, []);
|
||||
|
||||
// magpie answers, but GitHub couldn't give it the list: said in
|
||||
// the section's place with why, never the section gone
|
||||
// magpie answers, but GitHub couldn't give it the list: said
|
||||
// with why
|
||||
const why = 'http://raw.githubusercontent.com/a/b/main/package.json: Get "https://raw.githubusercontent.com/a/b/main/package.json": dial tcp: i/o timeout';
|
||||
const urls = [];
|
||||
const later = held();
|
||||
const e = await open([{ json: { repos: [], topic: "magpie-plugin", error: why, missing: 12 } }, later], urls);
|
||||
t.after(() => e.ctx.close());
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
const said = await e.sec.locator(".pm-ghnone").innerText();
|
||||
const eLine = e.view.locator(".pm-ghwarn");
|
||||
await eLine.waitFor();
|
||||
const said = await eLine.innerText();
|
||||
assert.match(said, w.none);
|
||||
assert.ok(said.includes("i/o timeout"), said);
|
||||
// its reason wraps: nothing spills at this width
|
||||
assert.ok(await e.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the reason fits");
|
||||
await shot(e.sec, `unread-${engine}-${lang}-${width}`);
|
||||
assert.ok(await eLine.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the reason fits");
|
||||
assert.ok(await e.view.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the page fits");
|
||||
await shot(e.view, `unread-${engine}-${lang}-${width}`);
|
||||
// the search field's results say it too
|
||||
const eq = e.view.locator(".pm-head .pm-find input");
|
||||
await eq.fill("claude");
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
await eLine.waitFor();
|
||||
await eq.fill("");
|
||||
await e.sec.locator(".pm-ghnone").waitFor();
|
||||
// Try again has magpie ask GitHub at once (wheeled into sight
|
||||
// first, clear of the window's footer, as a reader would)
|
||||
const eAgain = e.sec.getByRole("button", { name: w.again });
|
||||
await e.page.mouse.move(width / 2, 300);
|
||||
for (let i = 0; i < 4; i++) await e.page.mouse.wheel(0, 400);
|
||||
await eAgain.click();
|
||||
await e.sec.locator(".pm-ghlook").waitFor();
|
||||
await eLine.waitFor();
|
||||
// Try again has magpie ask GitHub at once
|
||||
await eLine.getByRole("button", { name: w.again }).click();
|
||||
await e.view.locator(".pm-ghlook").waitFor();
|
||||
later.go();
|
||||
await e.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
await ghCards(e.view).first().waitFor();
|
||||
assert.deepEqual(urls, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
||||
assert.equal(await e.sec.locator(".pm-ghwarn, .pm-ghnone").count(), 0);
|
||||
assert.equal(await e.view.locator(".pm-ghwarn").count(), 0);
|
||||
assert.deepEqual(e.errors, []);
|
||||
|
||||
// some came, some couldn't be read: the cards, and a line over
|
||||
@@ -201,30 +198,29 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const later2 = held();
|
||||
const m = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: why, missing: 12 } }, later2], urls2);
|
||||
t.after(() => m.ctx.close());
|
||||
await m.sec.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await m.sec.locator(".pm-ghwarn").innerText(), w.more);
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
assert.ok(await m.sec.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the line fits");
|
||||
await shot(m.sec, `partial-${engine}-${lang}-${width}`);
|
||||
const mAgain = m.sec.locator(".pm-ghwarn").getByRole("button", { name: w.again });
|
||||
await m.page.mouse.move(width / 2, 300);
|
||||
for (let i = 0; i < 4; i++) await m.page.mouse.wheel(0, 400);
|
||||
await mAgain.click();
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2, "cards kept while asking");
|
||||
const mLine = m.view.locator(".pm-ghwarn");
|
||||
await mLine.waitFor();
|
||||
assert.match(await mLine.innerText(), w.more);
|
||||
assert.equal(await ghCards(m.view).count(), 2);
|
||||
assert.ok(await mLine.evaluate((s) => s.scrollWidth <= s.clientWidth + 1), "the line fits");
|
||||
await shot(m.view, `partial-${engine}-${lang}-${width}`);
|
||||
await mLine.getByRole("button", { name: w.again }).click();
|
||||
await m.view.locator(".pm-bar .pm-ghlook").waitFor();
|
||||
assert.equal(await ghCards(m.view).count(), 2, "cards kept while asking");
|
||||
later2.go();
|
||||
await m.sec.locator(".pm-ghwarn").waitFor({ state: "detached" });
|
||||
assert.equal(await m.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
await m.view.locator(".pm-ghwarn").waitFor({ state: "detached" });
|
||||
await m.view.locator(".pm-ghlook").waitFor({ state: "detached" });
|
||||
assert.equal(await ghCards(m.view).count(), 2);
|
||||
assert.deepEqual(urls2, ["/api/plugins/github", "/api/plugins/github?again=1"]);
|
||||
assert.deepEqual(m.errors, []);
|
||||
|
||||
// GitHub too slow, as magpie tells it (why: "slow"): the line
|
||||
// says so in the reader's language, not Go's "no answer in 8s"
|
||||
// in the middle of the page, and the error as it came is its
|
||||
// hover (the Kiko03O1 reply on X: ui 设计能不能好看点); Try
|
||||
// again reads as a button, in the accent
|
||||
// says so in the reader's language, not Go's "no answer in 8s",
|
||||
// and the error as it came is its hover (the Kiko03O1 reply on
|
||||
// X: ui 设计能不能好看点); Try again reads as a button, in the accent
|
||||
const s = await open([{ json: { repos: REPOS, topic: "magpie-plugin", error: "no answer in 8s", why: "slow", missing: 7 } }]);
|
||||
t.after(() => s.ctx.close());
|
||||
const sLine = s.sec.locator(".pm-ghwarn");
|
||||
const sLine = s.view.locator(".pm-ghwarn");
|
||||
await sLine.waitFor();
|
||||
assert.match(await sLine.innerText(), w.slow);
|
||||
assert.doesNotMatch(await sLine.innerText(), /no answer/);
|
||||
@@ -237,11 +233,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
// line says it is from before
|
||||
const k = await open([{ json: { repos: REPOS, topic: "magpie-plugin" } }, { json: { repos: [], topic: "magpie-plugin", error: "GitHub's search: 403 rate limit" } }]);
|
||||
t.after(() => k.ctx.close());
|
||||
await k.sec.locator(".pm-card:not(.ghost)").first().waitFor();
|
||||
await ghCards(k.view).first().waitFor();
|
||||
await k.page.evaluate(() => window.loadPlugins());
|
||||
await k.sec.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await k.sec.locator(".pm-ghwarn").innerText(), /403 rate limit/);
|
||||
assert.equal(await k.sec.locator(".pm-card:not(.ghost)").count(), 2);
|
||||
await k.view.locator(".pm-ghwarn").waitFor();
|
||||
assert.match(await k.view.locator(".pm-ghwarn").innerText(), /403 rate limit/);
|
||||
assert.equal(await ghCards(k.view).count(), 2);
|
||||
assert.deepEqual(k.errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user