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
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { getRegistry } from '@jackwener/opencli/registry';
|
|
import './topic.js';
|
|
describe('zsxq topic command', () => {
|
|
beforeEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
it('maps topic detail 404 responses to NOT_FOUND before fetching comments', async () => {
|
|
const command = getRegistry().get('zsxq/topic');
|
|
expect(command?.func).toBeTypeOf('function');
|
|
const mockPage = {
|
|
goto: vi.fn().mockResolvedValue(undefined),
|
|
evaluate: vi.fn()
|
|
.mockResolvedValueOnce(true) // ensureZsxqAuth
|
|
.mockResolvedValueOnce('12345') // getActiveGroupId
|
|
.mockResolvedValueOnce({
|
|
ok: true,
|
|
status: 404,
|
|
url: 'https://api.zsxq.com/v2/groups/12345/topics/404',
|
|
data: null,
|
|
}),
|
|
};
|
|
await expect(command.func(mockPage, { id: '404', comment_limit: 20 })).rejects.toMatchObject({
|
|
code: 'NOT_FOUND',
|
|
message: 'Topic 404 not found',
|
|
});
|
|
expect(mockPage.goto).toHaveBeenCalledWith('https://wx.zsxq.com');
|
|
expect(mockPage.evaluate).toHaveBeenCalledTimes(3);
|
|
});
|
|
});
|