Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,40 @@ describe("HopCharlie console (platform API)", () => {
expect(screen.getByText(/끝나지 않은 시작 요청을 같은 옵션으로 다시 보냅니다/)).toBeInTheDocument();
});

it("keeps the map on screen while the platform runs the start checks", { timeout: 10000 }, async () => {
let starting = false;
let polled = 0;
let release: (() => void) | undefined;
installFetch((c: FakeCall) => {
const u = new URL(c.url, "http://x");
if (u.pathname === "/v1/plans") {
if (starting) polled++;
return json(200, { plans: [{ ...basePlan, status: starting ? "starting" : "pending_approval" }] });
}
if (u.pathname === "/v1/migrations" && c.method === "POST") {
// the platform holds the plan in starting until its checks answer and the run exists
starting = true;
return new Promise<Response>((resolve) => {
release = () => resolve(json(502, { error: { code: "bad_gateway", message: "upstream closed" } }));
});
}
if (u.pathname === "/v1/audit") return json(200, { entries: [] });
return route(() => [])(c);
});
storeSession();
const { user } = setup("", "live");
window.location.hash = "#migrate-shop";
await user.click(await screen.findByRole("button", { name: "승인하고 시작" }));
expect(screen.getByTitle("이주 지도")).toBeInTheDocument();

// the plans poll sees the plan in starting before the start request answers with its run
await waitFor(() => expect(polled).toBeGreaterThan(0), { timeout: 5000 });
await act(() => new Promise((r) => setTimeout(r, 100)));
expect(screen.getByTitle("이주 지도")).toBeInTheDocument();
expect(screen.queryByLabelText("옮겨 갈 환경")).toBeNull();
release?.();
});

it("starts the next plan from the default options after a reject", async () => {
let rejected = false;
let submitted = false;
Expand Down
4 changes: 3 additions & 1 deletion src/data/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ export function useLiveMigration(): MigrationView {
// an older Plan the page may have picked up.
// A started run whose first snapshot has not arrived yet keeps its Plan on screen (its status is
// already starting/started), so the page does not drop back to the setup form until the run shows.
const stage: MigrationView["stage"] = run ? "run" : planning || currentAI ? "ai" : plan?.status === "pending_approval" || plan?.status === "approved" || (runId && plan) ? "review" : "setup";
// So does a Plan in starting before the start answers with its run: the platform holds it there while
// its start checks reach the clusters, which takes seconds.
const stage: MigrationView["stage"] = run ? "run" : planning || currentAI ? "ai" : plan?.status === "pending_approval" || plan?.status === "approved" || plan?.status === "starting" || (runId && plan) ? "review" : "setup";

// The Plan from the platform's draft, without the AI: the "Plan 작성" path, and an AI start answered no_database.
const draftAndSubmit = async (name: string, source: string) => {
Expand Down