수정: 관리자 e2e 인증 흐름 안정화
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user