Files
magpie/internal/gui/tests/providers-withdrawn.test.cjs
T
yetone 256910f174 plugin: Antigravity's plugin keeps serving whoever has it, and is given to nobody new
The owner (11-15): "正在使用的继续正常,加个提示,新用户不让下载". Google
suspends accounts it sees on Code Assist through Antigravity's own client,
so 9cd5f3652 retired the plugin outright (0.2.0 answered every request with
a 410). Now its users keep it working and are told the risk; nobody new
gets it.

- internal/plugin/withdrawn.go: a list of withdrawn packages (Antigravity's,
  pointing to agy-cli). plugin.Add, the one place the CLI, the GUI,
  Discover and import links install through, turns a withdrawn package
  away unless this magpie has it listed already (on or off), and says
  what to use instead. Upgrade and AddExact (backup, sync) are not gated:
  they act on a plugin the user has.
- The mover installs it for the user's own accounts (move,
  keepMovedCurrent) under plugin.KeepWithdrawn; Adopt, which brings no
  accounts, is a new user and is turned away. Antigravity's min is 0.2.1,
  plugins c0c625ac: the 0.1.18 plugin restored, out of the registry.
- /api/providers lists the withdrawn plugins kept in `withdrawn`, and the
  Providers page draws a line over the list: the risk, why, and "Use
  Antigravity (local agy CLI)", which opens Plugins on "agy". New strings
  in zh, zh-TW, ja and de. depLine() now draws all three kinds of
  Providers line (discovery off, unmoved, this one), which keeps app.js
  inside its budget without a raise.
- AGENTS.md, provider-plugins.md and the site's subscriptions docs (en,
  zh, ja, search index) say the plugin keeps working for its users and
  is withdrawn for anyone new.

Run on mote at this tree (base 52e83f7b5). After the rebase onto
500f39886 (testenv, qianfan, LESSONS upstream), again at this head: go vet
and go test -count=1 of internal/plugin, internal/provider, internal/gui,
internal/testenv and the root package, all ok. Before it:
- go vet, GOOS=linux go vet -tags nogui and GOOS=windows go vet of
  internal/plugin, internal/provider and internal/gui: ok. gofmt -l clean.
- go test -count=1 ./internal/plugin ./internal/provider ./internal/gui
  (whole packages, TestCoreScriptBudget and the i18n guards in them): ok.
- node --test providers-withdrawn (new; chromium and webkit, en zh
  zh-TW ja de, 1100 and 420), deprecation-notice, plugin-move,
  plugin-move-overflow, retired-move, deprecated-subscriptions, i18n-keys,
  providers-discovery-off, plugin-movable-review, providers-off-fold: ok.
  plugin-move-unserved's 'Try again takes the models unticked' is red 4 of
  4, the same at origin/main 500f39886 alone: #4410.
- Broken by hand: without RefuseWithdrawn in Add,
  TestWithdrawnGivenToNobodyNew goes red (Add goes on to install); without
  KeepWithdrawn in move, TestWithdrawnPluginKeptForItsUsers goes red (the
  user's own move is turned away).
- Plugins: bun scripts/check.mjs all and bun test packages/antigravity
  packages/agy-cli scripts, 195 pass; dist index.json has 0.2.1.

Not tried: a real Antigravity account through 0.2.1 (it is 0.1.18's code,
which served until 11-15), and the CLI/TUI show no notice beyond Add's
refusal.
2026-11-16 03:00:18 +08:00

87 lines
5.9 KiB
JavaScript

// Run with Node's test runner and Playwright on the module path; see README.md.
// Antigravity's plugin is withdrawn (the owner, 11-15: 正在使用的继续正常,
// 加个提示,新用户不让下载): it keeps working for whoever has it, and a
// line over the Providers list tells them Google can suspend the account
// and leads to Antigravity (local agy CLI) on the Plugins page. Without it
// installed, no line. Every language, Chromium and WebKit, at 1100 and 420
// wide, nothing past the window's edge.
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");
function serve(lang, kept) {
const settings = { lang, theme: "light", lanURLs: [], fx: { rate: 7.2, at: new Date().toISOString() } };
const full = settings;
const withdrawn = kept ? [{ id: "antigravity", name: "Antigravity", instead: "Antigravity (local agy CLI)", package: "@magpie-community/opencode-agy-cli-auth" }] : undefined;
return async (route) => {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false,textSize:100};` });
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 });
if (url.pathname === "/api/settings") return json(full);
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/plugins/listings") return json({ listings: [{ name: "Antigravity (local agy CLI)", package: "@magpie-community/opencode-agy-cli-auth", providers: ["agy-cli"], community: true, summary: "Your own agy CLI" }] });
if (url.pathname === "/api/plugins/search") return json({ hits: [] });
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
if (url.pathname === "/api/providers") return json({ providers: [{ id: "relay", name: "Relay", icon: "generic", host: "relay.example", chat: "https://relay.example/v1", models: [], agents: [], key: { set: true, masked: "sk-…1234" } }], presets: [], excluded: [], withdrawn });
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
if (url.pathname.startsWith("/api/")) return json({});
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 fits = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1);
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
for (const width of [1100, 420]) {
test(`${engine} ${lang} ${width}: a withdrawn plugin's user is told the risk and led to agy`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const open = async (kept) => {
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(6000);
page.setDefaultNavigationTimeout(60000);
page.errors = [];
page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; page.errors.push(e.message); });
await page.route("**/*", serve(lang, kept));
await page.goto("http://magpie.test/?view=providers");
await page.locator("#view-providers .row", { hasText: "Relay" }).first().waitFor();
return page;
};
const tr = (page, s, v) => page.evaluate(([s, v]) => t(s, v), [s, v]);
// without it: no line
let page = await open(false);
assert.equal(await page.locator("#movable .withdrawn").count(), 0, "no line");
assert.deepEqual(page.errors, []);
// with it: the risk, translated, and the way to agy-cli
page = await open(true);
const line = page.locator("#movable .withdrawn");
await line.waitFor();
assert(await page.locator("#movable").isVisible(), "shown");
const head = await tr(page, "{name}'s plugin can get your account suspended", { name: "Antigravity" });
assert.equal((await line.locator(".dep-head").textContent()).trim(), head);
if (lang !== "en") assert.notEqual(head, "Antigravity's plugin can get your account suspended", "translated");
assert.equal((await line.locator(".dep-why").textContent()).trim(), await tr(page, "Google suspends accounts it sees used outside its own app. {name} runs your own agy instead.", { name: "Antigravity (local agy CLI)" }));
assert(await fits(page), "fits");
const go = line.locator("button.action");
assert.equal((await go.textContent()).trim(), await tr(page, "Use {name}", { name: "Antigravity (local agy CLI)" }));
const gb = await go.boundingBox(), lb = await line.boundingBox();
assert(gb.x >= lb.x - 1 && gb.x + gb.width <= lb.x + lb.width + 1, "inside the line");
await go.click();
await page.waitForFunction(() => [...document.querySelectorAll("#view-plugins input[type=search]")].some((q) => q.value === "agy"));
assert.deepEqual(page.errors, []);
});
}
}
}