Skip to content

Commit

Permalink
Remove frontend test
Browse files Browse the repository at this point in the history
 (#100)
  • Loading branch information
kimurash committed Oct 29, 2024
1 parent 1142955 commit 090e30d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 66 deletions.
55 changes: 2 additions & 53 deletions frontend/test/routes/auth.login.test.tsx
Original file line number Diff line number Diff line change
@@ -1,77 +1,26 @@
import { screen } from '@testing-library/react';
import { renderWithWrapper } from 'test/helpers/wrapper';
import LoginPage from '~/routes/auth.login';

describe('Login page', () => {
it('should login successfully', async () => {
const { user } = renderWithWrapper(<LoginPage />);

// メールアドレスを入力
const emailForm = screen.getByTestId('email-input');
await user.type(emailForm, 'user@example.com');
expect(emailForm).toHaveValue('user@example.com');

// パスワードを入力
const passwordForm = screen.getByTestId('password-input');
await user.type(passwordForm, 'passw0rd');
expect(passwordForm).toHaveValue('passw0rd');

// ログインボタンをクリック
const submitButton = screen.getByRole('button', { name: 'ログイン' });
await user.click(submitButton);

// ログイン成功の通知が表示される
const banner = await screen.findByText('ログインに成功しました');
expect(banner).toBeInTheDocument();
});

it('should fail to pass when email is invalid', async () => {
const { user } = renderWithWrapper(<LoginPage />);

// メールアドレスを入力
const emailForm = screen.getByTestId('email-input');
await user.type(emailForm, 'user@invalid');

// ログインボタンをクリック
const submitButton = screen.getByRole('button', { name: 'ログイン' });
await user.click(submitButton);

// エラーメッセージが表示される
const message = await screen.findByText('有効でないメールアドレスです');
expect(message).toBeInTheDocument();
});

test('should fail to pass when password length is less than 8', async () => {
const { user } = renderWithWrapper(<LoginPage />);

it('should fail to pass when password length is less than 8', async () => {
// パスワードを入力
const passwordForm = screen.getByTestId('password-input');
await user.type(passwordForm, 'pass');

// ログインボタンをクリック
const submitButton = screen.getByRole('button', { name: 'ログイン' });
await user.click(submitButton);

// エラーメッセージが表示される
// prettier-ignore
const message = await screen.findByText("パスワードは8文字以上で入力してください");
expect(message).toBeInTheDocument();
});

test('should fail to pass when password is not alphanumeric', async () => {
const { user } = renderWithWrapper(<LoginPage />);

it('should fail to pass when password is not alphanumeric', async () => {
// パスワードを入力
const passwordForm = screen.getByTestId('password-input');
await user.type(passwordForm, 'password');

// ログインボタンをクリック
const submitButton = screen.getByRole('button', { name: 'ログイン' });
await user.click(submitButton);

// エラーメッセージが表示される
// prettier-ignore
const message = await screen.findByText("パスワードにはアルファベットと数字を含めてください");
expect(message).toBeInTheDocument();
});
});
13 changes: 0 additions & 13 deletions frontend/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@ import { cleanup } from '@testing-library/react';
import { setupServer } from 'msw/node';
import { handlers } from './mocks/handlers';

vi.mock('@remix-run/react', () => {
const useNavigate = vi.fn();
const form = vi
.fn()
.mockImplementation(({ children }: { children: React.ReactElement }) => {
return children;
});
return {
useNavigate: useNavigate,
Form: form,
};
});

const server = setupServer(...handlers);

beforeAll(() => {
Expand Down

0 comments on commit 090e30d

Please sign in to comment.