修复泥点消耗刷新不及时 (#138)
refactor: - 主站复用game agent的zustand store fix: - 修复旧请求覆盖问题 - 修复账号切换问题 - 主站原本已经每 4 秒轮询 external generation 任务状态, 在这里补充触发余额刷新的时机 --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/138 Co-authored-by: 王德宇 <kvtodev@outlook.com> Co-committed-by: 王德宇 <kvtodev@outlook.com>
This commit was merged in pull request #138.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
const apiClientMocks = vi.hoisted(() => ({
|
||||
fetchWithApiAuth: vi.fn(),
|
||||
requestJson: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../apiClient', () => apiClientMocks);
|
||||
|
||||
import {
|
||||
createPlatformProfileRechargeOrder,
|
||||
getPlatformProfileRechargeCenter,
|
||||
redeemPlatformProfileReferralInviteCode,
|
||||
redeemPlatformProfileRewardCode,
|
||||
} from './platformProfileClient';
|
||||
|
||||
describe('platformProfileClient', () => {
|
||||
beforeEach(() => {
|
||||
apiClientMocks.requestJson.mockReset();
|
||||
apiClientMocks.requestJson.mockResolvedValue({});
|
||||
});
|
||||
|
||||
test('forwards the recharge-center abort signal through request options', async () => {
|
||||
const abortController = new AbortController();
|
||||
|
||||
await getPlatformProfileRechargeCenter({
|
||||
signal: abortController.signal,
|
||||
});
|
||||
|
||||
expect(apiClientMocks.requestJson).toHaveBeenCalledWith(
|
||||
'/api/profile/recharge-center',
|
||||
{
|
||||
method: 'GET',
|
||||
signal: abortController.signal,
|
||||
},
|
||||
'读取泥点购买信息失败',
|
||||
expect.objectContaining({
|
||||
retry: expect.any(Object),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test.each([
|
||||
[
|
||||
'充值下单',
|
||||
(signal: AbortSignal) =>
|
||||
createPlatformProfileRechargeOrder('points-60', 'wechat_native', {
|
||||
signal,
|
||||
}),
|
||||
],
|
||||
[
|
||||
'邀请码兑换',
|
||||
(signal: AbortSignal) =>
|
||||
redeemPlatformProfileReferralInviteCode('INVITE01', { signal }),
|
||||
],
|
||||
[
|
||||
'奖励码兑换',
|
||||
(signal: AbortSignal) =>
|
||||
redeemPlatformProfileRewardCode('REWARD01', { signal }),
|
||||
],
|
||||
])('%s write forwards its account abort signal', async (_label, request) => {
|
||||
const abortController = new AbortController();
|
||||
|
||||
await request(abortController.signal);
|
||||
|
||||
expect(apiClientMocks.requestJson).toHaveBeenCalledWith(
|
||||
expect.stringMatching(/^\/api\/profile\//u),
|
||||
expect.objectContaining({ signal: abortController.signal }),
|
||||
expect.any(String),
|
||||
expect.objectContaining({ retry: expect.any(Object) }),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user