fix(core): restore group remarks in queries
Request and retain the group remark information needed by group list and group detail queries while preserving the existing safeguards for large rosters. Synchronize confirmed group remark changes with the local identity roster and persistent cache. Remote failures leave local state untouched, and missing roster entries remain observable without creating phantom groups. Add regression coverage for query mapping, request scope, persistence, failed updates, unknown groups, and closed identity stores. Fixes #304
This commit is contained in:
10 files changed
+173
-10
No files matched your search
@@ -8,7 +8,10 @@ import { SetGroupRemark } from '../../../src/oidb-services/group-admin/set-group
|
||||
|
||||
function makeDeps() {
|
||||
const r: SendPacketResult = { success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData: Buffer.alloc(0) };
|
||||
return { sendRawPacket: vi.fn(async () => r) };
|
||||
return {
|
||||
sendRawPacket: vi.fn(async () => r),
|
||||
identity: { uin: '10001', updateGroupRemark: vi.fn(() => true) },
|
||||
};
|
||||
}
|
||||
|
||||
describe('SetGroupRemark namespace', () => {
|
||||
@@ -25,4 +28,27 @@ describe('SetGroupRemark namespace', () => {
|
||||
const env = protobuf_decode<OidbBase<Oidb0xf16Req>>(bytes);
|
||||
expect(env.body?.inner).toMatchObject({ groupId: 12345n, remark: 'my group' });
|
||||
});
|
||||
|
||||
it('updates the local group roster after QQ confirms the remark', async () => {
|
||||
const deps = makeDeps();
|
||||
await SetGroupRemark.invoke(deps as any, { groupId: 12345, remark: 'my group' });
|
||||
|
||||
expect(deps.identity.updateGroupRemark).toHaveBeenCalledWith(12345, 'my group');
|
||||
});
|
||||
|
||||
it('does not update the local roster when QQ rejects the mutation', async () => {
|
||||
const deps = makeDeps();
|
||||
deps.sendRawPacket.mockResolvedValueOnce({
|
||||
success: false,
|
||||
gotResponse: true,
|
||||
errorCode: 120,
|
||||
errorMessage: 'denied',
|
||||
responseData: Buffer.alloc(0),
|
||||
});
|
||||
|
||||
await expect(
|
||||
SetGroupRemark.invoke(deps as any, { groupId: 12345, remark: 'not-applied' }),
|
||||
).rejects.toThrow();
|
||||
expect(deps.identity.updateGroupRemark).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user