Files
taxbaik/tests/e2e/helpers/admin-auth.ts
T
kjh2064 e0067c6f55
TaxBaik CI/CD / build-and-deploy (push) Successful in 1m13s
TaxBaik Browser E2E / browser-e2e (push) Failing after 3m26s
수정: 관리자 e2e 인증 흐름 안정화
2026-06-27 21:16:19 +09:00

22 lines
719 B
TypeScript

import { expect, type APIRequestContext, type Page } from '@playwright/test';
export async function getAdminToken(
request: APIRequestContext,
baseUrl: string,
username: string,
password: string,
) {
const response = await request.post(`${baseUrl}/api/auth/login`, {
data: { username, password },
});
expect(response.status(), 'login API should accept the configured admin credentials').toBe(200);
const body = await response.json();
expect(body?.token, 'login API should return a token').toBeTruthy();
return body.token as string;
}
export async function installAdminToken(page: Page, token: string) {
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
}