mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-08 05:36:09 +00:00
2b10808fbd
* fix(settings): require server-side 2fa for sensitive changes * fix(lint): group third-party imports separately from local (goimports) golangci-lint goimports flagged setting.go and setting_security_test.go because xlzd/gotp and gorm.io/gorm were mixed into the github.com/mhsanaei/3x-ui local-prefix group. Move them into the third-party group so the local imports stand alone.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import type { AllSetting } from '@/models/setting';
|
|
import SecurityTab from '@/pages/settings/SecurityTab';
|
|
import { HttpUtil } from '@/utils';
|
|
|
|
describe('API token creation date', () => {
|
|
it('renders both API seconds and legacy millisecond timestamps', async () => {
|
|
vi.spyOn(HttpUtil, 'get').mockResolvedValueOnce({
|
|
success: true,
|
|
msg: '',
|
|
obj: [
|
|
{
|
|
id: 2,
|
|
name: 'seconds-token',
|
|
enabled: true,
|
|
createdAt: 1782485394,
|
|
},
|
|
{
|
|
id: 3,
|
|
name: 'legacy-milliseconds-token',
|
|
enabled: true,
|
|
createdAt: 1782485394270,
|
|
},
|
|
],
|
|
});
|
|
|
|
render(<SecurityTab allSetting={{} as AllSetting} updateSetting={vi.fn()} saveSetting={vi.fn()} />);
|
|
fireEvent.click(screen.getByRole('tab', { name: /API Token/ }));
|
|
|
|
expect(await screen.findByText('seconds-token')).toBeTruthy();
|
|
expect(screen.getByText('legacy-milliseconds-token')).toBeTruthy();
|
|
expect(screen.getAllByText(/2026/)).toHaveLength(2);
|
|
});
|
|
});
|