Add API vs Coding Plan mode selection for Z.AI auth
This commit is contained in:
@@ -60,7 +60,7 @@ describe('zai-auth command', () => {
|
||||
|
||||
it('re-prompts and stores new key when credential exists and user answers yes', async () => {
|
||||
mockLoadStoredZaiAuth.mockReturnValue({ api_key: 'existing-key', created_at: '2026-02-16T00:00:00.000Z' });
|
||||
mockReadlineAnswers(['y', 'new-zai-key']);
|
||||
mockReadlineAnswers(['y', '1', 'new-zai-key']);
|
||||
|
||||
const program = new Command();
|
||||
const { registerZaiAuthCommand } = await import('./zai-auth.js');
|
||||
@@ -77,4 +77,24 @@ describe('zai-auth command', () => {
|
||||
consoleLog.mockRestore();
|
||||
consoleError.mockRestore();
|
||||
});
|
||||
|
||||
it('supports --mode plan without interactive mode selection', async () => {
|
||||
mockLoadStoredZaiAuth.mockReturnValue(null);
|
||||
mockReadlineAnswers(['new-zai-plan-key']);
|
||||
|
||||
const program = new Command();
|
||||
const { registerZaiAuthCommand } = await import('./zai-auth.js');
|
||||
registerZaiAuthCommand(program);
|
||||
|
||||
const consoleLog = vi.spyOn(console, 'log').mockImplementation(() => undefined);
|
||||
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
|
||||
await program.parseAsync(['node', 'test', 'zai-auth', '--mode', 'plan']);
|
||||
|
||||
expect(mockStoreZaiAuth).toHaveBeenCalledWith('new-zai-plan-key');
|
||||
expect(consoleError).not.toHaveBeenCalled();
|
||||
|
||||
consoleLog.mockRestore();
|
||||
consoleError.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user