feat(web): localize and redesign operations console

This commit is contained in:
chick
2026-07-18 22:22:41 +08:00
parent d575ab4d9d
commit abfd07f8a3
34 changed files with 1536 additions and 1058 deletions
+15 -15
View File
@@ -40,16 +40,16 @@ describe('isolated Calls read module', () => {
it('loads only through the injected source and renders aggregate call and device status', async () => {
const pending = deferredSource();
render(<CallsModule instance={owner} dataSource={pending.source} />);
expect(screen.getByRole('status', { name: 'Calls loading status' })).toBeTruthy();
expect(screen.getByRole('status', { name: '通话加载状态' })).toBeTruthy();
expect(pending.load).toHaveBeenCalledWith('alpha', expect.any(AbortSignal));
pending.resolve(snapshot);
const calls = await screen.findByRole('region', { name: 'Call status' });
const devices = screen.getByRole('region', { name: 'Device status' });
expect(within(calls).getByText('active')).toBeTruthy();
const calls = await screen.findByRole('region', { name: '通话状态' });
const devices = screen.getByRole('region', { name: '设备状态' });
expect(within(calls).getByText('活跃')).toBeTruthy();
expect(within(calls).getByText('2')).toBeTruthy();
expect(within(devices).getByText('available')).toBeTruthy();
expect(screen.getByText(/Observed 2026-07-17T12:30:00Z/)).toBeTruthy();
expect(within(devices).getByText('可用')).toBeTruthy();
expect(screen.getByText(/观测时间:2026-07-17T12:30:00Z/)).toBeTruthy();
});
it('strictly allowlists aggregate fields and exposes no phone numbers, audio, logs, or controls', async () => {
@@ -62,7 +62,7 @@ describe('isolated Calls read module', () => {
devices: { ...snapshot.devices, phoneNumber: '+1-555-0102', audioUrl: 'secret-audio-url' },
} as CallsSnapshot;
render(<CallsModule instance={owner} dataSource={{ load: async () => unsafe }} />);
expect(await screen.findByText('available')).toBeTruthy();
expect(await screen.findByText('可用')).toBeTruthy();
expect(document.body.textContent).not.toMatch(/555|private|secret-audio/i);
expect(screen.queryByRole('button')).toBeNull();
});
@@ -75,12 +75,12 @@ describe('isolated Calls read module', () => {
dataSource={{ load }}
/>,
);
expect(screen.getByRole('alert').textContent).toMatch(/authentication is required/i);
expect(screen.getByRole('alert').textContent).toMatch(/需要先完成认证/i);
expect(load).not.toHaveBeenCalled();
rerender(<CallsModule instance={owner} />);
expect(screen.getByRole('status', { name: 'Calls unavailable' }).textContent).toMatch(
/no safe calls read data source.*will not invent.*production endpoint/i,
expect(screen.getByRole('status', { name: '通话不可用' }).textContent).toMatch(
/没有可用的安全通话只读数据源.*不会臆造.*生产端点/i,
);
});
@@ -95,16 +95,16 @@ describe('isolated Calls read module', () => {
const { rerender } = render(
<CallsModule instance={owner} dataSource={source} refreshSignal={0} />,
);
expect(await screen.findByText('available')).toBeTruthy();
expect(await screen.findByText('可用')).toBeTruthy();
rerender(<CallsModule instance={owner} dataSource={source} refreshSignal={1} />);
const alert = await screen.findByRole('alert');
expect(alert.textContent).toMatch(/showing the last known Calls data/i);
expect(alert.textContent).toMatch(/正在显示上次已知的通话数据/i);
expect(alert.textContent).not.toMatch(/secret endpoint|telephone/i);
expect(screen.getByText('available')).toBeTruthy();
await user.click(screen.getByRole('button', { name: 'Retry loading Calls' }));
expect(screen.getByText('可用')).toBeTruthy();
await user.click(screen.getByRole('button', { name: '重试加载通话' }));
expect(
await within(screen.getByRole('region', { name: 'Call status' })).findByText('3'),
await within(screen.getByRole('region', { name: '通话状态' })).findByText('3'),
).toBeTruthy();
});