payloadSchema 声明了 is_dismiss(是否解散),该字段也会出现在 build:openapi 生成的接口文档中,但 _handle 始终只调用 quitGroup:群主传 is_dismiss=true 期望解散群聊时,实际只把账号退出群聊——群没解散,账号却已经不在群里。 同一问题曾在 #1694(deae7fd4)修复过。该 PR 随后被 #1701(e6f646837, 2026-03-13)整包回滚,54 个文件全部撤销;触发原因记录在 #1700(v4.17.48 无法正常发送 JSON 卡片消息),回滚后 v4.17.49 确认修复。回滚一并删掉了 destroyGroup 与 is_dismiss 分支,本次只恢复这一条分支。 本补丁不触碰任何 schema、描述与示例字段。
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
// StreamBasic must be evaluated before OneBotAction: the two modules import each other,
|
|
// and loading OneBotAction first leaves BasicStream extending an uninitialized binding.
|
|
import '../napcat-onebot/action/stream/StreamBasic';
|
|
import { describe, expect, test, vi } from 'vitest';
|
|
import SetGroupLeave from '../napcat-onebot/action/group/SetGroupLeave';
|
|
|
|
function createAction () {
|
|
const quitGroup = vi.fn().mockResolvedValue(undefined);
|
|
const destroyGroup = vi.fn().mockResolvedValue(undefined);
|
|
const action = new SetGroupLeave(
|
|
undefined as never,
|
|
{
|
|
apis: {
|
|
GroupApi: { quitGroup, destroyGroup },
|
|
},
|
|
} as never
|
|
);
|
|
return { action, quitGroup, destroyGroup };
|
|
}
|
|
|
|
describe('set_group_leave is_dismiss', () => {
|
|
test('leaves the group when is_dismiss is absent', async () => {
|
|
const { action, quitGroup, destroyGroup } = createAction();
|
|
|
|
await action._handle({ group_id: '123' });
|
|
|
|
expect(quitGroup).toHaveBeenCalledWith('123');
|
|
expect(destroyGroup).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test('leaves the group when is_dismiss is false', async () => {
|
|
const { action, quitGroup, destroyGroup } = createAction();
|
|
|
|
await action._handle({ group_id: '123', is_dismiss: false });
|
|
|
|
expect(quitGroup).toHaveBeenCalledWith('123');
|
|
expect(destroyGroup).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test("leaves the group when is_dismiss is the string 'false'", async () => {
|
|
const { action, quitGroup, destroyGroup } = createAction();
|
|
|
|
await action._handle({ group_id: '123', is_dismiss: 'false' });
|
|
|
|
expect(quitGroup).toHaveBeenCalledWith('123');
|
|
expect(destroyGroup).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test('destroys the group when is_dismiss is true', async () => {
|
|
const { action, quitGroup, destroyGroup } = createAction();
|
|
|
|
await action._handle({ group_id: '123', is_dismiss: true });
|
|
|
|
expect(destroyGroup).toHaveBeenCalledWith('123');
|
|
expect(quitGroup).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test("destroys the group when is_dismiss is the string 'true'", async () => {
|
|
const { action, quitGroup, destroyGroup } = createAction();
|
|
|
|
await action._handle({ group_id: '123', is_dismiss: 'true' });
|
|
|
|
expect(destroyGroup).toHaveBeenCalledWith('123');
|
|
expect(quitGroup).not.toHaveBeenCalled();
|
|
});
|
|
});
|