const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const source = fs.readFileSync('background/steps/open-chatgpt.js', 'utf8'); const globalScope = {}; const api = new Function('self', `${source}; return self.MultiPageBackgroundStep1;`)(globalScope); test('step 1 clears login state before opening signup entry tab', async () => { const calls = []; const executor = api.createStep1Executor({ addLog: async () => {}, completeStepFromBackground: async () => { calls.push('complete'); }, openSignupEntryTab: async (_step, options) => { calls.push(['open', options]); }, runPreStep1SessionCleanup: async () => { calls.push('cleanup'); }, }); await executor.executeStep1(); assert.deepStrictEqual(calls, [ 'cleanup', ['open', { reloadIfSameUrl: true }], 'complete', ]); });