6bac88fbc4
- Detect and block chrome://, chrome-extension://, about://, edge://, brave:// pages - Show 'Unsupported' badge with warning icon and disabled button - Add 'unsupported' and 'unsupportedDesc' i18n keys (zh/en) - Update useRightClickRestorer hook with isUnsupported state - Add unit tests for unsupported page behavior - Update page UI to render conditional unsupported layout
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import RightClickRestorerPage from '../index';
|
|
|
|
const mockUnlock = vi.fn();
|
|
|
|
vi.mock('../useRightClickRestorer', () => ({
|
|
useRightClickRestorer: () => ({
|
|
domain: 'example.com',
|
|
isLoading: false,
|
|
isUnlocked: false,
|
|
isUnsupported: false,
|
|
unlock: mockUnlock,
|
|
}),
|
|
}));
|
|
|
|
describe('RightClickRestorerPage', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
it('should render current domain', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/example\.com/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should render locked status', () => {
|
|
render(<RightClickRestorerPage />);
|
|
expect(screen.getByText(/statusLocked/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('should call unlock when button clicked', () => {
|
|
render(<RightClickRestorerPage />);
|
|
const button = screen.getByRole('button');
|
|
fireEvent.click(button);
|
|
expect(mockUnlock).toHaveBeenCalled();
|
|
});
|
|
});
|