Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

test(settings): exercise stale proxy restoration in Electron

vastsab34c1f31a50a
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4b91fbdad..fe7ac5d70 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -13403,8 +13403,10 @@ are withdrawn with ADR 0165.
credentials and unsupported SOCKS4 schemes are covered by shared parser
tests. `system-proxy-relay.test.ts` covers authenticated provider traffic,
PAC proxy fallback, HTTP proxy forwarding, and scheme detection on
- non-default ports. Full UI journey Draft (run only in a capable environment
- when this surface changes).
+ non-default ports. The stale-invalid-draft Custom → System → Custom
+ restoration path is covered by `pnpm test:e2e:settings-scroll`. The full UI
+ journey remains Draft (run only in a capable environment when this surface
+ changes).
#### E2E-191: Newly emitted AppError codes stay registered
diff --git a/scripts/e2e/settings-scroll.jsx b/scripts/e2e/settings-scroll.jsx
index 7fa238b48..ef55d6ca1 100644
--- a/scripts/e2e/settings-scroll.jsx
+++ b/scripts/e2e/settings-scroll.jsx
@@ -22,6 +22,7 @@ let settings = {
language: "en",
enterToSend: true,
developerMode: false,
+ networkProxy: { mode: "custom", url: "socks5://10.0.0.8:1080" },
};
let updateState = {
mode: "in-app",
@@ -186,10 +187,11 @@ async function exerciseUpdatePreference() {
const trigger = () => document.querySelector('button[aria-label="Update behavior"]');
assert(trigger() instanceof HTMLButtonElement, "Update behavior selector must render");
assert(trigger().textContent?.includes("Automatic"), "Installed package defaults to Automatic");
+ const updateActionLabels = [...document.querySelectorAll(".about-update-actions button")]
+ .map((button) => button.textContent?.trim() ?? "");
assert(
- [...document.querySelectorAll(".update-settings-actions button")]
- .some((button) => button.textContent?.includes("Check for updates")),
- "Automatic mode keeps the existing update check action",
+ updateActionLabels.some((label) => label.includes("Check for updates")),
+ `Automatic mode keeps the existing update check action: ${updateActionLabels.join(", ")}`,
);
async function choosePreference(label, value) {
@@ -210,7 +212,7 @@ async function exerciseUpdatePreference() {
await choosePreference("Manual", "manual");
assert(trigger().textContent?.includes("Manual"), "Manual must become the selected value");
assert(
- [...document.querySelectorAll(".update-settings-actions button")]
+ [...document.querySelectorAll(".about-update-actions button")]
.some((button) => button.textContent?.includes("View release")),
"Manual mode must offer the release page for an available version",
);
@@ -259,6 +261,40 @@ async function exerciseBrazilianPortuguese() {
assert(selectedLabel?.textContent?.trim() === "Português (Brasil)", "Picker must show the selected native name");
return { locale: i18n.language, language: settings.language, label: selectedLabel.textContent.trim() };
}
+async function exerciseProxyDraftRestoration() {
+ await select("General");
+ const urlInput = () => document.querySelector('input[aria-label="Proxy URL"]');
+ const input = urlInput();
+ assert(input instanceof HTMLInputElement, "Custom proxy URL field must render");
+ const rememberedUrl = settings.networkProxy.url;
+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
+ assert(setter, "Proxy URL input must expose its value setter");
+ setter.call(input, "not-a-proxy");
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ await settle();
+ urlInput().blur();
+ await settle();
+ assert(settings.networkProxy.url === rememberedUrl, "An invalid draft must not overwrite the saved proxy");
+
+ const chooseMode = async (label) => {
+ const group = document.querySelector('.settings-segment[aria-label="Proxy"]');
+ assert(group, "Proxy mode control must render");
+ const option = [...group.querySelectorAll('[role="radio"]')]
+ .find((candidate) => candidate.textContent?.trim() === label);
+ assert(option instanceof HTMLButtonElement, `Missing proxy mode: ${label}`);
+ flushSync(() => option.click());
+ await settle();
+ };
+
+ await chooseMode("System");
+ assert(settings.networkProxy.mode === "system", "System mode must persist");
+ assert(settings.networkProxy.url === rememberedUrl, "System mode must retain the remembered proxy");
+ await chooseMode("Custom");
+ assert(settings.networkProxy.mode === "custom", "Custom mode must persist on re-entry");
+ assert(urlInput()?.value === rememberedUrl, "Re-entering Custom must restore the remembered URL");
+ assert(settings.networkProxy.url === rememberedUrl, "Re-entry must not replace the saved URL with the default");
+ return { proxyMode: settings.networkProxy.mode, proxyUrl: settings.networkProxy.url };
+}
window.settingsScrollProbe = async () => {
await settle();
assert(
@@ -266,6 +302,7 @@ window.settingsScrollProbe = async () => {
"Mounting Settings must move focus to its search control",
);
const checks = [];
+ checks.push(await exerciseProxyDraftRestoration());
await checkCloudSyncVisibility();
for (const theme of ["light", "dark"]) {
document.documentElement.dataset.theme = theme;