gui: a moved Factory's waiting sign-in has one "Use an API key instead" link, its key import's
plugin-other-ways.test.cjs was red on main in both engines sinceee1df7e7a(bisected,653cb8ee3good): that commit let a moved Factory import API keys to its plugin, so its waiting device-code box showed "Use an API key instead" (the plugin's own key way) beside "Use an API key instead…" (the import, one key or many, factory_key.go). Two links that read as one. The plugin's link is left out when a moved subscription's import is there; the key way is still counted, so there is no "Other ways to sign in…" for Factory. plugin-other-ways.test.cjs now checks one key link and that it opens the import; with the app.js line put back it goes red ("two API key links"). It, plugin-moved-signin, plugin-signin and signin-paste-plugin pass in Chromium and WebKit, en and zh.
This commit is contained in:
@@ -12405,10 +12405,12 @@ function renderSigning(sub) {
|
||||
// a plugin's browser sign-in whose page can't reach magpie (Docker: the
|
||||
// Command Code plugin's Studio posts its key to 127.0.0.1) can be left
|
||||
// for the plugin's own API key way, without starting over; one that
|
||||
// takes a pasted key in place already (#2468) needs no second way
|
||||
// takes a pasted key in place already (#2468) needs no second way, and
|
||||
// nor does a moved one whose key import goes to its plugin (Factory,
|
||||
// factory_key.go): two "Use an API key instead" links read as one
|
||||
const keyWay = sub.plugin && signing.method != null && !signing.pasteCode && !signing.pasteKey && signing.state === "waiting"
|
||||
? (sub.plugin.methods || []).findIndex((m) => m.type === "api") : -1;
|
||||
if (keyWay >= 0 && keyWay !== signing.method) {
|
||||
if (keyWay >= 0 && keyWay !== signing.method && !(sub.moved && sub.importable)) {
|
||||
const acts = tt.querySelector(".acts") || tt.appendChild(el("span", "acts"));
|
||||
const k = el("button", "link", t("Use an API key instead"));
|
||||
k.title = t("If the page can't reach magpie (it runs on a server or in Docker)");
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
// is signed in to, not a sign-in page), and the waiting box of one with
|
||||
// ways besides the one under way and its key has "Other ways to sign in…",
|
||||
// which cancels that sign-in and shows the ways. Factory, with its real two
|
||||
// ways, still goes straight to its device code, its key the one link away.
|
||||
// ways, still goes straight to its device code, its key the one link away:
|
||||
// its key import, which sends the keys to its plugin, not a second link.
|
||||
// English and Chinese; the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
@@ -50,8 +51,8 @@ function server(lang, asked) {
|
||||
}
|
||||
|
||||
const L = {
|
||||
en: { anyway: "Sign in anyway", app: "ZCode app's sign-in", key: "GLM Coding Plan API key", other: "Other ways to sign in…", how: "How do you sign in to" },
|
||||
zh: { anyway: "仍然登录", app: "使用 ZCode 应用已登录的账号", key: "GLM Coding Plan API Key", other: "其他登录方式…", how: "用哪种方式登录" },
|
||||
en: { anyway: "Sign in anyway", app: "ZCode app's sign-in", key: "GLM Coding Plan API key", other: "Other ways to sign in…", how: "How do you sign in to", apiKey: "Use an API key instead" },
|
||||
zh: { anyway: "仍然登录", app: "使用 ZCode 应用已登录的账号", key: "GLM Coding Plan API Key", other: "其他登录方式…", how: "用哪种方式登录", apiKey: "改用 API" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
@@ -102,8 +103,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await box.locator(".choices").count(), 0);
|
||||
assert.equal(await box.locator("button.other-ways").count(), 0);
|
||||
if (process.env.ARTIFACT_DIR) await box.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-other-ways-factory-${engine}-${lang}.png`) });
|
||||
await box.locator(".acts button.link").last().click();
|
||||
await box.locator('input[type="password"]').waitFor();
|
||||
// one key link, not the plugin's beside the import's: the import
|
||||
// sends its keys to the plugin (factory_key.go)
|
||||
const keys = box.locator(".acts button.link", { hasText: w.apiKey });
|
||||
assert.equal(await keys.count(), 1, "two API key links");
|
||||
await keys.click();
|
||||
await page.locator("#addSheet textarea").waitFor();
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user