forked from akai/readest
1705006b6b
- AppLockScreen: pad the lock screen bottom by the on-screen keyboard height tracked via visualViewport, so the flex-centered PIN sits above the keyboard on iOS WKWebView where dvh does not shrink. - AppLockScreen: skip stickyFocus on mobile. iOS will not pop the keyboard from a programmatic .focus(), so the cursor would blink with no input — wait for the user's tap instead. - PinInput: forward autoFocus to the input when autoFocus or stickyFocus is set, for more reliable mount-time focus. - style.ts: give legacy <p><font>...</font></p> its own block context so iOS Safari applies the inherited line-height. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { describe, it, expect, afterEach, vi } from 'vitest';
|
|
import { render, screen, cleanup } from '@testing-library/react';
|
|
|
|
import PinInput from '@/components/PinInput';
|
|
|
|
vi.mock('@/libs/crypto/applock', () => ({
|
|
PIN_LENGTH: 4,
|
|
}));
|
|
|
|
afterEach(cleanup);
|
|
|
|
describe('PinInput', () => {
|
|
it('focuses the input on mount when autoFocus is true', async () => {
|
|
render(<PinInput value='' onChange={() => {}} ariaLabel='PIN code' autoFocus />);
|
|
|
|
const input = screen.getByLabelText('PIN code');
|
|
await vi.waitFor(() => expect(document.activeElement).toBe(input));
|
|
});
|
|
|
|
it('focuses the input on mount when stickyFocus is true', async () => {
|
|
render(<PinInput value='' onChange={() => {}} ariaLabel='PIN code' stickyFocus />);
|
|
|
|
const input = screen.getByLabelText('PIN code');
|
|
await vi.waitFor(() => expect(document.activeElement).toBe(input));
|
|
});
|
|
|
|
it('does not focus the input when neither autoFocus nor stickyFocus is set', () => {
|
|
render(<PinInput value='' onChange={() => {}} ariaLabel='PIN code' />);
|
|
|
|
const input = screen.getByLabelText('PIN code');
|
|
expect(document.activeElement).not.toBe(input);
|
|
});
|
|
});
|