9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
navigateToProject: vi.fn(),
|
|
selectChatGPTModel: vi.fn(),
|
|
}));
|
|
|
|
vi.mock('./utils.js', () => ({
|
|
CHATGPT_DOMAIN: 'chatgpt.com',
|
|
CHATGPT_MODEL_CHOICES: ['fast', 'speed', 'instant', 'balanced', 'advanced', 'high', 'thinking', 'very-high', 'pro'],
|
|
navigateToProject: mocks.navigateToProject,
|
|
selectChatGPTModel: mocks.selectChatGPTModel,
|
|
}));
|
|
|
|
const { modelCommand } = await import('./model.js');
|
|
|
|
beforeEach(() => {
|
|
vi.restoreAllMocks();
|
|
mocks.navigateToProject.mockReset().mockResolvedValue(undefined);
|
|
mocks.selectChatGPTModel.mockReset().mockResolvedValue({ Status: 'Success', Model: 'High' });
|
|
});
|
|
|
|
describe('chatgpt model project routing', () => {
|
|
it('opens a project before selecting the requested model', async () => {
|
|
const page = {};
|
|
|
|
await expect(modelCommand.func(page, { model: 'high', project: '12345678' }))
|
|
.resolves.toEqual([{ Status: 'Success', Model: 'High' }]);
|
|
|
|
expect(mocks.navigateToProject).toHaveBeenCalledWith(page, '12345678');
|
|
expect(mocks.navigateToProject.mock.invocationCallOrder[0]).toBeLessThan(
|
|
mocks.selectChatGPTModel.mock.invocationCallOrder[0],
|
|
);
|
|
expect(mocks.selectChatGPTModel).toHaveBeenCalledWith(page, 'high');
|
|
});
|
|
});
|