test: 관리자 e2e 검증 안정화
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import { expect, type APIRequestContext, type Page } from '@playwright/test';
|
||||
|
||||
export type InquiryListItem = {
|
||||
id: number;
|
||||
name: string;
|
||||
phone: string;
|
||||
message: string;
|
||||
};
|
||||
|
||||
export async function getAdminToken(
|
||||
request: APIRequestContext,
|
||||
baseUrl: string,
|
||||
@@ -19,3 +26,21 @@ export async function getAdminToken(
|
||||
export async function installAdminToken(page: Page, token: string) {
|
||||
await page.addInitScript(value => localStorage.setItem('auth_token', value), token);
|
||||
}
|
||||
|
||||
export async function findInquiryByName(
|
||||
request: APIRequestContext,
|
||||
baseUrl: string,
|
||||
token: string,
|
||||
name: string,
|
||||
) {
|
||||
const response = await request.get(`${baseUrl}/api/inquiry?page=1&pageSize=100`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
expect(response.status(), 'admin inquiry list API should be accessible with the token').toBe(200);
|
||||
const body = await response.json();
|
||||
const items = (body?.data ?? []) as InquiryListItem[];
|
||||
const inquiry = items.find(item => item.name === name);
|
||||
expect(inquiry, `created inquiry ${name} should appear in the admin inquiry API`).toBeTruthy();
|
||||
return inquiry!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user