# Conflicts: # internal/web/translation/ar-EG.json # internal/web/translation/en-US.json # internal/web/translation/es-ES.json # internal/web/translation/fa-IR.json # internal/web/translation/id-ID.json # internal/web/translation/ja-JP.json # internal/web/translation/pt-BR.json # internal/web/translation/ru-RU.json # internal/web/translation/tr-TR.json # internal/web/translation/uk-UA.json # internal/web/translation/vi-VN.json # internal/web/translation/zh-CN.json # internal/web/translation/zh-TW.json
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { fireEvent, screen } from '@testing-library/react';
|
|
import { MemoryRouter } from 'react-router';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import { AllSetting } from '@/models/setting';
|
|
import SubscriptionGeneralTab from '@/pages/settings/SubscriptionGeneralTab';
|
|
import { renderWithProviders } from './test-utils';
|
|
|
|
describe('SubscriptionGeneralTab', () => {
|
|
// P7 made the subscription port optional: clearing the field applies
|
|
// subPort 0, the explicit "no port in generated links" setting (the sub
|
|
// server keeps binding the default port). This field opts out of the
|
|
// shared keep-stored-value-on-clear semantic via onNumber's onClear —
|
|
// see utils/onNumber.ts and SettingService.BuildSubURIBase.
|
|
it('applies subPort 0 (no port in generated links) when the field is cleared', () => {
|
|
const updateSetting = vi.fn();
|
|
|
|
renderWithProviders(
|
|
<MemoryRouter initialEntries={['/settings#subscription']}>
|
|
<SubscriptionGeneralTab
|
|
allSetting={new AllSetting({ subPort: 2096 })}
|
|
updateSetting={updateSetting}
|
|
/>
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
const portInput = screen.getByDisplayValue('2096');
|
|
fireEvent.change(portInput, { target: { value: '' } });
|
|
fireEvent.blur(portInput);
|
|
|
|
expect(updateSetting).toHaveBeenCalledWith({ subPort: 0 });
|
|
});
|
|
|
|
it('forwards typed subscription ports unchanged', () => {
|
|
const updateSetting = vi.fn();
|
|
|
|
renderWithProviders(
|
|
<MemoryRouter initialEntries={['/settings#subscription']}>
|
|
<SubscriptionGeneralTab
|
|
allSetting={new AllSetting({ subPort: 2096 })}
|
|
updateSetting={updateSetting}
|
|
/>
|
|
</MemoryRouter>,
|
|
);
|
|
|
|
fireEvent.change(screen.getByDisplayValue('2096'), { target: { value: '8443' } });
|
|
|
|
expect(updateSetting).toHaveBeenCalledWith({ subPort: 8443 });
|
|
});
|
|
});
|