// @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: 30000 }); } 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: 30000 }); 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(); }); });