Files

36 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

/**
* 공통 인증 헬퍼
*/
const TEST_ACCOUNTS = {
admin: { id: 'tester_admin', password: 'test1234!', level: 4 },
local: { id: 'tester_local', password: 'test1234!', level: 3 },
shop: { id: 'tester_shop', password: 'test1234!', level: 2 },
user: { id: 'tester_user', password: 'test1234!', level: 1 },
};
/**
* 로그인 수행
* @param {import('@playwright/test').Page} page
* @param {'admin'|'local'|'shop'|'user'} role
*/
async function login(page, role = 'admin') {
const acct = TEST_ACCOUNTS[role];
await page.goto('/login');
await page.fill('input[name="login_id"]', acct.id);
await page.fill('input[name="password"]', acct.password);
await page.click('button[type="submit"]');
// 로그인 후 리다이렉트 대기
await page.waitForURL(url => !url.pathname.includes('/login'), { timeout: 10000 });
}
/**
* 로그아웃 수행
* @param {import('@playwright/test').Page} page
*/
async function logout(page) {
await page.goto('/logout');
}
module.exports = { TEST_ACCOUNTS, login, logout };