Files
jongryangje/e2e/phase2-extra.spec.js
javamon1174 c2840a9e34 P2-19~21 지자체 수정/삭제, 비밀번호 변경, 로그인 5회 실패 lock
- P2-19: LocalGovernment edit/update/delete 추가, 목록에 수정/비활성 버튼
- P2-20: PasswordChange 컨트롤러 + View (현재 비밀번호 검증 후 변경)
- P2-21: 로그인 5회 연속 실패 시 30분 lock
  - member 테이블에 mb_login_fail_count, mb_locked_until 컬럼 추가
  - Auth::login에 lock 체크/실패 카운트 증가/성공 시 리셋 로직
- E2E 테스트 4개 전체 통과

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:53:52 +09:00

55 lines
2.3 KiB
JavaScript

// @ts-check
const { test, expect } = require('@playwright/test');
const { login } = require('./helpers/auth');
async function loginAsAdmin(page) {
await login(page, 'admin');
await page.locator('input[name="lg_idx"]').first().check();
await page.click('button[type="submit"]');
await page.waitForURL(url => !url.pathname.includes('select-local-government'), { timeout: 15000 });
}
test.describe('P2-19: 지자체 수정/삭제', () => {
test('지자체 수정 폼 표시', async ({ page }) => {
await loginAsAdmin(page);
await page.goto('/admin/local-governments/edit/1');
await expect(page.locator('input[name="lg_name"]')).toBeVisible();
});
test('지자체 목록에 수정/비활성 버튼 존재', async ({ page }) => {
await loginAsAdmin(page);
await page.goto('/admin/local-governments');
await expect(page.locator('a:has-text("수정")').first()).toBeVisible({ timeout: 10000 });
});
});
test.describe('P2-20: 비밀번호 변경', () => {
test('비밀번호 변경 폼 표시', async ({ page }) => {
await login(page, 'local');
await page.goto('/admin/password-change');
await expect(page.locator('input[name="current_password"]')).toBeVisible();
await expect(page.locator('input[name="new_password"]')).toBeVisible();
await expect(page.locator('input[name="new_password_confirm"]')).toBeVisible();
});
});
test.describe('P2-21: 로그인 실패 lock', () => {
test('잘못된 비밀번호 시 실패 카운트 메시지', async ({ page }) => {
test.setTimeout(60000);
// 3회 연속 실패하면 (실패 N/5회) 표시
for (let i = 0; i < 3; i++) {
await page.goto('/login');
await page.fill('input[name="login_id"]', 'tester_user');
await page.fill('input[name="password"]', 'wrong_password');
await page.click('button[type="submit"]');
await page.waitForURL(/\/login/, { timeout: 15000 });
await page.waitForTimeout(500);
}
// 3회 이후 실패 카운트 표시 확인
await expect(page.locator('[role="alert"]').first()).toBeVisible({ timeout: 5000 });
const alertText = await page.locator('[role="alert"]').first().textContent();
// 실패 카운트 또는 잠금 메시지 확인
expect(alertText?.includes('실패') || alertText?.includes('잠겼')).toBeTruthy();
});
});