feat(qzone): add QQ space message deletion functionality (#1978)
- Add deleteQzoneMsg API method to NTQQWebApi for deleting Qzone posts by tid - Implement buildQzoneDeleteBody to construct form-encoded request payload - Implement parseQzoneDeleteResponse to validate deletion API response - Add QzoneDeleteResponse and QzoneDeleteParams type definitions - Create DeleteQzoneMsg OneBot action handler with payload validation - Register delete_qzone_msg action in router and action handlers - Add example payload and response for DeleteQzoneMsg action - Add comprehensive unit tests for delete body construction and response parsing - Fix indentation inconsistency in createAlbumCommentRequest call
This commit is contained in:
1 parent
cbec362ed1
commit
33ee94ab0f
7 files changed
+121
-4
No files matched your search
@@ -1,7 +1,9 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import {
|
||||
buildQzoneDeleteBody,
|
||||
buildQzonePublishBody,
|
||||
buildQzoneUploadImageBody,
|
||||
parseQzoneDeleteResponse,
|
||||
parseQzonePublishResponse,
|
||||
parseQzoneUploadImageResponseText,
|
||||
toQzoneRichval,
|
||||
@@ -91,4 +93,28 @@ describe('Qzone data helpers', () => {
|
||||
test('parseQzonePublishResponse throws when tid missing', () => {
|
||||
expect(() => parseQzonePublishResponse({ subcode: 0 })).toThrow();
|
||||
});
|
||||
|
||||
test('buildQzoneDeleteBody encodes required fields', () => {
|
||||
const body = buildQzoneDeleteBody({ hostuin: '123456', tid: 'tid123' });
|
||||
const params = new URLSearchParams(body);
|
||||
expect(params.get('hostuin')).toBe('123456');
|
||||
expect(params.get('tid')).toBe('tid123');
|
||||
expect(params.get('t1_source')).toBe('1');
|
||||
expect(params.get('code_version')).toBe('1');
|
||||
expect(params.get('format')).toBe('json');
|
||||
expect(params.get('qzreferrer')).toContain('123456');
|
||||
});
|
||||
|
||||
test('parseQzoneDeleteResponse succeeds when subcode is 0', () => {
|
||||
const result = parseQzoneDeleteResponse({ subcode: 0 });
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
test('parseQzoneDeleteResponse throws when subcode indicates failure', () => {
|
||||
expect(() => parseQzoneDeleteResponse({ subcode: -200, message: '权限不足' })).toThrow('权限不足');
|
||||
});
|
||||
|
||||
test('parseQzoneDeleteResponse throws with default message when subcode indicates failure without message', () => {
|
||||
expect(() => parseQzoneDeleteResponse({ subcode: -200 })).toThrow('subcode=-200');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user