Skip to content

Commit

Permalink
fix(web): group field values sometimes disapper after refreshing page (
Browse files Browse the repository at this point in the history
  • Loading branch information
caichi-t authored Aug 5, 2024
1 parent ccba0a4 commit 7a253a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions web/e2e/project/item/fields/boolean.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ test("Boolean field creating and updating has succeeded", async ({ page }) => {
await expect(page.locator("label")).toContainText("boolean1");
await expect(page.getByRole("main")).toContainText("boolean1 description");

await page.getByLabel("boolean1").click();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByRole("switch", { name: "close" })).toBeVisible();
await expect(page.getByRole("switch")).toHaveAttribute("aria-checked", "true");
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByRole("switch")).toHaveAttribute("aria-checked", "true");
await page.getByLabel("boolean1").click();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByRole("switch", { name: "check" })).toBeVisible();
await expect(page.getByRole("switch")).toHaveAttribute("aria-checked", "false");
});

test("Boolean field editing has succeeded", async ({ page }) => {
Expand All @@ -61,7 +63,7 @@ test("Boolean field editing has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByRole("switch", { name: "check" })).toBeVisible();
await expect(page.getByRole("switch")).toHaveAttribute("aria-checked", "true");
await page.getByText("Schema").click();
await page.getByRole("img", { name: "ellipsis" }).locator("svg").click();
await page.getByLabel("Display name").click();
Expand Down
1 change: 1 addition & 0 deletions web/e2e/project/item/fields/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test("Int field creating and updating has succeeded", async ({ page }) => {
await expect(page.getByRole("cell", { name: "1", exact: true })).toBeVisible();

await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("int1")).toHaveValue("1");
await page.getByLabel("int1").click();
await page.getByLabel("int1").fill("2");
await page.getByRole("button", { name: "Save" }).click();
Expand Down
1 change: 1 addition & 0 deletions web/e2e/project/item/fields/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test("URL field creating and updating has succeeded", async ({ page }) => {
await expect(page.getByRole("cell", { name: "http://test1.com", exact: true })).toBeVisible();

await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("url1")).toHaveValue("http://test1.com");
await page.getByLabel("url1").click();
await page.getByLabel("url1").fill("http://test2.com");
await page.getByRole("button", { name: "Save" }).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ export default () => {
const [initialFormValues, setInitialFormValues] = useState<Record<string, any>>({});

useEffect(() => {
if (itemLoading) return;
const handleInitialValuesSet = async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const initialValues: Record<string, any> = {};
Expand Down Expand Up @@ -430,7 +431,7 @@ export default () => {
setInitialFormValues(initialValues);
};
handleInitialValuesSet();
}, [currentItem, currentModel, handleGroupGet, updateValueConvert, valueGet]);
}, [itemLoading, currentItem, currentModel, handleGroupGet, updateValueConvert, valueGet]);

const initialMetaFormValues: Record<string, unknown> = useMemo(() => {
const initialValues: Record<string, unknown> = {};
Expand Down

0 comments on commit 7a253a0

Please sign in to comment.