feat(user): sync entitlement snapshot
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { UserEntitlements } from "@/data/dto/user";
|
||||
import { User } from "@/data/dto/user/user";
|
||||
|
||||
describe("User", () => {
|
||||
@@ -42,4 +43,51 @@ describe("User", () => {
|
||||
lastMessageAt: "2026-06-24T11:00:23.156561+00:00",
|
||||
});
|
||||
});
|
||||
|
||||
it("parses the latest backend entitlements payload", () => {
|
||||
const entitlements = UserEntitlements.fromJson({
|
||||
userId: "user-1",
|
||||
isGuest: false,
|
||||
isVip: true,
|
||||
vipExpiresAt: "2026-07-26T00:00:00+00:00",
|
||||
creditBalance: 120,
|
||||
dolBalance: 120,
|
||||
policy: {
|
||||
membershipState: "vip",
|
||||
nonVipEntitlementsShared: true,
|
||||
guestSameAsLoggedInNonVip: true,
|
||||
refreshAfterPayment: "GET /api/user/entitlements",
|
||||
},
|
||||
costs: {
|
||||
normal_message: 2,
|
||||
private_message: 10,
|
||||
voice_message: 20,
|
||||
photo: 40,
|
||||
voice_call_minute: 50,
|
||||
private_album_10: 300,
|
||||
private_album_20: 600,
|
||||
},
|
||||
quotas: {
|
||||
normalChatFreeDaily: 30,
|
||||
privateUnlockFreeDaily: 1,
|
||||
voiceMessageFreeDaily: 0,
|
||||
photoFreeDaily: 0,
|
||||
},
|
||||
historyUnlock: {
|
||||
enabled: true,
|
||||
order: "oldest_first",
|
||||
chargeMode: "highest_cost_per_locked_message",
|
||||
insufficientBalanceBehavior: "no_deduction",
|
||||
costs: {
|
||||
private_message: 10,
|
||||
voice_message: 20,
|
||||
photo: 40,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(entitlements.isVip).toBe(true);
|
||||
expect(entitlements.creditBalance).toBe(120);
|
||||
expect(entitlements.historyUnlock.costs.photo).toBe(40);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user