合并主分支
合并远端主线,保留钱包快照竞态修复。
This commit is contained in:
@@ -20,6 +20,7 @@ import { PlatformProfileSummaryHeader } from '../common/PlatformProfileSummaryHe
|
||||
import { PlatformStatusMessage } from '../common/PlatformStatusMessage';
|
||||
import { PlatformTextField } from '../common/PlatformTextField';
|
||||
import { useCopyFeedback } from '../common/useCopyFeedback';
|
||||
import { formatPlatformProfileTime } from './platformProfileFundsModel';
|
||||
import { PlatformProfileSecondaryModalShell } from './PlatformProfileModalShell';
|
||||
|
||||
type PlatformProfileApiKeysModalProps = {
|
||||
@@ -34,14 +35,7 @@ function buildApiKeyTimeLabel(value: string | null) {
|
||||
if (!value) {
|
||||
return '尚未使用';
|
||||
}
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value;
|
||||
}
|
||||
const year = date.getUTCFullYear();
|
||||
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getUTCDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
return formatPlatformProfileTime(value);
|
||||
}
|
||||
|
||||
function buildApiKeyScopeLabel(scopes: string[]) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/* @vitest-environment jsdom */
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { createElement } from 'react';
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
||||
|
||||
import { PlatformProfileApiKeysModal } from './PlatformProfileApiKeysModal';
|
||||
|
||||
const listExternalApiKeysMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('../../services/platform-entry/platformProfileClient', () => ({
|
||||
createPlatformProfileExternalApiKey: vi.fn(),
|
||||
listPlatformProfileExternalApiKeys: listExternalApiKeysMock,
|
||||
revokePlatformProfileExternalApiKey: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('PlatformProfileApiKeysModal', () => {
|
||||
beforeEach(() => {
|
||||
listExternalApiKeysMock.mockReset();
|
||||
});
|
||||
|
||||
test('将 API Key 时间戳格式化为日期', async () => {
|
||||
listExternalApiKeysMock.mockResolvedValueOnce({
|
||||
keys: [
|
||||
{
|
||||
keyId: 'api-key-1',
|
||||
name: '外部 API Key',
|
||||
keyPrefix: 'tnr_sk_example',
|
||||
scopes: ['editor:project'],
|
||||
createdAt: '1785913407.182731Z',
|
||||
lastUsedAt: null,
|
||||
revokedAt: null,
|
||||
updatedAt: '1785913407.182731Z',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
render(createElement(PlatformProfileApiKeysModal, { onClose: vi.fn() }));
|
||||
|
||||
expect(
|
||||
await screen.findByText('创建 2026-08-05 · 最近使用 尚未使用'),
|
||||
).toBeTruthy();
|
||||
expect(screen.queryByText(/1785913407\.182731Z/u)).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user