feat(onebot): add actions for group category tags
get_group_tags lists the tags under one group category. add_group_tag and delete_group_tag add or remove a tag by name. Callers pass the category number as group_class. An empty name is rejected. Refs #506
This commit is contained in:
6 files changed
+552
-3
No files matched your search
@@ -31,6 +31,9 @@ import {
|
||||
type GroupMemberPermission,
|
||||
} from '@snowluma/protocol/oidb-services/group-admin/set-member-permission';
|
||||
import { SetSearch } from '@snowluma/protocol/oidb-services/group-admin/set-search';
|
||||
import { GetGroupCategoryTags } from '@snowluma/protocol/oidb-services/group-admin/get-group-category-tags';
|
||||
import { AddGroupCategoryTag } from '@snowluma/protocol/oidb-services/group-admin/add-group-category-tag';
|
||||
import { DeleteGroupCategoryTag } from '@snowluma/protocol/oidb-services/group-admin/delete-group-category-tag';
|
||||
import { SetSpecialTitle } from '@snowluma/protocol/oidb-services/group-admin/set-special-title';
|
||||
import { ModifyGroupExtInfo } from '@snowluma/protocol/oidb-services/group-admin/modify-group-ext-info';
|
||||
import { OidbError } from '@snowluma/protocol/oidb-service';
|
||||
@@ -117,6 +120,18 @@ export class GroupAdminApi {
|
||||
return SetSearch.invoke(this.ctx, { groupId, noFingerOpen, noCodeFingerOpen });
|
||||
}
|
||||
|
||||
listCategoryTags(groupClass: number): Promise<{ tags: { id: number; name: string; type: number }[] }> {
|
||||
return GetGroupCategoryTags.invoke(this.ctx, { groupClass });
|
||||
}
|
||||
|
||||
addCategoryTag(groupClass: number, name: string): Promise<void> {
|
||||
return AddGroupCategoryTag.invoke(this.ctx, { groupClass, name });
|
||||
}
|
||||
|
||||
removeCategoryTag(groupClass: number, name: string): Promise<void> {
|
||||
return DeleteGroupCategoryTag.invoke(this.ctx, { groupClass, name });
|
||||
}
|
||||
|
||||
async setMemberInvitePolicy(groupId: number, policy: GroupMemberInvitePolicy): Promise<void> {
|
||||
const currentPrivilegeFlag = await this.fetchGroupPrivilegeFlag(
|
||||
groupId,
|
||||
|
||||
@@ -23,6 +23,11 @@ import type {
|
||||
OidbSetAdmin,
|
||||
OidbSpecialTitle,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type {
|
||||
OidbChangeGroupCategoryTag,
|
||||
OidbGetGroupCategoryTags,
|
||||
OidbGetGroupCategoryTagsResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/group-category-tag';
|
||||
|
||||
// Post-namespace migration: GroupAdminApi forwards through namespaces
|
||||
// under @snowluma/protocol/oidb-services/group-admin. Tests assert
|
||||
@@ -705,4 +710,54 @@ describe('apis/group-admin', () => {
|
||||
remain_at_all_count_for_uin: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('lists category tags and keeps category 0 on the wire', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockResolvedValueOnce(packResponse(
|
||||
protobuf_encode<OidbBase<OidbGetGroupCategoryTagsResp>>({
|
||||
body: { tags: [{ id: 7, name: '学习', type: 1 }, { name: '未编号' }] },
|
||||
}),
|
||||
));
|
||||
|
||||
const out = await new GroupAdminApi(bridge as any).listCategoryTags(0);
|
||||
expect(out).toEqual({
|
||||
tags: [
|
||||
{ id: 7, name: '学习', type: 1 },
|
||||
{ id: 0, name: '未编号', type: 0 },
|
||||
],
|
||||
});
|
||||
expect(bridge.sendRawPacket.mock.calls[0]![0]).toBe('OidbSvcTrpcTcp.0x967c_0');
|
||||
const env = protobuf_decode<OidbBase<OidbGetGroupCategoryTags>>(bridge.sendRawPacket.mock.calls[0]![1]);
|
||||
expect(env.command).toBe(0x967C);
|
||||
expect(env.body?.groupClass).toBe(0);
|
||||
});
|
||||
|
||||
it('returns an empty tag list when the category has none', async () => {
|
||||
const bridge = mockBridge();
|
||||
bridge.sendRawPacket.mockResolvedValueOnce(packResponse(
|
||||
protobuf_encode<OidbBase<OidbGetGroupCategoryTagsResp>>({ body: {} }),
|
||||
));
|
||||
await expect(new GroupAdminApi(bridge as any).listCategoryTags(2)).resolves.toEqual({ tags: [] });
|
||||
});
|
||||
|
||||
it('adds and removes a category tag by its name', async () => {
|
||||
const bridge = mockBridge();
|
||||
await new GroupAdminApi(bridge as any).addCategoryTag(3, ' 户外 ');
|
||||
await new GroupAdminApi(bridge as any).removeCategoryTag(3, '户外');
|
||||
expect(bridge.sendRawPacket.mock.calls.map((call) => call[0])).toEqual([
|
||||
'OidbSvcTrpcTcp.0x967d_0',
|
||||
'OidbSvcTrpcTcp.0x967e_0',
|
||||
]);
|
||||
const added = protobuf_decode<OidbBase<OidbChangeGroupCategoryTag>>(bridge.sendRawPacket.mock.calls[0]![1]);
|
||||
expect(added.body).toMatchObject({ groupClass: 3, name: ' 户外 ' });
|
||||
const removed = protobuf_decode<OidbBase<OidbChangeGroupCategoryTag>>(bridge.sendRawPacket.mock.calls[1]![1]);
|
||||
expect(removed.body).toMatchObject({ groupClass: 3, name: '户外' });
|
||||
});
|
||||
|
||||
it('refuses an empty tag name instead of sending it', async () => {
|
||||
const bridge = mockBridge();
|
||||
await expect(new GroupAdminApi(bridge as any).addCategoryTag(1, '')).rejects.toThrow(/must not be empty/);
|
||||
await expect(new GroupAdminApi(bridge as any).removeCategoryTag(1, '')).rejects.toThrow(/must not be empty/);
|
||||
expect(bridge.sendRawPacket).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -440,6 +440,54 @@
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "add_group_tag",
|
||||
"aliases": [],
|
||||
"summary": "向某个群分类添加资料标签",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class",
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "bot_exit",
|
||||
"aliases": [],
|
||||
@@ -1422,6 +1470,54 @@
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "delete_group_tag",
|
||||
"aliases": [],
|
||||
"summary": "从某个群分类移除资料标签",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class",
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "delete_msg",
|
||||
"aliases": [],
|
||||
@@ -6107,6 +6203,75 @@
|
||||
},
|
||||
"category": "群信息"
|
||||
},
|
||||
{
|
||||
"name": "get_group_tags",
|
||||
"aliases": [],
|
||||
"summary": "读取某个群分类下的资料标签",
|
||||
"returns": "该分类下的资料标签列表。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"description": "资料标签",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "标签编号"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "标签名"
|
||||
},
|
||||
"type": {
|
||||
"type": "integer",
|
||||
"description": "标签类型"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"type"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tags"
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "get_group_todo_list",
|
||||
"aliases": [],
|
||||
@@ -13154,7 +13319,7 @@
|
||||
},
|
||||
{
|
||||
"category": "群管理",
|
||||
"count": 18
|
||||
"count": 21
|
||||
},
|
||||
{
|
||||
"category": "群文件",
|
||||
|
||||
@@ -443,6 +443,54 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "add_group_tag",
|
||||
"aliases": [],
|
||||
"summary": "向某个群分类添加资料标签",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class",
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "bot_exit",
|
||||
"aliases": [],
|
||||
@@ -1425,6 +1473,54 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "扩展"
|
||||
},
|
||||
{
|
||||
"name": "delete_group_tag",
|
||||
"aliases": [],
|
||||
"summary": "从某个群分类移除资料标签",
|
||||
"readOnly": false,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class",
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "delete_msg",
|
||||
"aliases": [],
|
||||
@@ -6110,6 +6206,75 @@ export const ACTIONS: CatalogAction[] = [
|
||||
},
|
||||
"category": "群信息"
|
||||
},
|
||||
{
|
||||
"name": "get_group_tags",
|
||||
"aliases": [],
|
||||
"summary": "读取某个群分类下的资料标签",
|
||||
"returns": "该分类下的资料标签列表。",
|
||||
"returnsSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"description": "资料标签",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"description": "标签编号"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "标签名"
|
||||
},
|
||||
"type": {
|
||||
"type": "integer",
|
||||
"description": "标签类型"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"type"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"tags"
|
||||
]
|
||||
},
|
||||
"readOnly": true,
|
||||
"params": [
|
||||
{
|
||||
"name": "group_class",
|
||||
"type": "int",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
}
|
||||
],
|
||||
"invariants": [],
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"group_class": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 4294967295
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"group_class"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"category": "群管理"
|
||||
},
|
||||
{
|
||||
"name": "get_group_todo_list",
|
||||
"aliases": [],
|
||||
@@ -13158,7 +13323,7 @@ export const CATEGORIES: CatalogCategory[] = [
|
||||
},
|
||||
{
|
||||
"category": "群管理",
|
||||
"count": 18
|
||||
"count": 21
|
||||
},
|
||||
{
|
||||
"category": "群文件",
|
||||
|
||||
@@ -166,6 +166,60 @@ export const actions = [
|
||||
},
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'get_group_tags',
|
||||
summary: '读取某个群分类下的资料标签',
|
||||
readOnly: true,
|
||||
returns: '该分类下的资料标签列表。',
|
||||
returnsSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
tags: {
|
||||
type: 'array',
|
||||
description: '资料标签',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'integer', description: '标签编号' },
|
||||
name: { type: 'string', description: '标签名' },
|
||||
type: { type: 'integer', description: '标签类型' },
|
||||
},
|
||||
required: ['id', 'name', 'type'],
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['tags'],
|
||||
},
|
||||
params: { group_class: f.int({ min: 0, max: 0xFFFFFFFF }) },
|
||||
run: async (p, ctx) => okResponse(await ctx.bridge.apis.groupAdmin.listCategoryTags(p.group_class)),
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'add_group_tag',
|
||||
summary: '向某个群分类添加资料标签',
|
||||
params: {
|
||||
group_class: f.int({ min: 0, max: 0xFFFFFFFF }),
|
||||
name: f.string({ allowEmpty: false }),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
await ctx.bridge.apis.groupAdmin.addCategoryTag(p.group_class, p.name);
|
||||
return okResponse();
|
||||
},
|
||||
}),
|
||||
|
||||
defineAction({
|
||||
name: 'delete_group_tag',
|
||||
summary: '从某个群分类移除资料标签',
|
||||
params: {
|
||||
group_class: f.int({ min: 0, max: 0xFFFFFFFF }),
|
||||
name: f.string({ allowEmpty: false }),
|
||||
},
|
||||
run: async (p, ctx) => {
|
||||
await ctx.bridge.apis.groupAdmin.removeCategoryTag(p.group_class, p.name);
|
||||
return okResponse();
|
||||
},
|
||||
}),
|
||||
|
||||
groupUserAction({
|
||||
name: 'set_group_admin',
|
||||
summary: '设置/取消管理员',
|
||||
|
||||
@@ -40,6 +40,9 @@ const setGroupMemberInvitePolicy = requireAction('set_group_member_invite_policy
|
||||
const setGroupNewMemberHistoryVisibility = requireAction('set_group_new_member_history_visibility');
|
||||
const setGroupMemberPermissions = requireAction('set_group_member_permissions');
|
||||
const getGroupAdminSettings = requireAction('get_group_admin_settings');
|
||||
const getGroupTags = requireAction('get_group_tags');
|
||||
const addGroupTag = requireAction('add_group_tag');
|
||||
const deleteGroupTag = requireAction('delete_group_tag');
|
||||
const setGroupAdmin = requireAction('set_group_admin');
|
||||
const setGroupCard = requireAction('set_group_card');
|
||||
const setGroupName = requireAction('set_group_name');
|
||||
@@ -62,6 +65,9 @@ describe('group admin actions catalog', () => {
|
||||
['set_group_new_member_history_visibility'],
|
||||
['set_group_member_permissions'],
|
||||
['get_group_admin_settings'],
|
||||
['get_group_tags'],
|
||||
['add_group_tag'],
|
||||
['delete_group_tag'],
|
||||
['set_group_admin'],
|
||||
['set_group_card'],
|
||||
['set_group_name'],
|
||||
@@ -74,7 +80,7 @@ describe('group admin actions catalog', () => {
|
||||
expect(actions.map((action) => action.kind)).toEqual([
|
||||
'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal',
|
||||
'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal',
|
||||
'normal', 'normal', 'normal', 'normal',
|
||||
'normal', 'normal', 'normal', 'normal', 'normal', 'normal', 'normal',
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1223,3 +1229,92 @@ describe('set_group_portrait toHandler', () => {
|
||||
expect(setGroupAvatar).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('get_group_tags parse', () => {
|
||||
it('accepts category 0 and a numeric string', () => {
|
||||
expect(getGroupTags.parse({ group_class: 0 })).toEqual({
|
||||
ok: true,
|
||||
value: { group_class: 0 },
|
||||
});
|
||||
expect(getGroupTags.parse({ group_class: '12' })).toEqual({
|
||||
ok: true,
|
||||
value: { group_class: 12 },
|
||||
});
|
||||
});
|
||||
|
||||
it('rejects a missing, negative, or oversized category', () => {
|
||||
expect(getGroupTags.parse({})).toEqual({
|
||||
ok: false,
|
||||
field: 'group_class',
|
||||
reason: 'is required',
|
||||
});
|
||||
expect(getGroupTags.parse({ group_class: -1 })).toEqual({
|
||||
ok: false,
|
||||
field: 'group_class',
|
||||
reason: 'must be >= 0',
|
||||
});
|
||||
expect(getGroupTags.parse({ group_class: 0x1_0000_0000 })).toEqual({
|
||||
ok: false,
|
||||
field: 'group_class',
|
||||
reason: 'must be <= 4294967295',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('get_group_tags toHandler', () => {
|
||||
it('returns the tag list for the category', async () => {
|
||||
const listCategoryTags = vi.fn(async () => ({
|
||||
tags: [{ id: 7, name: '学习', type: 1 }],
|
||||
}));
|
||||
const { ctx } = adminCtx({ listCategoryTags });
|
||||
|
||||
await expect(getGroupTags.toHandler(ctx)({ group_class: 4 })).resolves.toEqual({
|
||||
status: 'ok',
|
||||
retcode: 0,
|
||||
data: { tags: [{ id: 7, name: '学习', type: 1 }] },
|
||||
});
|
||||
expect(listCategoryTags.mock.calls).toEqual([[4]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('add_group_tag and delete_group_tag', () => {
|
||||
it('rejects an empty name and does not call the bridge', async () => {
|
||||
const addCategoryTag = vi.fn(async () => {});
|
||||
const removeCategoryTag = vi.fn(async () => {});
|
||||
const { ctx } = adminCtx({ addCategoryTag, removeCategoryTag });
|
||||
|
||||
await expect(addGroupTag.toHandler(ctx)({ group_class: 1, name: '' })).resolves.toEqual({
|
||||
status: 'failed',
|
||||
retcode: 1400,
|
||||
data: null,
|
||||
wording: 'name: must not be empty',
|
||||
});
|
||||
await expect(deleteGroupTag.toHandler(ctx)({ group_class: 1, name: '' })).resolves.toEqual({
|
||||
status: 'failed',
|
||||
retcode: 1400,
|
||||
data: null,
|
||||
wording: 'name: must not be empty',
|
||||
});
|
||||
expect(addCategoryTag).not.toHaveBeenCalled();
|
||||
expect(removeCategoryTag).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('forwards the category and the exact name', async () => {
|
||||
const addCategoryTag = vi.fn(async () => {});
|
||||
const removeCategoryTag = vi.fn(async () => {});
|
||||
const { ctx } = adminCtx({ addCategoryTag, removeCategoryTag });
|
||||
|
||||
await expect(addGroupTag.toHandler(ctx)({ group_class: 0, name: ' 户外 ' })).resolves.toEqual({
|
||||
status: 'ok',
|
||||
retcode: 0,
|
||||
data: null,
|
||||
});
|
||||
await expect(deleteGroupTag.toHandler(ctx)({ group_class: '2', name: '户外' })).resolves.toEqual({
|
||||
status: 'ok',
|
||||
retcode: 0,
|
||||
data: null,
|
||||
});
|
||||
expect(addCategoryTag.mock.calls).toEqual([[0, ' 户外 ']]);
|
||||
expect(removeCategoryTag.mock.calls).toEqual([[2, '户外']]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user