feat: integrate token point usage v2
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
fetchMyWorksProjects,
|
||||
fetchWorksAsset,
|
||||
fetchWorksAssets,
|
||||
fetchWorksTokenUsage,
|
||||
fetchWorksTokenPointBalance,
|
||||
fetchWorksProjectVersions,
|
||||
fetchWorksProjects,
|
||||
publishWorksProjectSource,
|
||||
@@ -212,22 +212,37 @@ describe('works square client', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('loads billing token usage with the current access token', async () => {
|
||||
const usage = {
|
||||
five_hour_remaining_percent: 72.5,
|
||||
weekly_remaining_percent: 48,
|
||||
plan_code: 'pro',
|
||||
plan_name: '专业版',
|
||||
it('loads the V2 token point balance with the current access token', async () => {
|
||||
const points = {
|
||||
plan_code: 'mastery',
|
||||
plan_name: '精通',
|
||||
cycle_start: '2026-09-01T00:00:00Z',
|
||||
cycle_end: '2026-09-08T00:00:00Z',
|
||||
next_refresh_at: '2026-09-08T00:00:00Z',
|
||||
weekly_allowance: '500.00',
|
||||
weekly_used: '100.00',
|
||||
weekly_reserved: '25.00',
|
||||
weekly_remaining: '375.00',
|
||||
permanent_total: '50.00',
|
||||
permanent_used: '0.00',
|
||||
permanent_reserved: '0.00',
|
||||
permanent_remaining: '50.00',
|
||||
total_remaining: '425.00',
|
||||
entitlement_source: 'self',
|
||||
family_shared: false,
|
||||
can_manage_membership: true,
|
||||
upgrade_action: 'self_service',
|
||||
shared_available: null,
|
||||
};
|
||||
hostApiFetchMock.mockResolvedValueOnce({ success: true, usage });
|
||||
hostApiFetchMock.mockResolvedValueOnce({ success: true, points });
|
||||
|
||||
const result = await fetchWorksTokenUsage('access-token');
|
||||
const result = await fetchWorksTokenPointBalance('access-token');
|
||||
|
||||
expect(result).toEqual(usage);
|
||||
expect(result.plan_code).toBe('pro');
|
||||
expect(result.plan_name).toBe('专业版');
|
||||
expect(result).toEqual(points);
|
||||
expect(result.plan_code).toBe('mastery');
|
||||
expect(result.plan_name).toBe('精通');
|
||||
expect(hostApiFetchMock).toHaveBeenCalledWith(
|
||||
'/api/works/billing/token-usage',
|
||||
'/api/works/billing/points',
|
||||
{
|
||||
headers: {
|
||||
'X-NianCode-Access-Token': 'access-token',
|
||||
|
||||
Reference in New Issue
Block a user