refactor(extensions): dedupe channel config, onboarding, and monitors

This commit is contained in:
Peter Steinberger
2026-03-02 08:53:11 +00:00
parent d358b3ac88
commit ad8d766f65
43 changed files with 677 additions and 776 deletions

View File

@@ -273,6 +273,36 @@ describe("loginGeminiCliOAuth", () => {
});
}
async function runRemoteLoginWithCapturedAuthUrl(
loginGeminiCliOAuth: (options: {
isRemote: boolean;
openUrl: () => Promise<void>;
log: (msg: string) => void;
note: () => Promise<void>;
prompt: () => Promise<string>;
progress: { update: () => void; stop: () => void };
}) => Promise<{ projectId: string }>,
) {
let authUrl = "";
const result = await loginGeminiCliOAuth({
isRemote: true,
openUrl: async () => {},
log: (msg) => {
const found = msg.match(/https:\/\/accounts\.google\.com\/o\/oauth2\/v2\/auth\?[^\s]+/);
if (found?.[0]) {
authUrl = found[0];
}
},
note: async () => {},
prompt: async () => {
const state = new URL(authUrl).searchParams.get("state");
return `${"http://localhost:8085/oauth2callback"}?code=oauth-code&state=${state}`;
},
progress: { update: () => {}, stop: () => {} },
});
return { result, authUrl };
}
let envSnapshot: Partial<Record<(typeof ENV_KEYS)[number], string>>;
beforeEach(() => {
envSnapshot = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]]));
@@ -325,24 +355,8 @@ describe("loginGeminiCliOAuth", () => {
});
vi.stubGlobal("fetch", fetchMock);
let authUrl = "";
const { loginGeminiCliOAuth } = await import("./oauth.js");
const result = await loginGeminiCliOAuth({
isRemote: true,
openUrl: async () => {},
log: (msg) => {
const found = msg.match(/https:\/\/accounts\.google\.com\/o\/oauth2\/v2\/auth\?[^\s]+/);
if (found?.[0]) {
authUrl = found[0];
}
},
note: async () => {},
prompt: async () => {
const state = new URL(authUrl).searchParams.get("state");
return `${"http://localhost:8085/oauth2callback"}?code=oauth-code&state=${state}`;
},
progress: { update: () => {}, stop: () => {} },
});
const { result } = await runRemoteLoginWithCapturedAuthUrl(loginGeminiCliOAuth);
expect(result.projectId).toBe("daily-project");
const loadRequests = requests.filter((request) =>
@@ -398,24 +412,8 @@ describe("loginGeminiCliOAuth", () => {
});
vi.stubGlobal("fetch", fetchMock);
let authUrl = "";
const { loginGeminiCliOAuth } = await import("./oauth.js");
const result = await loginGeminiCliOAuth({
isRemote: true,
openUrl: async () => {},
log: (msg) => {
const found = msg.match(/https:\/\/accounts\.google\.com\/o\/oauth2\/v2\/auth\?[^\s]+/);
if (found?.[0]) {
authUrl = found[0];
}
},
note: async () => {},
prompt: async () => {
const state = new URL(authUrl).searchParams.get("state");
return `${"http://localhost:8085/oauth2callback"}?code=oauth-code&state=${state}`;
},
progress: { update: () => {}, stop: () => {} },
});
const { result } = await runRemoteLoginWithCapturedAuthUrl(loginGeminiCliOAuth);
expect(result.projectId).toBe("env-project");
expect(requests.filter((url) => url.includes("v1internal:loadCodeAssist"))).toHaveLength(3);