fa0f1bdcad
- Add RightClickRestorer page with active unlock trigger - Content script with dual-world strategy (isolated + main world) - Monkey patch preventDefault/stopPropagation via background executeScript - Overlay penetration for pointer-events blocking layers - Delegated main-world injection to avoid CSP restrictions - Async message handling for reliable state updates - i18n translations (zh/en) and unit tests
38 lines
1.0 KiB
TypeScript
38 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,
|
|
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();
|
|
});
|
|
});
|