feat: add form and page platform
This commit is contained in:
@@ -58,6 +58,14 @@ function inputWith(
|
||||
createdAtLabel: null,
|
||||
},
|
||||
}),
|
||||
getResource: async (resourceId) => ({
|
||||
ok: true,
|
||||
value: {
|
||||
resourceId,
|
||||
title: "Detail",
|
||||
createdAtLabel: null,
|
||||
},
|
||||
}),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -129,7 +137,7 @@ describe("reference feature page states", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("deduplicates optimistic create and rolls back a conflict", async () => {
|
||||
it("deduplicates create, preserves input and surfaces a conflict", async () => {
|
||||
const user = userEvent.setup();
|
||||
let finish:
|
||||
| ((result: ReferenceResult<ReferenceResourceView>) => void)
|
||||
@@ -141,31 +149,22 @@ describe("reference feature page states", () => {
|
||||
}),
|
||||
);
|
||||
renderReference(
|
||||
inputWith({
|
||||
listResources: async () => ({
|
||||
ok: true,
|
||||
value: [
|
||||
{
|
||||
resourceId: "existing",
|
||||
title: "Existing",
|
||||
createdAtLabel: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
createResource,
|
||||
}),
|
||||
inputWith({ createResource }),
|
||||
"/examples/reference-resources/new",
|
||||
);
|
||||
await screen.findByText("Existing");
|
||||
await user.type(screen.getByLabelText("새 항목 이름"), "Conflicting");
|
||||
const submit = screen.getByRole("button", { name: "추가" });
|
||||
await screen.findByRole("heading", {
|
||||
name: "Reference resource 만들기",
|
||||
});
|
||||
await user.type(
|
||||
screen.getByRole("textbox", { name: /새 항목 이름/ }),
|
||||
"Conflicting",
|
||||
);
|
||||
await user.type(screen.getByLabelText("설명"), "Keep this input");
|
||||
const submit = screen.getByRole("button", { name: "저장" });
|
||||
await user.dblClick(submit);
|
||||
|
||||
await waitFor(() => expect(createResource).toHaveBeenCalledOnce());
|
||||
expect(await screen.findByText("Conflicting")).toHaveAttribute(
|
||||
"data-optimistic",
|
||||
"true",
|
||||
);
|
||||
expect(screen.getByText("mutation-pending")).toBeVisible();
|
||||
expect(screen.getByRole("button", { name: "저장 중…" })).toBeDisabled();
|
||||
|
||||
finish?.({
|
||||
ok: false,
|
||||
@@ -175,14 +174,11 @@ describe("reference feature page states", () => {
|
||||
0,
|
||||
),
|
||||
});
|
||||
expect(await screen.findByText(/다른 변경과 충돌했습니다/)).toBeVisible();
|
||||
expect(
|
||||
await screen.findByRole("button", { name: "충돌 해결" }),
|
||||
).toBeVisible();
|
||||
expect(screen.queryByText("Conflicting")).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "충돌 해결" }));
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByText("mutation-conflict")).not.toBeInTheDocument(),
|
||||
);
|
||||
screen.getByRole("textbox", { name: /새 항목 이름/ }),
|
||||
).toHaveValue("Conflicting");
|
||||
expect(screen.getByLabelText("설명")).toHaveValue("Keep this input");
|
||||
});
|
||||
|
||||
it("keeps stale data visible during refresh failure and recovers on retry", async () => {
|
||||
@@ -219,8 +215,7 @@ describe("reference feature page states", () => {
|
||||
});
|
||||
renderReference(inputWith({ listResources }));
|
||||
await screen.findByText("Existing");
|
||||
await user.type(screen.getByLabelText("새 항목 이름"), "Created");
|
||||
await user.click(screen.getByRole("button", { name: "추가" }));
|
||||
await user.click(screen.getByRole("button", { name: "새로고침" }));
|
||||
|
||||
expect(await screen.findByText("stale-degraded")).toBeVisible();
|
||||
expect(screen.getByText("Existing")).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user