fix: resolve all ESLint errors and TypeScript compilation errors
- Auto-fixed 712 import ordering errors via `pnpm lint --fix` - Manually fixed 13 remaining ESLint errors: - Prefixed unused vars with _ (mockAdminUser, params) - Removed unused imports (UnauthorizedException, vi, screen) - Moved imports above vi.mock() calls to fix import group ordering - Removed eslint-disable for non-existent rules - Fixed empty object pattern in Playwright fixture - Fixed ~40 TypeScript TS4111 index signature errors in test files: - Used bracket notation for Record<string, unknown> property access - Added missing PropertyMedia fields (id, order, caption) to test data - Fixed pre-existing test failures in rate-limit guard specs: - Added NODE_ENV override to bypass test-mode skip in guard Both `pnpm lint` and `pnpm typecheck` now exit 0 cleanly. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
70
apps/web/components/auth/__tests__/oauth-buttons.spec.tsx
Normal file
70
apps/web/components/auth/__tests__/oauth-buttons.spec.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { OAuthButtons } from '../oauth-buttons';
|
||||
|
||||
describe('OAuthButtons', () => {
|
||||
it('renders Google button', () => {
|
||||
render(<OAuthButtons />);
|
||||
expect(screen.getByRole('button', { name: /Google/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders Zalo button', () => {
|
||||
render(<OAuthButtons />);
|
||||
expect(screen.getByRole('button', { name: /Zalo/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('has two OAuth buttons', () => {
|
||||
render(<OAuthButtons />);
|
||||
const buttons = screen.getAllByRole('button');
|
||||
expect(buttons).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('buttons are type="button" (not submit)', () => {
|
||||
render(<OAuthButtons />);
|
||||
const buttons = screen.getAllByRole('button');
|
||||
buttons.forEach((btn) => {
|
||||
expect(btn).toHaveAttribute('type', 'button');
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects to Google OAuth URL on click', () => {
|
||||
const originalHref = window.location.href;
|
||||
delete (window as unknown as Record<string, unknown>)['location'];
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { href: originalHref },
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
render(<OAuthButtons />);
|
||||
screen.getByRole('button', { name: /Google/i }).click();
|
||||
expect(window.location.href).toContain('/auth/google');
|
||||
|
||||
// Restore
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { href: originalHref },
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects to Zalo OAuth URL on click', () => {
|
||||
const originalHref = window.location.href;
|
||||
delete (window as unknown as Record<string, unknown>)['location'];
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { href: originalHref },
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
render(<OAuthButtons />);
|
||||
screen.getByRole('button', { name: /Zalo/i }).click();
|
||||
expect(window.location.href).toContain('/auth/zalo');
|
||||
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { href: originalHref },
|
||||
writable: true,
|
||||
configurable: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user