gui: a proxy typed outside Settings takes its login in fields (#3382)
Settings' proxy row keeps a proxy's login in fields of its own, so a
password with @ : / % # or a space survives. The three places that ask
for a proxy of their own still took one line, and the same login had
to be percent-encoded by hand. Those places are the provider editor's
row, each account's and key's line, and the sign-in box's typed proxy.
Each now splits a pasted URL the way Settings' proxyFields does: the
login lands in the fields and the box keeps the address. What the
fields hold is joined back as it is typed, so the value saved (or sent
to a sign-in) is the address Settings would save for the same login:
userinfo in the address, the saved format unchanged. A field left as it
was split keeps its escapes, so a saved login with non-UTF-8 bytes
opens decoded, still works, and saves again byte for byte. A pasted URL
keeps working.
The layout question the issue leaves open ("an account line with two
more fields is wide"): the fields stack under the row, 140px each, so
an account line is no wider. A mode pick that doesn't ask for an
address dims them with the row's own "off", keeping their room, as the
address box always did. proxyLoginRow is the one helper, drawn by all
three places. Settings' own row is untouched. signin-proxy.test.cjs
pins the form's address as its first input, with the two new fields
beside it.
Changed in landing (yetone):
- The fields show for every scheme, as Settings' do. As first written
they showed only for a SOCKS address, but the split ran on any
pasted URL, and join skipped hidden fields. So a pasted
http://name:pw@host lost its login on save. With this change's first
app.js the new HTTP case is red: it saves "http://proxy.example:8080".
- The core budget is not raised. Comments were trimmed to bring the
core to 1,532,444 of 1,533,105.
- The test sets the navigation's minute, as the #4470 guard asks.
Save and the sign-in wait on the post itself, with 30s of room, not
a fixed 2.5s or 2s cap. The sign-in no longer clicks "Sign in
anyway": on main a sign-in again goes straight to the browser.
Broken by hand on mote, chromium en and zh: with app.js and app.css at
origin/main, proxy-login-fields is red 6/6; with this change's first
app.js, its provider case is red 2/2 on the HTTP login.
Run at the pushed head on mote (load ~115):
- proxy-login-fields.test.cjs, chromium and webkit, en and zh: 12/12.
- The same run took signin-proxy, account-proxy, provider-proxy,
provider-many-keys-proxy, provider-advanced-fold, nav-timeout and
i18n-keys in both engines (13 files, 189 cases, 187 pass. The 2 reds are signin-proxy's webkit zh and zh-TW at 380px, red alone at origin/main 41b5c0f19 (#4643). internal/gui/assets is the same at 573b21f4b). signin-proxy's webkit zh and
zh-TW 380 are red the same way at origin/main 41b5c0f19, run alone:
the editor's switch-only line takes the click meant for "Sign in
again" (#4643).
- go test ./internal/gui -run 'Budget|I18n|Asset': ok.
- go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch
Not tried: the whole GUI suite; a real SOCKS or HTTP proxy.
Generated-by: GLM-5.3-Flash (ZCode)
Co-authored-by: yetone <yetoneful@gmail.com>
This commit is contained in:
committed by
yetone
co-authored by
yetone
parent
a6de2a15ea
commit
9c8636a351
@@ -3162,6 +3162,13 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
|
||||
.editor .acct-proxy-tools .acct-proxy-filter { flex: 1 1 auto; min-width: 0; }
|
||||
.editor .acct-proxy-tools .text { flex: none; }
|
||||
.editor .acct-proxies > .acct-proxy-more { justify-self: start; }
|
||||
/* the login of a SOCKS proxy in the rows outside Settings (#3382): the
|
||||
fields Settings' own row has, stacked under, so an account line is no
|
||||
wider; off keeps its room as the address beside the options does */
|
||||
.editor .proxy-auth.proxy-login { justify-content: flex-start; }
|
||||
.editor .proxy-auth.proxy-login input.proxy-credential { width: 140px; max-width: 100%; min-width: 0; }
|
||||
.editor .proxy-auth.proxy-login.off { visibility: hidden; }
|
||||
.signing .callback-form .proxy-login { flex-basis: 100%; }
|
||||
/* what a balance token's URL wants instead, and a balance checked in the form */
|
||||
.editor .bal-fix { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--muted); }
|
||||
.editor .bal-fix:empty { display: none; }
|
||||
|
||||
@@ -7628,10 +7628,11 @@ function proxyPicker() {
|
||||
const addr = input(draft.proxyURL || "", "http://127.0.0.1:7890");
|
||||
addr.className = "proxy-url";
|
||||
addr.classList.toggle("off", draft.proxyMode !== "custom");
|
||||
addr.oninput = () => { draft.proxyURL = addr.value; };
|
||||
const login = proxyLoginRow(addr, (v) => { draft.proxyURL = v; });
|
||||
const seg = segs([["", t("Global proxy")], ["direct", t("Direct")], ["custom", t("Custom")]], draft.proxyMode || "", (v) => {
|
||||
draft.proxyMode = v;
|
||||
addr.classList.toggle("off", v !== "custom");
|
||||
login.classList.toggle("off", v !== "custom");
|
||||
hint.textContent = t(PROXY_HINT[v]);
|
||||
});
|
||||
seg.classList.add("proxy-mode");
|
||||
@@ -7640,7 +7641,7 @@ function proxyPicker() {
|
||||
// centred dialog would move under the pointer)
|
||||
const row = el("div", "proxy-row");
|
||||
row.append(seg, addr);
|
||||
box.append(row, hint);
|
||||
box.append(row, login, hint);
|
||||
return box;
|
||||
}
|
||||
|
||||
@@ -8002,15 +8003,16 @@ function proxyLine(it) {
|
||||
const addr = input(cur.url || "", "http://127.0.0.1:7890");
|
||||
addr.className = "proxy-url";
|
||||
addr.classList.toggle("off", cur.mode !== "custom");
|
||||
addr.oninput = () => { draft.accountProxies[k] = { ...(draft.accountProxies[k] || { mode: "custom" }), url: addr.value }; };
|
||||
const login = proxyLoginRow(addr, (v) => { draft.accountProxies[k] = { ...(draft.accountProxies[k] || { mode: "custom" }), url: v }; });
|
||||
const seg = segs([["", t("Provider's proxy")], ["direct", t("Direct")], ["custom", t("Custom")]], cur.mode || "", (v) => {
|
||||
draft.accountProxies[k] = { ...(draft.accountProxies[k] || {}), mode: v };
|
||||
addr.classList.toggle("off", v !== "custom");
|
||||
login.classList.toggle("off", v !== "custom");
|
||||
});
|
||||
seg.classList.add("proxy-mode");
|
||||
const row = el("div", "proxy-row");
|
||||
row.append(seg, addr);
|
||||
line.append(who, row);
|
||||
line.append(who, row, login);
|
||||
return line;
|
||||
}
|
||||
// accountProxiesOfDraft is each account's own proxy as it is saved — the
|
||||
@@ -12652,15 +12654,18 @@ function signInProxyForm(sub) {
|
||||
const go = el("button", "text primary", t("Sign in through it"));
|
||||
go.type = "submit";
|
||||
go.disabled = !inp.value.trim();
|
||||
inp.oninput = () => { flow.customProxy = inp.value; go.disabled = !inp.value.trim(); };
|
||||
const login = proxyLoginRow(inp, (v) => { flow.customProxy = v; }, () => { go.disabled = !inp.value.trim(); });
|
||||
// the fields' keys stay out of the sheet's, as the address's are
|
||||
for (const f of login.querySelectorAll("input")) f.onkeydown = inp.onkeydown;
|
||||
const submit = (e) => {
|
||||
e.preventDefault();
|
||||
if (signing !== flow || !inp.value.trim()) return;
|
||||
signInThrough(sub, inp.value.trim());
|
||||
const v = (flow.customProxy || "").trim();
|
||||
if (signing !== flow || !v) return;
|
||||
signInThrough(sub, v);
|
||||
};
|
||||
form.onsubmit = submit;
|
||||
go.onclick = submit;
|
||||
form.append(inp, go);
|
||||
form.append(inp, go, login);
|
||||
setTimeout(() => { if (inp.isConnected) inp.focus(NO_SCROLL); });
|
||||
return form;
|
||||
}
|
||||
@@ -20670,6 +20675,41 @@ function proxyAddress(a, f, user, pass) {
|
||||
const [, scheme = "", rest] = /^([a-z][\w+.-]*:\/\/)?(.*)$/is.exec(a);
|
||||
return scheme + enc(user, f.username, f.eu) + (pass ? ":" + enc(pass, f.password, f.ep) : "") + "@" + rest;
|
||||
}
|
||||
// proxyLoginRow: a proxy login's fields for the proxy rows outside
|
||||
// Settings (#3382), split and joined as Settings' row does (proxyFields,
|
||||
// proxyAddress), so setURL gets the address Settings would save.
|
||||
function proxyLoginRow(addr, setURL, changed) {
|
||||
const fields = {};
|
||||
const auth = el("div", "proxy-auth proxy-login");
|
||||
const username = input("", t("Username (optional)"));
|
||||
const password = input("", t("Password (optional)"), "password");
|
||||
for (const f of [username, password]) {
|
||||
f.className = "proxy-credential";
|
||||
f.setAttribute("aria-label", f.placeholder);
|
||||
}
|
||||
auth.append(username, password);
|
||||
const join = () => {
|
||||
let v = addr.value;
|
||||
try {
|
||||
v = proxyAddress(addr.value.trim(), fields, username.value, password.value);
|
||||
} catch {} // a half-typed address is kept as it was typed
|
||||
setURL(v);
|
||||
};
|
||||
const split = (quiet) => {
|
||||
const parsed = proxyFields(addr.value.trim());
|
||||
if (parsed.username || parsed.password) {
|
||||
Object.assign(fields, { username: parsed.username, password: parsed.password, eu: parsed.eu, ep: parsed.ep });
|
||||
username.value = parsed.username;
|
||||
password.value = parsed.password;
|
||||
addr.value = parsed.address;
|
||||
}
|
||||
if (!quiet) { join(); if (changed) changed(); }
|
||||
};
|
||||
username.oninput = password.oninput = join;
|
||||
addr.oninput = () => split();
|
||||
split(true);
|
||||
return auth;
|
||||
}
|
||||
function proxyDisplay(value) {
|
||||
// Also mask an older backend's proxyNow, and environment/system proxies.
|
||||
return (value || "").replace(/^(\w+:\/\/)?[^/?#]*@/, "$1");
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// The proxy rows outside Settings take a proxy's login in fields
|
||||
// of their own (#3382), the same split Settings' proxyFields makes: a pasted
|
||||
// URL keeps working — its login lands in the fields, the box keeps the
|
||||
// address — and what is typed in the fields is saved joined back into the
|
||||
// saved format (userinfo in the address), escaped as Settings would save it,
|
||||
// so the same login typed in Settings and pasted here is one address. A
|
||||
// saved login opens decoded and saves again byte for byte, non-UTF-8
|
||||
// escapes included. The provider's row, an account's line, a key's line and
|
||||
// the sign-in box's typed proxy. In English and Chinese.
|
||||
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 BARE = "socks5://127.0.0.1:1080";
|
||||
const JOINED = "socks5://a%40b%3A%2F%25%20user:p%40ss%3A%2F%25%20%23pass@127.0.0.1:1080";
|
||||
const LOGIN = { user: "a@b:/% user", pass: "p@ss:/% #pass" };
|
||||
const codex = {
|
||||
id: "codex", name: "Codex", icon: "codex-color", chat: "", responses: "", anthropic: "", catalog: "",
|
||||
models: [{ id: "gpt-6", name: "GPT-6", on: true }], agents: [], fallback: [], headers: {}, keyList: [],
|
||||
account: {
|
||||
agent: "codex", agentName: "Codex", user: "me@example.com", plan: "PLUS",
|
||||
logins: [
|
||||
{ user: "spare@example.com", plan: "PLUS", on: true },
|
||||
{ user: "me@example.com", plan: "PLUS", active: true, on: true },
|
||||
{ user: "Third@Example.com", plan: "PRO", on: true },
|
||||
],
|
||||
},
|
||||
proxy: "",
|
||||
accountProxies: { "me@example.com": BARE, "spare@example.com": "direct" },
|
||||
};
|
||||
const relay = {
|
||||
id: "relay", name: "Relay", icon: "generic", chat: "https://relay.example.com/v1", responses: "", anthropic: "", catalog: "",
|
||||
models: [{ id: "big", name: "", on: true }], agents: [], fallback: [], headers: {},
|
||||
key: { set: true, masked: "sk-…one" }, balanceToken: { takes: false, set: false },
|
||||
proxy: BARE,
|
||||
keyList: [{ id: "aaaaaaaaaa", name: "Team", masked: "sk-…one", on: true, active: true }, { id: "bbbbbbbbbb", name: "", masked: "sk-…two", on: true }, { id: "cccccccccc", name: "Spare", masked: "sk-…three", on: true }],
|
||||
accountProxies: { aaaaaaaaaa: BARE, bbbbbbbbbb: "direct" },
|
||||
};
|
||||
const claude = {
|
||||
id: "claude", name: "Claude", icon: "claude-color", chat: "", responses: "", anthropic: "", catalog: "",
|
||||
models: [{ id: "claude-opus-5", name: "Claude Opus 5", on: true }], agents: [], fallback: [], headers: {}, keyList: [],
|
||||
account: { agent: "claude", agentName: "Claude Code", user: "alice@example.com", plan: "MAX", logins: [{ user: "alice@example.com", plan: "MAX", active: true, on: true }, { user: "bob@example.com", plan: "PRO", lapsed: true }] },
|
||||
proxy: "", accountProxies: {},
|
||||
};
|
||||
|
||||
function serve(lang, posts, seen) {
|
||||
// a clone each time: a save merges into this test's copy, not the
|
||||
// fixtures the next test opens with
|
||||
const [codexNow, relayNow, claudeNow] = [codex, relay, claude].map((p) => structuredClone(p));
|
||||
const providers = { providers: [codexNow, relayNow, claudeNow], presets: [], excluded: [], gateway: { running: true, window: true } };
|
||||
const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
|
||||
const flows = {};
|
||||
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 = ${JSON.stringify({ 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(state);
|
||||
if (url.pathname === "/api/providers") return json(providers);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [] });
|
||||
if (url.pathname.startsWith("/api/provider/") && req.method() === "POST") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push({ action: url.pathname.slice("/api/provider/".length), body });
|
||||
const p = providers.providers.find((x) => x.id === body.id);
|
||||
if (p) { if ("proxy" in body) p.proxy = body.proxy; if ("accountProxies" in body) p.accountProxies = body.accountProxies; }
|
||||
return json(providers);
|
||||
}
|
||||
if (url.pathname === "/api/signin") {
|
||||
const b = req.postDataJSON();
|
||||
seen.starts.push(b);
|
||||
const id = "s" + seen.starts.length;
|
||||
flows[id] = { id, agent: b.agent, state: "waiting", url: "https://vendor.example/oauth?state=" + id, proxy: b.proxy ?? "" };
|
||||
return json(flows[id]);
|
||||
}
|
||||
const m = url.pathname.match(/^\/api\/signin\/(s\d+)(\/cancel)?$/);
|
||||
if (m) {
|
||||
if (m[2]) { seen.canceled.push(m[1]); flows[m[1]].state = "canceled"; }
|
||||
return json(flows[m[1]]);
|
||||
}
|
||||
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 words = {
|
||||
en: { custom: "Custom", direct: "Direct", save: "Save", user: "Username (optional)", pass: "Password (optional)", again: "Sign in again", via: "Proxy: {p}", typed: "Sign in through it" },
|
||||
zh: { custom: "自定义", direct: "直连", save: "保存", user: "用户名(可选)", pass: "密码(可选)", again: "重新登录", via: "代理:{p}", typed: "经由它登录" },
|
||||
};
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh"]) {
|
||||
const w = words[lang];
|
||||
const browser = async (t, width, height, tag) => {
|
||||
const b = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${tag}-proxy-login.png`) });
|
||||
}
|
||||
await b.close();
|
||||
});
|
||||
const page = await (await b.newContext({ viewport: { width, height }, reducedMotion: "reduce" })).newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
return page;
|
||||
};
|
||||
const unfold = async (page) => {
|
||||
const adv = page.locator(".editor details.advanced");
|
||||
await adv.waitFor({ state: "attached" });
|
||||
if (!(await adv.evaluate((d) => d.open))) await adv.locator(":scope > summary").click();
|
||||
};
|
||||
const openEditor = async (page, name, wait) => {
|
||||
await page.locator(".row.provider", { hasText: name }).first().click();
|
||||
await unfold(page);
|
||||
await page.locator(wait).first().waitFor();
|
||||
};
|
||||
const save = async (page, posts) => {
|
||||
const n = posts.length;
|
||||
await page.locator(".editor .bar").getByRole("button", { name: w.save, exact: true }).click();
|
||||
// waits on the post itself, with half a minute's room for a busy box
|
||||
for (const end = Date.now() + 30000; posts.length === n && Date.now() < end;) await page.waitForTimeout(20);
|
||||
assert.notEqual(posts.length, n, "Save posted nothing");
|
||||
return posts.at(-1);
|
||||
};
|
||||
const creds = (scope) => ({
|
||||
user: scope.getByLabel(w.user, { exact: true }),
|
||||
pass: scope.getByLabel(w.pass, { exact: true }),
|
||||
});
|
||||
const line = (page, user) => page.locator(`.editor .acct-proxy[data-${/^[a-f0-9]{10}$/.test(user) ? "key" : "user"}="${user}"]`);
|
||||
|
||||
test(`${engine} ${lang}: the provider's proxy row splits and joins a login`, async (t) => {
|
||||
const page = await browser(t, 900, 760, "provider");
|
||||
const errors = [], posts = [], seen = { starts: [], canceled: [] };
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, posts, seen));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await openEditor(page, "Relay", ".editor .proxy-pick .proxy-url");
|
||||
const pick = page.locator(".editor .proxy-pick");
|
||||
const addr = pick.locator(".proxy-url");
|
||||
const { user, pass } = creds(pick);
|
||||
assert.equal(await addr.inputValue(), BARE, "the saved login is out of the box");
|
||||
await user.waitFor({ state: "visible" });
|
||||
assert.equal(await user.inputValue(), "");
|
||||
assert.equal(await pass.inputValue(), "");
|
||||
|
||||
// typed in the fields, saved as Settings would save the same login
|
||||
await user.fill(LOGIN.user);
|
||||
await pass.fill(LOGIN.pass);
|
||||
let saved = await save(page, posts);
|
||||
assert.equal(saved.body.proxy, JOINED);
|
||||
|
||||
// saved again unchanged, it is one address still
|
||||
await openEditor(page, "Relay", ".editor .proxy-pick .proxy-url");
|
||||
assert.equal(await addr.inputValue(), BARE);
|
||||
assert.equal(await user.inputValue(), LOGIN.user);
|
||||
assert.equal(await pass.inputValue(), LOGIN.pass);
|
||||
saved = await save(page, posts);
|
||||
assert.equal(saved.body.proxy, JOINED);
|
||||
|
||||
// a pasted URL with a login separates, and non-UTF-8 escapes are kept
|
||||
await openEditor(page, "Relay", ".editor .proxy-pick .proxy-url");
|
||||
await addr.fill("socks5://name:p%FFss@[::1]:1080");
|
||||
assert.equal(await addr.inputValue(), "socks5://[::1]:1080");
|
||||
assert.equal(await user.inputValue(), "name");
|
||||
assert.equal(await pass.inputValue(), "p%FFss");
|
||||
saved = await save(page, posts);
|
||||
assert.equal(saved.body.proxy, "socks5://name:p%FFss@[::1]:1080");
|
||||
|
||||
// an HTTP proxy's login splits the same way, as Settings splits it
|
||||
await openEditor(page, "Relay", ".editor .proxy-pick .proxy-url");
|
||||
await addr.fill("http://name:pw@proxy.example:8080");
|
||||
assert.equal(await addr.inputValue(), "http://proxy.example:8080");
|
||||
assert.equal(await user.inputValue(), "name");
|
||||
assert.equal(await pass.inputValue(), "pw");
|
||||
saved = await save(page, posts);
|
||||
assert.equal(saved.body.proxy, "http://name:pw@proxy.example:8080");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: an account's and a key's line split and join a login`, async (t) => {
|
||||
const page = await browser(t, 900, 760, "lines");
|
||||
const errors = [], posts = [], seen = { starts: [], canceled: [] };
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, posts, seen));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
|
||||
await openEditor(page, "Codex", ".editor .acct-proxy");
|
||||
const me = creds(line(page, "me@example.com"));
|
||||
await me.user.waitFor({ state: "visible" });
|
||||
await me.user.fill(LOGIN.user);
|
||||
await me.pass.fill(LOGIN.pass);
|
||||
let saved = await save(page, posts);
|
||||
assert.deepEqual(saved.body.accountProxies, { "me@example.com": JOINED, "spare@example.com": "direct" });
|
||||
|
||||
await openEditor(page, "Codex", ".editor .acct-proxy");
|
||||
const meAgain = creds(line(page, "me@example.com"));
|
||||
assert.equal(await line(page, "me@example.com").locator(".proxy-url").inputValue(), BARE);
|
||||
assert.equal(await meAgain.user.inputValue(), LOGIN.user);
|
||||
assert.equal(await meAgain.pass.inputValue(), LOGIN.pass);
|
||||
saved = await save(page, posts);
|
||||
assert.deepEqual(saved.body.accountProxies, { "me@example.com": JOINED, "spare@example.com": "direct" });
|
||||
|
||||
// a pasted URL with a login separates, and saves as it came
|
||||
await openEditor(page, "Codex", ".editor .acct-proxy");
|
||||
const mine = line(page, "me@example.com");
|
||||
await mine.locator(".proxy-url").fill(JOINED);
|
||||
assert.equal(await mine.locator(".proxy-url").inputValue(), BARE, "the pasted login is out of the box");
|
||||
assert.equal(await creds(mine).user.inputValue(), LOGIN.user);
|
||||
assert.equal(await creds(mine).pass.inputValue(), LOGIN.pass);
|
||||
saved = await save(page, posts);
|
||||
assert.deepEqual(saved.body.accountProxies, { "me@example.com": JOINED, "spare@example.com": "direct" });
|
||||
|
||||
await openEditor(page, "Relay", ".editor .acct-proxy");
|
||||
const team = creds(line(page, "aaaaaaaaaa"));
|
||||
await team.user.waitFor({ state: "visible" });
|
||||
await team.user.fill(LOGIN.user);
|
||||
await team.pass.fill(LOGIN.pass);
|
||||
saved = await save(page, posts);
|
||||
assert.deepEqual(saved.body.accountProxies, { aaaaaaaaaa: JOINED, bbbbbbbbbb: "direct" });
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test(`${engine} ${lang}: the sign-in box's typed proxy takes a login in fields`, async (t) => {
|
||||
const page = await browser(t, 900, 800, "signin");
|
||||
const errors = [], posts = [], seen = { starts: [], canceled: [] };
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", serve(lang, posts, seen));
|
||||
await page.goto("http://magpie.test/?view=providers");
|
||||
await page.locator(".row.provider", { hasText: "Claude" }).first().click();
|
||||
const bob = page.locator(".editor .accts .acc", { hasText: "bob@example.com" });
|
||||
await bob.locator("button", { hasText: w.again }).click();
|
||||
const box = page.locator(".editor .signing");
|
||||
const via = box.locator(".acts .via");
|
||||
await via.waitFor();
|
||||
await via.scrollIntoViewIfNeeded();
|
||||
await via.click();
|
||||
const menu = page.locator(".proto-menu");
|
||||
await menu.waitFor();
|
||||
await menu.locator(".pm-item", { hasText: w.custom }).click();
|
||||
const form = box.locator("form.proxy-ask");
|
||||
await form.waitFor();
|
||||
const addr = form.locator("input").first();
|
||||
const { user, pass } = creds(form);
|
||||
await addr.fill(BARE);
|
||||
await user.waitFor({ state: "visible" });
|
||||
await user.fill(LOGIN.user);
|
||||
await pass.fill(LOGIN.pass);
|
||||
// a pasted URL with a login separates the same way
|
||||
await addr.fill(JOINED);
|
||||
assert.equal(await addr.inputValue(), BARE, "the pasted login is out of the box");
|
||||
assert.equal(await user.inputValue(), LOGIN.user);
|
||||
assert.equal(await pass.inputValue(), LOGIN.pass);
|
||||
await form.locator("button", { hasText: w.typed }).click();
|
||||
for (const end = Date.now() + 30000; seen.starts.length < 2 && Date.now() < end;) await page.waitForTimeout(20);
|
||||
assert.deepEqual(seen.starts.at(-1), { agent: "claude", user: "bob@example.com", proxy: JOINED });
|
||||
await page.waitForFunction((p) => document.querySelector(".editor .signing .acts .via")?.textContent.includes(p), BARE);
|
||||
const shown = (await via.textContent()).trim();
|
||||
assert(!shown.includes("p@ss") && !shown.includes("p%40ss"), "the link shows the login");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await form.waitFor();
|
||||
const go = form.locator("button", { hasText: w.go });
|
||||
assert.equal(await go.isDisabled(), true, "nothing to sign in through yet");
|
||||
await form.locator("input").fill("http://127.0.0.1:8888");
|
||||
await form.locator("input").first().fill("http://127.0.0.1:8888");
|
||||
await go.click();
|
||||
await page.waitForFunction(() => document.querySelector(".editor .signing .acts .via")?.textContent.includes("8888"));
|
||||
assert.deepEqual(seen.starts[2], { agent: "claude", user: "bob@example.com", proxy: "http://127.0.0.1:8888" });
|
||||
|
||||
Reference in New Issue
Block a user