71aaa08230
Build and Release / Build (push) Has been cancelled
备注保存前获取完整用户详情构造请求体,TC03 清空备注场景不再丢失其他字段。 拆出 RemarkForm 组件,增加保存中禁用态和失败错误提示。
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildUserBasicInfoPayload } from "./user-basic-info-payload";
|
|
|
|
const user = {
|
|
id: 37,
|
|
avatar: "https://example.com/avatar.png",
|
|
balance: 1200,
|
|
commission: 300,
|
|
referral_percentage: 10,
|
|
only_first_purchase: true,
|
|
gift_amount: 500,
|
|
telegram: 123_456,
|
|
refer_code: "INVITE37",
|
|
referer_id: 7,
|
|
enable: true,
|
|
is_admin: false,
|
|
enable_balance_notify: true,
|
|
enable_login_notify: true,
|
|
enable_subscribe_notify: false,
|
|
enable_trade_notify: false,
|
|
user_group_id: 2,
|
|
group_locked: false,
|
|
auth_methods: [],
|
|
user_devices: [],
|
|
remark: "old remark",
|
|
rules: [],
|
|
created_at: 1_700_000_000,
|
|
updated_at: 1_700_000_100,
|
|
} satisfies API.User;
|
|
|
|
describe("buildUserBasicInfoPayload", () => {
|
|
it("keeps the full basic user fields when updating a remark", () => {
|
|
expect(buildUserBasicInfoPayload(user, "new remark")).toEqual({
|
|
user_id: 37,
|
|
avatar: "https://example.com/avatar.png",
|
|
balance: 1200,
|
|
commission: 300,
|
|
referral_percentage: 10,
|
|
only_first_purchase: true,
|
|
gift_amount: 500,
|
|
telegram: 123_456,
|
|
refer_code: "INVITE37",
|
|
referer_id: 7,
|
|
enable: true,
|
|
is_admin: false,
|
|
remark: "new remark",
|
|
});
|
|
});
|
|
|
|
it("preserves an intentionally cleared remark", () => {
|
|
expect(buildUserBasicInfoPayload(user, "").remark).toBe("");
|
|
});
|
|
});
|