Skip to content

Commit

Permalink
fix(web): keep search word and selected view after going back to tabl…
Browse files Browse the repository at this point in the history
…e from edit (#1138)

* fix: keep searchTerm & currentView

* fix: e2e tests
  • Loading branch information
caichi-t authored May 8, 2024
1 parent b3ae6d9 commit 41569b1
Show file tree
Hide file tree
Showing 22 changed files with 77 additions and 62 deletions.
4 changes: 2 additions & 2 deletions web/e2e/project/content/content.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test("Item CRUD and searching has succeeded", async ({ page }) => {
await page.getByPlaceholder("input search text").fill("");
await page.getByRole("button", { name: "search" }).click();
await expect(page.getByRole("cell", { name: "text", exact: true })).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("text").click();

await page.getByLabel("text").click();
Expand Down Expand Up @@ -66,7 +66,7 @@ test("Publishing and Unpublishing item has succeeded", async ({ page }) => {
await page.getByText("Unpublish").click();
await closeNotification(page);
await expect(page.getByText("DRAFT")).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByText("DRAFT")).toBeVisible();
await page.getByRole("button", { name: "Publish" }).click();
await closeNotification(page);
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/asset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test("Asset field creating and updating has succeeded", async ({ page }) => {
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByText("tileset.json")).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByRole("button", { name: `folder ${uploadFileName_1}` }).click();
await page.getByRole("button", { name: "upload Upload Asset" }).click();
await page.getByRole("tab", { name: "URL" }).click();
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/boolean.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test("Boolean field creating and updating has succeeded", async ({ page }) => {
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByRole("switch", { name: "close" })).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("boolean1").click();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test("Date field creating and updating has succeeded", async ({ page }) => {
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.locator("tbody")).toContainText("2024-01-01");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByRole("button", { name: "close-circle" }).click();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
Expand Down
18 changes: 9 additions & 9 deletions web/e2e/project/item/fields/group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test("Group field creating and updating has succeeded", async ({ page }) => {
await page.getByLabel("Back").click();
// TO DO: check if the group field shows correctly

await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("text1")).toHaveValue("text1");
await page.getByLabel("text1").click();
await page.getByLabel("text1").fill("new text1");
Expand Down Expand Up @@ -102,7 +102,7 @@ test("Group field creating and updating has succeeded", async ({ page }) => {
await closeNotification(page);
await page.getByText("Content").click();
await page.getByText("e2e model name").click();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByRole("main")).toContainText("new text1(unique)");
await expect(page.getByRole("main")).toContainText("new text1 description");
await expect(page.getByLabel("new text1(unique)")).toHaveValue("new text1");
Expand All @@ -114,7 +114,7 @@ test("Group field creating and updating has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("new text1(unique)")).toHaveValue("text1");
await page.getByLabel("Back").click();
await page.getByRole("button", { name: "plus New Item" }).click();
Expand All @@ -134,14 +134,14 @@ test("Group field creating and updating has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByRole("textbox").nth(0)).toHaveValue("text1");
await expect(page.getByRole("textbox").nth(1)).toHaveValue("text2");
await page.getByRole("button", { name: "arrow-down" }).first().click();
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByRole("textbox").nth(0)).toHaveValue("text2");
await expect(page.getByRole("textbox").nth(1)).toHaveValue("text1");
});
Expand Down Expand Up @@ -212,7 +212,7 @@ test("Group field editing has succeeded", async ({ page }) => {
await closeNotification(page);
await page.getByText("Content").click();
await expect(page.locator("thead")).toContainText("new group1");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByRole("main")).toContainText("new group1");
await expect(page.getByRole("main")).toContainText("new group1 (1)");
await expect(page.getByRole("main")).toContainText("new group1 description");
Expand All @@ -232,7 +232,7 @@ test("Group field editing has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(
page
.locator("div")
Expand All @@ -253,7 +253,7 @@ test("Group field editing has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByLabel("text1")).toHaveValue("text1");

await page.locator("span").filter({ hasText: "Schema" }).click();
Expand Down Expand Up @@ -283,7 +283,7 @@ test("Group field editing has succeeded", async ({ page }) => {
await page.getByRole("button", { name: "Save" }).click();
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByRole("textbox").nth(0)).toHaveValue("text1");
await expect(page.getByRole("textbox").nth(1)).toHaveValue("text2");
await expect(page.getByRole("textbox").nth(2)).toHaveValue("text2");
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test("Int field creating and updating has succeeded", async ({ page }) => {
await page.getByLabel("Back").click();
await expect(page.getByRole("cell", { name: "1", exact: true })).toBeVisible();

await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("int1").click();
await page.getByLabel("int1").fill("2");
await page.getByRole("button", { name: "Save" }).click();
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test("Option field creating and updating has succeeded", async ({ page }) => {
await page.getByLabel("Back").click();
await expect(page.getByText("first")).toBeVisible();

await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("close-circle").locator("svg").click();
await page.getByLabel("option1").click();
await page.getByTitle("second").locator("div").click();
Expand Down
4 changes: 2 additions & 2 deletions web/e2e/project/item/fields/reference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ test("One-way reference field creating and updating has succeeded", async ({ pag
await closeNotification(page);
await page.getByLabel("Back").click();
await expect(page.getByRole("cell", { name: "text1" }).locator("span").first()).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.locator("#root").getByText("text1")).toBeVisible();
await page.getByRole("button", { name: "Refer to item" }).click();
await page.getByRole("row").getByRole("button").nth(1).hover();
Expand Down Expand Up @@ -270,7 +270,7 @@ test("Two-way reference field editing has succeeded", async ({ page }) => {
await expect(
page.getByRole("cell", { name: "text2", exact: true }).locator("span").first(),
).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await page.getByRole("button", { name: "Refer to item" }).click();
await page.getByRole("row").getByRole("button").nth(0).hover();
await page.getByRole("row").getByRole("button").nth(0).click();
Expand Down
2 changes: 1 addition & 1 deletion web/e2e/project/item/fields/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test("URL field creating and updating has succeeded", async ({ page }) => {
await page.getByLabel("Back").click();
await expect(page.getByRole("cell", { name: "http://test1.com", exact: true })).toBeVisible();

await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("url1").click();
await page.getByLabel("url1").fill("http://test2.com");
await page.getByRole("button", { name: "Save" }).click();
Expand Down
6 changes: 3 additions & 3 deletions web/e2e/project/item/metadata/boolean.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ test("Boolean metadata creating and updating has succeeded", async ({ page }) =>
await expect(page.getByLabel("boolean1")).toHaveAttribute("aria-checked", "false");
await page.getByLabel("Back").click();
await expect(page.getByRole("switch", { name: "close" })).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("boolean1").click();
await closeNotification(page);
await expect(page.getByLabel("boolean1")).toHaveAttribute("aria-checked", "true");
await page.getByLabel("Back").click();
await page.getByRole("switch", { name: "check" }).click();
await closeNotification(page);
await expect(page.getByRole("switch", { name: "close" })).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("boolean1")).toHaveAttribute("aria-checked", "false");
});

Expand Down Expand Up @@ -132,7 +132,7 @@ test("Boolean metadata editing has succeeded", async ({ page }) => {
await expect(page.getByRole("switch").nth(3)).toHaveAttribute("aria-checked", "true");
await page.getByRole("switch").nth(1).click();
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByRole("switch").nth(0)).toHaveAttribute("aria-checked", "false");
await expect(page.getByRole("switch").nth(1)).toHaveAttribute("aria-checked", "false");
await expect(page.getByRole("switch").nth(2)).toHaveAttribute("aria-checked", "true");
Expand Down
7 changes: 4 additions & 3 deletions web/e2e/project/item/metadata/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ test("Checkbox metadata creating and updating has succeeded", async ({ page }) =
await expect(page.getByLabel("checkbox1")).not.toBeChecked();
await page.getByLabel("Back").click();
await expect(page.getByLabel("", { exact: true }).nth(1)).not.toBeChecked();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("checkbox1").check();
await closeNotification(page);
await expect(page.getByLabel("checkbox1")).toBeChecked();
await page.getByLabel("Back").click();
await expect(page.getByLabel("", { exact: true }).nth(1)).toBeChecked();
await page.waitForTimeout(100);
await page.getByLabel("", { exact: true }).nth(1).uncheck();
await closeNotification(page);
await expect(page.getByLabel("", { exact: true }).nth(1)).not.toBeChecked();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("checkbox1")).not.toBeChecked();
});

Expand Down Expand Up @@ -140,7 +141,7 @@ test("Checkbox metadata editing has succeeded", async ({ page }) => {
).toBeChecked();
await page.getByRole("tooltip", { name: "new checkbox1" }).getByLabel("").nth(1).check();
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByLabel("", { exact: true }).nth(0)).toBeChecked();
await expect(page.getByLabel("", { exact: true }).nth(1)).toBeChecked();
await expect(page.getByLabel("", { exact: true }).nth(2)).toBeChecked();
Expand Down
6 changes: 3 additions & 3 deletions web/e2e/project/item/metadata/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test("Date metadata creating and updating has succeeded", async ({ page }) => {
await expect(page.getByPlaceholder("Select date")).toHaveValue("2024-01-01");
await page.getByLabel("Back").click();
await expect(page.getByPlaceholder("-")).toHaveValue("2024-01-01");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByPlaceholder("Select date").click();
await page.getByPlaceholder("Select date").fill("2024-01-02");
await page.getByPlaceholder("Select date").press("Enter");
Expand All @@ -67,7 +67,7 @@ test("Date metadata creating and updating has succeeded", async ({ page }) => {
await page.getByPlaceholder("-").press("Enter");
await closeNotification(page);
await expect(page.getByPlaceholder("-")).toHaveValue("2024-01-03");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByPlaceholder("Select date")).toHaveValue("2024-01-03");
});

Expand Down Expand Up @@ -152,7 +152,7 @@ test("Date metadata editing has succeeded", async ({ page }) => {
await page.getByRole("tooltip").getByRole("textbox").nth(1).fill("2024-01-04");
await page.getByRole("tooltip").getByRole("textbox").nth(1).press("Enter");
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByRole("textbox").nth(0)).toHaveValue("2024-01-01");
await expect(page.getByRole("textbox").nth(1)).toHaveValue("2024-01-04");
await expect(page.getByRole("textbox").nth(2)).toHaveValue("2024-01-02");
Expand Down
6 changes: 3 additions & 3 deletions web/e2e/project/item/metadata/tag.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ test("Tag metadata creating and updating has succeeded", async ({ page }) => {
await expect(page.locator("#root").getByText("Tag1", { exact: true })).toBeVisible();
await page.getByLabel("Back").click();
await expect(page.getByText("Tag1", { exact: true })).toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("close-circle").locator("svg").click();
await page.getByLabel("tag1").click();
await page
Expand All @@ -89,7 +89,7 @@ test("Tag metadata creating and updating has succeeded", async ({ page }) => {
await page.getByRole("cell", { name: "Tag1", exact: true }).locator("svg").click();
await closeNotification(page);
await expect(page.locator("#root").getByText("Tag1", { exact: true }).first()).not.toBeVisible();
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.locator("#root").getByText("Tag1", { exact: true })).not.toBeVisible();
});

Expand Down Expand Up @@ -174,7 +174,7 @@ test("Tag metadata editing has succeeded", async ({ page }) => {
await page.getByRole("cell", { name: "Tag2 Tag3" }).click();
await page.getByText("Tag2").nth(2).click();
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByText("Tag3")).toBeVisible();
await page.getByLabel("close-circle").locator("svg").click();
await expect(page.getByText("Please input field!")).toBeVisible();
Expand Down
6 changes: 3 additions & 3 deletions web/e2e/project/item/metadata/text.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test("Text metadata creating and updating has succeeded", async ({ page }) => {
await expect(page.getByLabel("text1")).toHaveValue("text1");
await page.getByLabel("Back").click();
await expect(page.getByPlaceholder("-")).toHaveValue("text1");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("text1").click();
await page.getByLabel("text1").fill("new text1");
await page.getByLabel("Back").click();
Expand All @@ -66,7 +66,7 @@ test("Text metadata creating and updating has succeeded", async ({ page }) => {
await page.locator(".ant-table-body").click();
await closeNotification(page);
await expect(page.getByPlaceholder("-")).toHaveValue("text1");
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();

await expect(page.getByLabel("text1")).toHaveValue("text1");
});
Expand Down Expand Up @@ -150,7 +150,7 @@ test("Text metadata editing has succeeded", async ({ page }) => {
await page.getByPlaceholder("-").nth(1).fill("text3");
await page.getByRole("tooltip").getByText("new text1").click();
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).first().click();
await page.getByRole("cell").getByLabel("edit").locator("svg").first().click();
await expect(page.getByLabel("new text1(unique)")).toHaveValue("text3");
await page.getByRole("button", { name: "plus New" }).click();
await page
Expand Down
4 changes: 2 additions & 2 deletions web/e2e/project/item/metadata/update.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ test.afterEach(async ({ page }) => {
test("Updating metadata added later from table has succeeded", async ({ page }) => {
await page.getByRole("switch").click();
await closeNotification(page);
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await expect(page.getByLabel("boolean")).toHaveAttribute("aria-checked", "true");
});

test("Updating metadata added later from edit page has succeeded", async ({ page }) => {
await page.getByRole("link", { name: "edit", exact: true }).click();
await page.getByRole("cell").getByLabel("edit").locator("svg").click();
await page.getByLabel("boolean").click();
await closeNotification(page);
await page.getByLabel("Back").click();
Expand Down
Loading

0 comments on commit 41569b1

Please sign in to comment.