fix(onebot): expose group descriptions separately (#491)
Expose group descriptions without replacing the existing group memo behavior. Fixes #490 Refs #491
This commit is contained in:
10 files changed
+170
-1
No files matched your search
@@ -228,10 +228,44 @@ describe('onebot/contact-actions / getGroupList', () => {
|
||||
group_remark: '工作群',
|
||||
member_count: 0, max_member_count: 500,
|
||||
group_create_time: 0, group_level: 0, group_memo: '',
|
||||
group_description: '',
|
||||
group_all_shut: -1,
|
||||
}]);
|
||||
});
|
||||
|
||||
// #490: group_description must carry the description itself, not a copy of
|
||||
// group_memo (which prefers the announcement).
|
||||
it('exposes the group description separately from the memo (#490)', async () => {
|
||||
const fetched = [{
|
||||
...makeGroup(150, 'Both Set'),
|
||||
memo: '公告正文',
|
||||
description: '简介正文',
|
||||
}];
|
||||
const bridge = fakeBridge({
|
||||
fetchGroupList: vi.fn(async () => fetched),
|
||||
identity: fakeIdentity({ groups: fetched }),
|
||||
});
|
||||
|
||||
const out = await getGroupList(bridge);
|
||||
|
||||
expect(out[0]).toMatchObject({
|
||||
group_memo: '公告正文',
|
||||
group_description: '简介正文',
|
||||
});
|
||||
});
|
||||
|
||||
it('reports an empty group_description when QQ returns no description (#490)', async () => {
|
||||
const fetched = [makeGroup(160, 'No Description')];
|
||||
const bridge = fakeBridge({
|
||||
fetchGroupList: vi.fn(async () => fetched),
|
||||
identity: fakeIdentity({ groups: fetched }),
|
||||
});
|
||||
|
||||
const out = await getGroupList(bridge);
|
||||
|
||||
expect(out[0]).toMatchObject({ group_memo: '', group_description: '' });
|
||||
});
|
||||
|
||||
it('skips fetch when cache is populated and noCache is omitted', async () => {
|
||||
const cached = [makeGroup(200, 'Group B')];
|
||||
const bridge = fakeBridge({
|
||||
|
||||
@@ -117,6 +117,23 @@ describe('group information actions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// #490: group_memo prefers the announcement, so the group description needs
|
||||
// its own documented field.
|
||||
it('documents the group description on both group-info results', async () => {
|
||||
const infoSchema = getGroupInfo.describe().returnsSchema;
|
||||
const listSchema = getGroupList.describe().returnsSchema;
|
||||
|
||||
expect(infoSchema?.properties).toHaveProperty('group_description');
|
||||
expect(listSchema?.items?.properties).toHaveProperty('group_description');
|
||||
// Never required: only the group list carries it, so a non-member lookup
|
||||
// legitimately returns ''.
|
||||
expect(infoSchema?.required ?? []).not.toContain('group_description');
|
||||
|
||||
// The no-provider fallback must still carry the key.
|
||||
const response = await getGroupInfo.toHandler({} as any)({ group_id: 123456 });
|
||||
expect(response).toMatchObject({ status: 'ok', data: { group_description: '' } });
|
||||
});
|
||||
|
||||
it('documents qidian flags on both member-list and single-member results', () => {
|
||||
const listSchema = getGroupMemberList.describe().returnsSchema;
|
||||
const infoSchema = getGroupMemberInfo.describe().returnsSchema;
|
||||
|
||||
@@ -730,6 +730,7 @@ describe('buildApiContext contact reads', () => {
|
||||
group_create_time: 100,
|
||||
group_level: 2,
|
||||
group_memo: 'rules',
|
||||
group_description: '',
|
||||
group_all_shut: -1,
|
||||
}]);
|
||||
expect(fetchGroupList).not.toHaveBeenCalled();
|
||||
@@ -758,6 +759,7 @@ describe('buildApiContext contact reads', () => {
|
||||
group_create_time: 0,
|
||||
group_level: 6,
|
||||
group_memo: '',
|
||||
group_description: '',
|
||||
group_all_shut: 0,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user