Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: show Google OAuth setup progress in Calendar and Messages (#11020)

Adam Eivyb2de785ff53d
diff --git a/client/src/components/calendar/ConfigTab.jsx b/client/src/components/calendar/ConfigTab.jsx
index fe3d49ba96..7c2ca6d0f8 100644
--- a/client/src/components/calendar/ConfigTab.jsx
+++ b/client/src/components/calendar/ConfigTab.jsx
@@ -8,6 +8,7 @@ import FeatureProviderPicker from '../FeatureProviderPicker';
import InlineConfirmRow from '../ui/InlineConfirmRow';
import { FormField } from '../ui/FormField';
import { useConfirmDelete } from '../../hooks/useConfirmDelete';
+import { useGoogleAutoConfigProgress } from '../../hooks/useGoogleAutoConfigProgress';
import { DEFAULT_AVATAR_COLOR } from '../../themes/portosThemes';
const TYPE_ICONS = { 'outlook-calendar': Globe, 'google-calendar': Calendar };
@@ -30,6 +31,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
const [clearingGoogleAuth, setClearingGoogleAuth] = useState(false);
const [oauthForm, setOauthForm] = useState({ clientId: '', clientSecret: '' });
const [savingOAuth, setSavingOAuth] = useState(false);
+ const { progress: autoConfigProgress, run: runAutoConfig, mounted: autoConfigMounted } = useGoogleAutoConfigProgress();
const [autoConfigStep, setAutoConfigStep] = useState(null); // null | 'launching' | 'login' | 'project' | 'api' | 'consent' | 'credentials' | 'capturing' | 'done'
const fetchGoogleAuth = async () => {
@@ -110,7 +112,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
// Find the google account's email to pass as test user
const googleAccount = accounts.find(a => a.type === 'google-calendar');
const email = googleAccount?.email || '';
- const result = await api.runGoogleAutoConfig(email, { silent: true }).catch(() => null);
+ const result = await runAutoConfig(email);
+ if (!autoConfigMounted.current) return;
if (!result || result.error) {
setAutoConfigStep('login');
return toast.error(result?.error || 'Automated setup failed. Try manual setup instead.');
@@ -441,9 +444,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
) : autoConfigStep === 'running' ? (
<div className="flex items-center gap-2 p-3 bg-port-bg/80 rounded border border-port-border">
<RefreshCw size={14} className="text-port-accent animate-spin shrink-0" />
- <div className="text-xs text-gray-400">
- Automating Google Cloud setup... enabling Calendar API, configuring OAuth consent, creating credentials.
- This may take up to a minute.
+ <div className="text-xs text-gray-400" role="status" aria-live="polite">
+ {autoConfigProgress?.message || 'Automating Google Cloud setup... This may take up to a minute.'}
</div>
</div>
) : autoConfigStep === 'login' ? (
diff --git a/client/src/components/calendar/googleAutoConfigProgress.test.jsx b/client/src/components/calendar/googleAutoConfigProgress.test.jsx
new file mode 100644
index 0000000000..49d50b0f50
--- /dev/null
+++ b/client/src/components/calendar/googleAutoConfigProgress.test.jsx
@@ -0,0 +1,97 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { act, fireEvent, render, screen } from '@testing-library/react';
+import { MemoryRouter } from 'react-router';
+import CalendarConfig from './ConfigTab';
+import MessagesConfig from '../messages/ConfigTab';
+
+const api = vi.hoisted(() => ({
+ getGoogleAuthStatus: vi.fn(), startGoogleAutoConfig: vi.fn(), getSettings: vi.fn(), getGoogleAuthUrl: vi.fn(),
+}));
+const runGoogleAutoConfig = vi.hoisted(() => vi.fn());
+const socket = vi.hoisted(() => ({ on: vi.fn(), off: vi.fn() }));
+const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }));
+vi.mock('../../services/api', () => api);
+vi.mock('../../services/apiCalendar', () => ({ runGoogleAutoConfig }));
+vi.mock('../../services/socket', () => ({ default: socket }));
+vi.mock('../ui/Toast', () => ({ default: toast }));
+vi.mock('../FeatureProviderPicker', () => ({ default: () => null }));
+vi.mock('../ProviderModelSelector', () => ({ default: () => null }));
+vi.mock('../../hooks/useProviderModels', () => ({ default: () => ({ providers: [], availableModels: [] }) }));
+
+const EVENT = 'calendar:google:autoconfig';
+let listeners;
+let settle;
+beforeEach(() => {
+ vi.clearAllMocks();
+ listeners = new Set();
+ socket.on.mockImplementation((event, listener) => { if (event === EVENT) listeners.add(listener); });
+ socket.off.mockImplementation((event, listener) => { if (event === EVENT) listeners.delete(listener); });
+ api.getGoogleAuthStatus.mockResolvedValue({ hasCredentials: false, hasTokens: false });
+ api.getSettings.mockResolvedValue({ messages: {} });
+ api.getGoogleAuthUrl.mockResolvedValue({ url: null });
+ api.startGoogleAutoConfig.mockResolvedValue({ status: 'login' });
+ runGoogleAutoConfig.mockImplementation(() => {
+ expect(listeners.size).toBe(1); // Listener must exist before HTTP dispatch.
+ return new Promise(resolve => { settle = resolve; });
+ });
+});
+
+for (const [name, Component, type] of [['Calendar', CalendarConfig, 'google-calendar'], ['Messages', MessagesConfig, 'gmail']]) {
+ describe(`${name} automated Google setup progress`, () => {
+ async function start() {
+ const view = render(<MemoryRouter><Component accounts={[{ id: 'example', name: 'Example', type, syncMethod: 'google-api' }]} setAccounts={vi.fn()} /></MemoryRouter>);
+ if (name === 'Calendar') fireEvent.click(screen.getByRole('button', { name: 'Expand calendars for Example' }));
+ fireEvent.click(await screen.findByRole('button', { name: /(?:Setup with|Set up with) PortOS Browser/ }));
+ fireEvent.click(await screen.findByRole('button', { name: 'Continue' }));
+ return view;
+ }
+ const emit = (requestId, step, message) => act(() => {
+ for (const listener of listeners) listener({ requestId, step, message });
+ });
+
+ it('renders correlated stages while HTTP is pending and ignores duplicates, foreign and settled frames', async () => {
+ const view = await start();
+ const requestId = runGoogleAutoConfig.mock.calls[0][1].requestId;
+ const staleListener = [...listeners][0];
+ emit(requestId, 'enable-api', 'Enabling Calendar API...');
+ expect(screen.getByRole('status')).toHaveTextContent('Enabling Calendar API...');
+ emit('other-request', 'consent', 'Unrelated progress');
+ expect(screen.queryByText('Unrelated progress')).not.toBeInTheDocument();
+ emit(requestId, 'consent', 'Configuring OAuth consent...');
+ emit(requestId, 'enable-api', 'Enabling Calendar API...'); // An old duplicate cannot regress the stage.
+ expect(screen.getByRole('status')).toHaveTextContent('Configuring OAuth consent...');
+ emit(requestId, 'capturing', 'Extracting credentials...');
+ expect(screen.getByRole('status')).toHaveTextContent('Extracting credentials...');
+ emit(requestId, 'done', 'Credentials captured and saved!');
+ expect(screen.getByRole('status')).toHaveTextContent('Credentials captured and saved!');
+ expect(toast.success).not.toHaveBeenCalledWith(name === 'Calendar' ? 'Google OAuth setup complete!' : 'Google OAuth setup complete');
+ expect(screen.queryByRole('button', { name: 'Continue' })).not.toBeInTheDocument();
+ await act(async () => settle({ status: 'success' }));
+ expect(toast.success).toHaveBeenCalledWith(name === 'Calendar' ? 'Google OAuth setup complete!' : 'Google OAuth setup complete');
+ expect(listeners.size).toBe(0);
+ act(() => staleListener({ requestId, step: 'consent', message: 'Late progress' }));
+ expect(screen.queryByRole('status')).not.toBeInTheDocument();
+ view.unmount();
+ });
+
+ it('retries HTTP failures with a fresh ID and cleans up an unmounted pending run', async () => {
+ const view = await start();
+ const oldId = runGoogleAutoConfig.mock.calls[0][1].requestId;
+ await act(async () => settle({ error: 'Synthetic setup failure' }));
+ expect(toast.error).toHaveBeenCalledWith('Synthetic setup failure');
+ expect(listeners.size).toBe(0);
+ fireEvent.click(screen.getByRole('button', { name: 'Continue' }));
+ const newId = runGoogleAutoConfig.mock.calls[1][1].requestId;
+ expect(newId).not.toBe(oldId);
+ expect(listeners.size).toBe(1);
+ emit(oldId, 'capturing', 'Previous run');
+ expect(screen.queryByText('Previous run')).not.toBeInTheDocument();
+ const staleListener = [...listeners][0];
+ view.unmount();
+ expect(listeners.size).toBe(0);
+ act(() => staleListener({ requestId: newId, step: 'done', message: 'Unmounted run' }));
+ await act(async () => settle({ status: 'success' }));
+ expect(toast.success).not.toHaveBeenCalledWith(name === 'Calendar' ? 'Google OAuth setup complete!' : 'Google OAuth setup complete');
+ });
+ });
+}
diff --git a/client/src/components/messages/ConfigTab.jsx b/client/src/components/messages/ConfigTab.jsx
index 94731b44d2..46ac7f1d0a 100644
--- a/client/src/components/messages/ConfigTab.jsx
+++ b/client/src/components/messages/ConfigTab.jsx
@@ -9,6 +9,7 @@ import useProviderModels from '../../hooks/useProviderModels';
import InlineConfirmRow from '../ui/InlineConfirmRow';
import { FormField } from '../ui/FormField';
import { useConfirmDelete } from '../../hooks/useConfirmDelete';
+import { useGoogleAutoConfigProgress } from '../../hooks/useGoogleAutoConfigProgress';
const TYPE_ICONS = { gmail: Mail, outlook: Globe, teams: MessageSquare };
const TYPE_LABELS = { gmail: 'Gmail (API)', outlook: 'Outlook (Playwright)', teams: 'Teams (Playwright)' };
@@ -40,6 +41,7 @@ export default function ConfigTab({ accounts, setAccounts }) {
const [oauthForm, setOauthForm] = useState({ clientId: '', clientSecret: '' });
const [savingOAuth, setSavingOAuth] = useState(false);
const [reauthorizing, setReauthorizing] = useState(false);
+ const { progress: autoConfigProgress, run: runAutoConfig, mounted: autoConfigMounted } = useGoogleAutoConfigProgress();
const [autoConfigStep, setAutoConfigStep] = useState(null);
// AI config
@@ -149,7 +151,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
const handleAutoConfigContinue = async () => {
setAutoConfigStep('running');
const email = accounts.find(a => a.type === 'gmail')?.email || '';
- const result = await api.runGoogleAutoConfig(email, { silent: true }).catch(() => null);
+ const result = await runAutoConfig(email);
+ if (!autoConfigMounted.current) return;
if (!result || result.error) {
setAutoConfigStep('login');
return toast.error(result?.error || 'Automated setup failed. Try manual setup instead.');
@@ -338,8 +341,8 @@ export default function ConfigTab({ accounts, setAccounts }) {
) : autoConfigStep === 'running' ? (
<div className="flex items-center gap-2 rounded border border-port-border bg-port-bg/80 p-3">
<RefreshCw size={14} className="shrink-0 animate-spin text-port-accent" />
- <p className="text-xs text-gray-400">
- Enabling Google APIs, configuring OAuth consent, and creating credentials. This may take up to a minute.
+ <p className="text-xs text-gray-400" role="status" aria-live="polite">
+ {autoConfigProgress?.message || 'Automating Google Cloud setup... This may take up to a minute.'}
</p>
</div>
) : autoConfigStep === 'login' ? (
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 57029e3535..18b00e6570 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -40,6 +40,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| Hook | Purpose | Use when |
|---|---|---|
+| `useGoogleAutoConfigProgress` | Request-correlated Google OAuth setup progress with HTTP settlement and listener cleanup. | Calendar and Messages automated setup. |
| `useQuotaUpdates` | Reconcile quota cards on scrape completion, reconnect and tab show; the caller owns the entry read. | Usage, Subscriptions and Quota Burn quota cards. |
| `useSseProgress` | Generic JSON-frame EventSource subscriber. | New SSE progress stream — start here, build on top. |
| `useSseJobSlot` | Generic single-slot SSE job: captured target from preparation through completion, terminal-frame handling (`complete`/`error`/`canceled`), and `sse.closed`-without-terminal-frame recovery in one place. Returns `{ active, pending, jobId, percent, stage, context, start, attach, cancel }` (`attach(jobId, context)` adopts a job another request already started into the idle slot); reserves synchronously, exposes context during kickoff and ignores unmounted responses. Optional `readPercent` adapts other progress scales; `connected` distinguishes a live stream from reconnecting, and `onSettled(reason, context)` refreshes persisted state after completion, failure, cancellation or a terminal disconnect. Pass `startRequest`/`eventsUrl`/`cancelRequest` + per-feature toast copy. | Any "kick off a job → stream SSE → settle on terminal frame" hook. The reference-audio/YouTube/video-download/MIDI/music-video-render hooks all wrap this — don't re-roll the terminal-frame + lost-connection dance. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index f27fcf0244..de0c7b3c3f 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -282,3 +282,5 @@ export { default as useMusicVideoProductionReview } from './useMusicVideoProduct
export * from './useCalendarWindowEvents.js';
export * from './useMusicVideoReviewDraft.js';
+
+export * from './useGoogleAutoConfigProgress.js';
diff --git a/client/src/hooks/useGoogleAutoConfigProgress.js b/client/src/hooks/useGoogleAutoConfigProgress.js
new file mode 100644
index 0000000000..251617dcc8
--- /dev/null
+++ b/client/src/hooks/useGoogleAutoConfigProgress.js
@@ -0,0 +1,44 @@
+import { useEffect, useRef, useState } from 'react';
+import socket from '../services/socket';
+import { runGoogleAutoConfig } from '../services/apiCalendar';
+import useMounted from './useMounted';
+import { uuidv4 } from '../lib/uuid';
+
+const EVENT = 'calendar:google:autoconfig';
+
+// Subscribe synchronously before dispatch; HTTP alone settles the operation.
+export function useGoogleAutoConfigProgress() {
+ const [progress, setProgress] = useState(null);
+ const active = useRef(null);
+ const mounted = useMounted();
+
+ useEffect(() => () => {
+ active.current?.unsubscribe();
+ active.current = null;
+ }, []);
+
+ const run = async (email) => {
+ if (active.current) return null;
+ const requestId = uuidv4();
+ const seen = new Set();
+ const listener = (frame) => {
+ if (active.current?.requestId !== requestId || frame?.requestId !== requestId
+ || typeof frame.step !== 'string' || typeof frame.message !== 'string') return;
+ const key = JSON.stringify([frame.step, frame.message]);
+ if (seen.has(key)) return;
+ seen.add(key);
+ setProgress({ step: frame.step, message: frame.message });
+ };
+ const unsubscribe = () => socket.off(EVENT, listener);
+ active.current = { requestId, unsubscribe };
+ setProgress(null);
+ socket.on(EVENT, listener);
+ return runGoogleAutoConfig(email, { silent: true, requestId }).catch(() => null).finally(() => {
+ unsubscribe();
+ if (active.current?.requestId === requestId) active.current = null;
+ if (mounted.current) setProgress(null);
+ });
+ };
+
+ return { progress, run, mounted };
+}
diff --git a/client/src/services/apiCalendar.js b/client/src/services/apiCalendar.js
index 4288581da5..6720377fbf 100644
--- a/client/src/services/apiCalendar.js
+++ b/client/src/services/apiCalendar.js
@@ -27,7 +27,7 @@ export const clearGoogleAuth = () => request('/calendar/google/auth/clear', { me
export const apiSyncGoogleCalendar = (accountId, options = {}) => request(`/calendar/sync/${accountId}/api`, { method: 'POST', ...options });
export const apiDiscoverCalendars = (accountId) => request(`/calendar/sync/${accountId}/discover-api`, { method: 'POST' });
export const startGoogleAutoConfig = (options = {}) => request('/calendar/google/auto-configure/start', { method: 'POST', ...options });
-export const runGoogleAutoConfig = (email, options = {}) => request('/calendar/google/auto-configure/run', { method: 'POST', body: JSON.stringify({ email }), ...options });
+export const runGoogleAutoConfig = (email, { requestId, ...options } = {}) => request('/calendar/google/auto-configure/run', { method: 'POST', body: JSON.stringify({ email, ...(requestId ? { requestId } : {}) }), ...options });
export const getDailyReview = (date, params = {}, options = {}) => {
const str = new URLSearchParams(Object.entries(params).filter(([, v]) => v != null)).toString();
return request(`/calendar/review/${date}${str ? `?${str}` : ''}`, options);
diff --git a/client/src/services/apiCalendar.test.js b/client/src/services/apiCalendar.test.js
new file mode 100644
index 0000000000..d271799c39
--- /dev/null
+++ b/client/src/services/apiCalendar.test.js
@@ -0,0 +1,17 @@
+import { describe, expect, it, vi } from 'vitest';
+import { runGoogleAutoConfig } from './apiCalendar';
+import { request } from './apiCore';
+vi.mock('./apiCore', () => ({ request: vi.fn().mockResolvedValue({ status: 'success' }) }));
+
+describe('Google automation request payload', () => {
+ it('sends correlation in the body while preserving request options and legacy payloads', async () => {
+ await runGoogleAutoConfig('[email protected]', { requestId: 'invented-run-1', silent: true });
+ expect(request).toHaveBeenLastCalledWith('/calendar/google/auto-configure/run', {
+ method: 'POST', body: JSON.stringify({ email: '[email protected]', requestId: 'invented-run-1' }), silent: true,
+ });
+ await runGoogleAutoConfig('[email protected]');
+ expect(request).toHaveBeenLastCalledWith('/calendar/google/auto-configure/run', {
+ method: 'POST', body: JSON.stringify({ email: '[email protected]' }),
+ });
+ });
+});
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 9c4b023725..beab9c4107 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -2765,7 +2765,10 @@ export const dailyReviewQuerySchema = z.object({
offset: z.coerce.number().int().min(0).default(0),
});
-export const calendarAutoConfigureBodySchema = z.object({ email: optionalString });
+export const calendarAutoConfigureBodySchema = z.object({
+ email: optionalString,
+ requestId: z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).optional(),
+});
export const commandExecuteBodySchema = z.object({ command: nonEmptyString, workspacePath: nullishString });
export const dataArchiveBodySchema = z.object({
daysToKeep: z.preprocess((value) => (value == null ? undefined : value), z.coerce.number().finite().min(0).optional()),
diff --git a/server/routes/calendar.js b/server/routes/calendar.js
index 5c27a208cf..24554888d3 100644
--- a/server/routes/calendar.js
+++ b/server/routes/calendar.js
@@ -381,8 +381,8 @@ router.post('/google/auto-configure/capture', asyncHandler(async (req, res) => {
router.post('/google/auto-configure/run', asyncHandler(async (req, res) => {
const io = req.app.get('io');
- const { email = '' } = validateRequest(calendarAutoConfigureBodySchema, req.body ?? {});
- const result = await googleOAuthAutoConfig.runAutomatedSetup(email, io);
+ const { email = '', requestId } = validateRequest(calendarAutoConfigureBodySchema, req.body ?? {});
+ const result = await googleOAuthAutoConfig.runAutomatedSetup(email, io, requestId);
res.json(result);
}));
diff --git a/server/routes/calendar.test.js b/server/routes/calendar.test.js
index 86936e80b3..4d52592993 100644
--- a/server/routes/calendar.test.js
+++ b/server/routes/calendar.test.js
@@ -167,6 +167,29 @@ describe('Calendar Routes — normalized error handling', () => {
});
});
+ describe('Google automation request correlation', () => {
+ it('passes optional request IDs through and preserves email-only callers and responses', async () => {
+ const io = { emit: vi.fn() };
+ app.set('io', io);
+ const result = { status: 'success', clientId: 'synthetic-client', authUrl: null };
+ googleOAuthAutoConfig.runAutomatedSetup.mockResolvedValue(result);
+ for (const requestId of ['invented-run-1', undefined]) {
+ const response = await request(app).post('/api/calendar/google/auto-configure/run')
+ .send({ email: '[email protected]', ...(requestId ? { requestId } : {}) });
+ expect(response.status).toBe(200);
+ expect(response.body).toEqual(result);
+ expect(googleOAuthAutoConfig.runAutomatedSetup).toHaveBeenLastCalledWith('[email protected]', io, requestId);
+ }
+ });
+
+ it.each(['', 'bad id', 'x'.repeat(129), 42, null])('rejects malformed request ID %j before automation', async (requestId) => {
+ googleOAuthAutoConfig.runAutomatedSetup.mockClear();
+ const response = await request(app).post('/api/calendar/google/auto-configure/run').send({ requestId });
+ expect(response.status).toBe(400);
+ expect(googleOAuthAutoConfig.runAutomatedSetup).not.toHaveBeenCalled();
+ });
+ });
+
describe('success passthrough', () => {
it('POST /sync/:accountId returns the sync result as-is', async () => {
calendarSync.syncAccount.mockResolvedValue({ newEvents: 3, pruned: 1, total: 42, status: 'success' });
diff --git a/server/services/googleOAuthAutoConfig.js b/server/services/googleOAuthAutoConfig.js
index 66fc7f484f..c9d18e6fb9 100644
--- a/server/services/googleOAuthAutoConfig.js
+++ b/server/services/googleOAuthAutoConfig.js
@@ -130,10 +130,10 @@ export async function runSteps(steps) {
}
}
-export async function runAutomatedSetup(userEmail, io) {
+export async function runAutomatedSetup(userEmail, io, requestId) {
console.log('📅 Running automated Google OAuth setup via CDP');
const emit = (step, message) => {
- io?.emit('calendar:google:autoconfig', { step, message });
+ io?.emit('calendar:google:autoconfig', { step, message, ...(requestId ? { requestId } : {}) });
console.log(`📅 Auto-config: ${message}`);
};
diff --git a/server/services/googleOAuthAutoConfig.test.js b/server/services/googleOAuthAutoConfig.test.js
index 45bdabfbf9..10261cadc4 100644
--- a/server/services/googleOAuthAutoConfig.test.js
+++ b/server/services/googleOAuthAutoConfig.test.js
@@ -1,6 +1,10 @@
import { afterEach, describe, expect, it, vi } from "vitest";
-import { runSteps } from "./googleOAuthAutoConfig.js";
+vi.mock('./messagePlaywrightSync.js', () => ({ getPages: vi.fn(), evaluateOnPage: vi.fn(), findOrOpenPage: vi.fn() }));
+vi.mock('./browserService.js', () => ({ navigateToUrl: vi.fn() }));
+import { getPages } from './messagePlaywrightSync.js';
+import { navigateToUrl } from './browserService.js';
+import { runSteps, runAutomatedSetup } from "./googleOAuthAutoConfig.js";
describe("runSteps", () => {
afterEach(() => {
@@ -55,3 +59,19 @@ describe("runSteps", () => {
expect(laterStep).not.toHaveBeenCalled();
});
});
+
+// Stop at mocked navigation after the first real progress emit: no Google account or changes.
+describe('automated setup progress wire contract', () => {
+ it('echoes correlation without account or project details and keeps legacy frames compatible', async () => {
+ vi.spyOn(console, 'log').mockImplementation(() => {});
+ getPages.mockResolvedValue([{ url: 'https://console.cloud.google.com/?project=synthetic-project' }]);
+ navigateToUrl.mockRejectedValue(new Error('Synthetic navigation stop'));
+ for (const requestId of ['invented-run-1', undefined]) {
+ const io = { emit: vi.fn() };
+ await expect(runAutomatedSetup('[email protected]', io, requestId)).rejects.toThrow('Synthetic navigation stop');
+ expect(io.emit).toHaveBeenCalledExactlyOnceWith('calendar:google:autoconfig', {
+ step: 'enable-api', message: 'Enabling Google Calendar API...', ...(requestId ? { requestId } : {}),
+ });
+ }
+ });
+});