forked from baron/baron-sso
dev 병합 code check 수정
This commit is contained in:
@@ -261,19 +261,30 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
const { pathname, searchParams } = url;
|
||||
const method = request.method();
|
||||
|
||||
if (pathname === "/api/v1/dev/requests" && method === "GET") {
|
||||
return json(route, { items: state.developerRequests ?? [] });
|
||||
if (
|
||||
(pathname === "/api/v1/dev/requests" ||
|
||||
pathname === "/api/v1/dev/developer-request/list") &&
|
||||
method === "GET"
|
||||
) {
|
||||
return json(route, state.developerRequests ?? []);
|
||||
}
|
||||
|
||||
if (pathname === "/api/v1/dev/requests" && method === "POST") {
|
||||
const payload = (request.postDataJSON() as {
|
||||
organization?: string;
|
||||
reason?: string;
|
||||
}) || {};
|
||||
if (
|
||||
(pathname === "/api/v1/dev/requests" ||
|
||||
pathname === "/api/v1/dev/developer-request") &&
|
||||
method === "POST"
|
||||
) {
|
||||
const payload =
|
||||
(request.postDataJSON() as {
|
||||
name?: string;
|
||||
organization?: string;
|
||||
reason?: string;
|
||||
}) || {};
|
||||
const created: DeveloperRequest = {
|
||||
id: `req-${Date.now()}`,
|
||||
userId: "playwright-user",
|
||||
userName: "Playwright User",
|
||||
userName: payload.name ?? "Playwright User",
|
||||
name: payload.name ?? "Playwright User",
|
||||
userEmail: "playwright@example.com",
|
||||
organization: payload.organization ?? "Unknown",
|
||||
reason: payload.reason ?? "No reason",
|
||||
@@ -288,7 +299,11 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
return json(route, created, 201);
|
||||
}
|
||||
|
||||
if (pathname === "/api/v1/dev/requests/status" && method === "GET") {
|
||||
if (
|
||||
(pathname === "/api/v1/dev/requests/status" ||
|
||||
pathname === "/api/v1/dev/developer-request/status") &&
|
||||
method === "GET"
|
||||
) {
|
||||
const myRequest = (state.developerRequests ?? []).find(
|
||||
(r) => r.userId === "playwright-user",
|
||||
);
|
||||
@@ -296,11 +311,12 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
}
|
||||
|
||||
if (
|
||||
pathname.startsWith("/api/v1/dev/requests/") &&
|
||||
(pathname.startsWith("/api/v1/dev/requests/") ||
|
||||
pathname.startsWith("/api/v1/dev/developer-request/")) &&
|
||||
pathname.endsWith("/approve") &&
|
||||
method === "POST"
|
||||
) {
|
||||
const reqId = pathname.split("/")[5] ?? "";
|
||||
const reqId = pathname.split("/")[5] ?? pathname.split("/")[4] ?? "";
|
||||
const found = state.developerRequests?.find((r) => r.id === reqId);
|
||||
if (!found) return json(route, { error: "not found" }, 404);
|
||||
found.status = "approved";
|
||||
@@ -309,11 +325,12 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
}
|
||||
|
||||
if (
|
||||
pathname.startsWith("/api/v1/dev/requests/") &&
|
||||
(pathname.startsWith("/api/v1/dev/requests/") ||
|
||||
pathname.startsWith("/api/v1/dev/developer-request/")) &&
|
||||
pathname.endsWith("/reject") &&
|
||||
method === "POST"
|
||||
) {
|
||||
const reqId = pathname.split("/")[5] ?? "";
|
||||
const reqId = pathname.split("/")[5] ?? pathname.split("/")[4] ?? "";
|
||||
const found = state.developerRequests?.find((r) => r.id === reqId);
|
||||
if (!found) return json(route, { error: "not found" }, 404);
|
||||
found.status = "rejected";
|
||||
@@ -322,11 +339,12 @@ export async function installDevApiMock(page: Page, state: DevApiMockState) {
|
||||
}
|
||||
|
||||
if (
|
||||
pathname.startsWith("/api/v1/dev/requests/") &&
|
||||
pathname.endsWith("/cancel") &&
|
||||
(pathname.startsWith("/api/v1/dev/requests/") ||
|
||||
pathname.startsWith("/api/v1/dev/developer-request/")) &&
|
||||
(pathname.endsWith("/cancel") || pathname.endsWith("/cancel-approval")) &&
|
||||
method === "POST"
|
||||
) {
|
||||
const reqId = pathname.split("/")[5] ?? "";
|
||||
const reqId = pathname.split("/")[5] ?? pathname.split("/")[4] ?? "";
|
||||
const found = state.developerRequests?.find((r) => r.id === reqId);
|
||||
if (!found) return json(route, { error: "not found" }, 404);
|
||||
found.status = "pending";
|
||||
|
||||
Reference in New Issue
Block a user