feat(group-album): expose cover and upload metadata
Decode the verified album cover response field and expose normalized cover details and last-upload timestamps through both album list actions. Preserve the legacy numeric timestamp shape, retain string timestamps for the native response, return null when no cover exists, and avoid additional network requests. Document the new output contracts in the OneBot and MCP catalogs. Add independent wire fixtures and action-level regression tests for the protocol mapping and public response shapes. Refs #257
This commit is contained in:
9 files changed
+841
-5
No files matched your search
@@ -37,6 +37,30 @@ describe('action-docs', () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each(['get_group_album_list', 'get_qun_album_list'])(
|
||||
'documents album cover and last-upload metadata for %s',
|
||||
(name) => {
|
||||
const action = docs.find((d) => d.name === name);
|
||||
const rootProperties = action?.returnsSchema?.properties as Record<string, any> | undefined;
|
||||
const itemProperties = name === 'get_group_album_list'
|
||||
? (action?.returnsSchema?.items as any)?.properties
|
||||
: rootProperties?.album_list?.items?.properties;
|
||||
|
||||
expect(itemProperties).toEqual(expect.objectContaining({
|
||||
last_upload_time: expect.objectContaining({
|
||||
type: name === 'get_group_album_list' ? 'integer' : 'string',
|
||||
}),
|
||||
cover: expect.objectContaining({ type: ['object', 'null'] }),
|
||||
}));
|
||||
expect(itemProperties.cover.properties.image.properties).toEqual(expect.objectContaining({
|
||||
photoUrls: expect.objectContaining({ type: 'array' }),
|
||||
defaultUrl: expect.objectContaining({ type: ['object', 'null'] }),
|
||||
isGif: expect.objectContaining({ type: 'boolean' }),
|
||||
hasRaw: expect.objectContaining({ type: 'boolean' }),
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
it('renders markdown with header + an action section', () => {
|
||||
const md = renderActionDocsMarkdown(docs);
|
||||
expect(md).toContain('# OneBot Actions');
|
||||
|
||||
@@ -1324,13 +1324,39 @@ describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
|
||||
});
|
||||
|
||||
// ─── napcat-parity: get_qun_album_list (QQ NT AlbumService) ───
|
||||
describe('extended-actions / get_group_album_list', () => {
|
||||
it('returns the cover and last-upload metadata from the core facade', async () => {
|
||||
const albumList = [{
|
||||
id: 'a1',
|
||||
name: '相册一',
|
||||
picNum: 5,
|
||||
createTime: 1700000000,
|
||||
desc: '',
|
||||
owner: '10001',
|
||||
createuin: '10001',
|
||||
createnickname: '测试用户',
|
||||
last_upload_time: 1700000123,
|
||||
cover: { type: 1, image: null },
|
||||
}];
|
||||
const list = vi.fn(async () => albumList);
|
||||
const bridge = fakeBridge({ apis: { groupAlbum: { list } } });
|
||||
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('get_group_album_list', { group_id: 12345 });
|
||||
|
||||
expect(list).toHaveBeenCalledWith(12345);
|
||||
expect(res).toMatchObject({ status: 'ok', data: albumList });
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended-actions / get_qun_album_list', () => {
|
||||
it('forwards the pagination cursor and returns the native AlbumService envelope', async () => {
|
||||
const albumList = [{
|
||||
album_id: 'a1',
|
||||
name: '相册一',
|
||||
create_time: '1700000000',
|
||||
last_upload_time: '1700000123',
|
||||
upload_number: '5',
|
||||
cover: { type: 1, image: null },
|
||||
creator: { uin: '10001', nick: '😂[em]e328514[/em]' },
|
||||
}];
|
||||
const listQun = vi.fn(async () => ({
|
||||
|
||||
Reference in new issue
Block a user