deckhearth/test/pages/login.test.js

30 lines
889 B
JavaScript
Raw Normal View History

// @vitest-environment jsdom
import { afterEach, describe, expect, it, vi } from 'vitest';
import { cleanup, render, screen } from '@testing-library/react';
import Login from '../../pages/login.js';
vi.mock('next/router', () => ({
useRouter: () => ({ push: vi.fn() }),
}));
vi.mock('../../components/AuthLayout', () => ({
default: ({ children }) => <div>{children}</div>,
}));
vi.mock('../../components/AnimatedFireLogo', () => ({
default: () => <div aria-hidden="true">logo</div>,
}));
describe('Login page', () => {
afterEach(() => cleanup());
it('renders the sign-in CTA without dev quick-login credentials', () => {
render(<Login />);
expect(screen.getByRole('button', { name: /sign in to deck hearth/i })).toBeTruthy();
expect(screen.queryByText(/quick login/i)).toBeNull();
expect(document.body.textContent).not.toMatch(/alice123|bob123/);
});
});