forked from boos/BoosAPI
[codex] fix expired connection health recovery (#393)
* fix expired connection health recovery * address review comments and test regressions
This commit is contained in:
@@ -597,6 +597,13 @@ export default function Accounts() {
|
||||
};
|
||||
|
||||
const resolveRuntimeHealth = (account: any) => {
|
||||
if (account.status === 'expired') {
|
||||
return {
|
||||
...runtimeHealthMap.unhealthy,
|
||||
label: '已过期',
|
||||
reason: account.runtimeHealth?.reason || '连接凭证已过期,请更新凭证',
|
||||
};
|
||||
}
|
||||
const capabilities = resolveAccountCapabilities(account);
|
||||
const fallbackState = account.status === 'disabled' || account.site?.status === 'disabled'
|
||||
? 'disabled'
|
||||
|
||||
@@ -51,6 +51,10 @@ describe('Accounts proxy-only expired state', () => {
|
||||
accessToken: 'api-key-only-token',
|
||||
status: 'expired',
|
||||
checkinEnabled: false,
|
||||
runtimeHealth: {
|
||||
state: 'unhealthy',
|
||||
reason: '连接已过期,请更新 API Key',
|
||||
},
|
||||
capabilities: {
|
||||
canCheckin: false,
|
||||
canRefreshBalance: false,
|
||||
@@ -77,8 +81,18 @@ describe('Accounts proxy-only expired state', () => {
|
||||
|
||||
const rendered = JSON.stringify(root.toJSON());
|
||||
expect(rendered).not.toContain('仅代理');
|
||||
expect(rendered).toContain('已过期');
|
||||
expect(rendered).toContain('连接已过期,请更新 API Key');
|
||||
expect(rendered).not.toContain('访问令牌已过期');
|
||||
|
||||
const badgeTexts = root.root.findAll((node) => (
|
||||
node.type === 'span'
|
||||
&& typeof node.props.className === 'string'
|
||||
&& node.props.className.includes('badge')
|
||||
)).map((node) => collectText(node).trim());
|
||||
expect(badgeTexts).toContain('已过期');
|
||||
expect(badgeTexts).not.toContain('健康');
|
||||
|
||||
const actionTexts = root.root.findAll((node) => node.type === 'button').map((node) => collectText(node));
|
||||
expect(actionTexts).not.toContain('重新绑定');
|
||||
} finally {
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('Accounts refresh action', () => {
|
||||
|
||||
expect(apiMock.getAccounts).toHaveBeenCalledTimes(2);
|
||||
const rendered = JSON.stringify(root.toJSON());
|
||||
expect(rendered).toContain('异常');
|
||||
expect(rendered).toContain('已过期');
|
||||
} finally {
|
||||
root?.unmount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user