Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(web): add simple, comprehensive, and minimum e2e tests #1081

Merged
merged 32 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7c1ed58
add account and myIntegrations tests
caichi-t Feb 22, 2024
27c3b42
add: logout test
caichi-t Feb 26, 2024
c2f6523
add: integrations test
caichi-t Feb 26, 2024
43eada0
small fix
caichi-t Feb 26, 2024
f0ac1e5
add: terrain test
caichi-t Feb 26, 2024
4f929d1
add: member test
caichi-t Feb 26, 2024
676425e
add: workspace test
caichi-t Feb 26, 2024
3b99bf5
add: project test
caichi-t Feb 26, 2024
d26f7b3
fix: terrain swtich test
caichi-t Feb 26, 2024
702db0b
add: overview test
caichi-t Feb 26, 2024
05baab1
add: accesibility test
caichi-t Feb 26, 2024
c1d6d30
add: asset test
caichi-t Feb 26, 2024
f89844c
add: request test
caichi-t Feb 27, 2024
8e9f217
fix: comment on Asset test
caichi-t Feb 27, 2024
942606d
Merge branch 'main' of https://github.com/reearth/reearth-cms into fe…
caichi-t Feb 27, 2024
6844aa1
add: schema test
caichi-t Feb 27, 2024
0c4aeca
move utils for workspace
caichi-t Feb 27, 2024
f02ccb1
move utils for project
caichi-t Feb 27, 2024
1c8426a
move utils for model
caichi-t Feb 27, 2024
37acbbe
move utils for group
caichi-t Feb 27, 2024
92c85cc
move utils for comment
caichi-t Feb 27, 2024
371c56d
fix: missing import
caichi-t Feb 27, 2024
545707c
move handleFieldForm
caichi-t Feb 27, 2024
26f72bc
move createRequest func
caichi-t Feb 27, 2024
adf3e19
add: content test
caichi-t Feb 27, 2024
fa1f204
fix some codes
caichi-t Feb 27, 2024
95d8cc7
Revert "fix: synchronize account name with personal workspace name wh…
caichi-t Feb 27, 2024
57f1087
fix: request state
caichi-t Feb 28, 2024
70d9b31
add: notification closing
caichi-t Feb 28, 2024
37927ae
fix: exclude path in vite.config
caichi-t Feb 28, 2024
c765367
fix: integrations test
caichi-t Feb 28, 2024
f0129c5
Apply suggestions from code review
caichi-t Feb 28, 2024
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
9 changes: 9 additions & 0 deletions web/e2e/common/notification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Page } from "@playwright/test";

export async function closeNotification(page: Page) {
await page
.locator(".ant-notification-notice")
.last()
.locator(".ant-notification-notice-close")
.click();
}
8 changes: 8 additions & 0 deletions web/e2e/general/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from "@reearth-cms/e2e/utils";

test("Logout has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await page.locator("a").nth(1).click();
await page.getByText("Logout").click();
await expect(page.getByLabel("Log In")).toBeVisible();
});
63 changes: 63 additions & 0 deletions web/e2e/general/project.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { closeNotification } from "@reearth-cms/e2e/common/notification";
import { expect, test } from "@reearth-cms/e2e/utils";

test("Project CRUD and searching has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await page.getByRole("button", { name: "plus New Project" }).click();
await page.getByLabel("Project name").click();
await page.getByLabel("Project name").fill("project name");
await page.getByLabel("Project alias").click();
await page.getByLabel("Project alias").fill("project alias");
await page.getByLabel("Project description").click();
await page.getByLabel("Project description").fill("project description");
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("input: createProject invalid alias");
await closeNotification(page);
await page.getByLabel("Project alias").click();
await page.getByLabel("Project alias").fill("project-alias");
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully created project!");
await closeNotification(page);

await expect(page.getByText("project name", { exact: true })).toBeVisible();
await expect(page.getByText("project description", { exact: true })).toBeVisible();
await page.locator(".ant-input-affix-wrapper").click();
await page.getByPlaceholder("search projects").fill("no project");
await page.getByRole("button", { name: "search" }).click();
await expect(page.getByText("project name", { exact: true })).not.toBeVisible();
await page.getByRole("button", { name: "close-circle" }).click();
await expect(page.getByText("project name", { exact: true })).toBeVisible();
await page.getByText("project name", { exact: true }).click();
await expect(page.getByText("project name").nth(1)).toBeVisible();
await expect(page.getByText("project description")).toBeVisible();

await page.getByText("Settings").click();
await page.getByLabel("Name").click();
await page.getByLabel("Name").fill("new project name");
await page.getByLabel("Description").click();
await page.getByLabel("Description").fill("new project description");
await page.locator("form").getByRole("button", { name: "Save changes" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully updated project!");
await closeNotification(page);

await expect(page.locator("#root")).toContainText("Project Settings / new project name");
await expect(page.locator("header")).toContainText("new project name");
await page.getByRole("row", { name: "Owner" }).getByRole("switch").click();
await page.getByRole("button", { name: "Save changes" }).nth(1).click();
await expect(page.getByRole("row", { name: "Owner" }).getByRole("switch")).toHaveAttribute(
"aria-checked",
"false",
);
await expect(page.getByRole("alert").last()).toContainText("Successfully updated request roles!");
await closeNotification(page);

await page.getByText("Overview").click();
await expect(page.locator("#root")).toContainText("new project name");
await expect(page.locator("#root")).toContainText("new project description");
await page.getByText("Settings").click();
await page.getByRole("button", { name: "Delete Project" }).click();
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully deleted project!");
await closeNotification(page);
await expect(page.getByText("new project name", { exact: true })).not.toBeVisible();
});
45 changes: 45 additions & 0 deletions web/e2e/general/workspace.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { closeNotification } from "@reearth-cms/e2e/common/notification";
import { expect, test } from "@reearth-cms/e2e/utils";

test("Workspace CRUD has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await page.getByRole("button", { name: "Create a Workspace" }).click();
await page.getByLabel("Workspace name").click();
await page.getByLabel("Workspace name").fill("workspace name");
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully created workspace!");
await closeNotification(page);

await page.getByText("Workspace", { exact: true }).click();
await page.getByLabel("Workspace Name").click();
await page.getByLabel("Workspace Name").fill("new workspace name");
await page.getByRole("button", { name: "Save changes" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully updated workspace!");
await closeNotification(page);

await expect(page.locator("header")).toContainText("new workspace name");
await page.getByRole("button", { name: "Remove Workspace" }).click();
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully deleted workspace!");
await closeNotification(page);

await page.locator("a").first().click();
await expect(page.getByText("new workspace name")).not.toBeVisible();
});

test("Workspace Creating from tab has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await page.locator("a").first().click();
await page.getByText("Create Workspace").click();
await page.getByLabel("Workspace name").click();
await page.getByLabel("Workspace name").fill("workspace name");
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully created workspace!");
await closeNotification(page);

await page.getByText("Workspace", { exact: true }).click();
await page.getByRole("button", { name: "Remove Workspace" }).click();
await page.getByRole("button", { name: "OK" }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully deleted workspace!");
await closeNotification(page);
});
29 changes: 29 additions & 0 deletions web/e2e/project/accessibility.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { closeNotification } from "@reearth-cms/e2e/common/notification";
import { expect, test } from "@reearth-cms/e2e/utils";

import { createProject, deleteProject } from "./utils/project";

test("Update settings on Accesibility page has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await createProject(page);

await page.getByText("Accessibility").click();
await page.getByText("Private").click();
await page.getByText("Public", { exact: true }).click();
await page.getByRole("textbox").click();
await page.getByRole("textbox").fill("new-e2e-project-alias");
await page.getByRole("switch").click();
await page.getByRole("button", { name: "Save changes" }).click();
await expect(page.getByRole("alert").last()).toContainText(
"Successfully updated publication settings!",
);
await closeNotification(page);
await expect(page.locator("form")).toContainText("Public");
await expect(page.getByRole("textbox")).toHaveValue("new-e2e-project-alias");
await expect(page.getByRole("switch")).toHaveAttribute("aria-checked", "true");
await expect(page.locator("tbody")).toContainText(
"http://localhost:8080/api/p/new-e2e-project-alias/assets",
);

await deleteProject(page);
});
129 changes: 129 additions & 0 deletions web/e2e/project/asset.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { closeNotification } from "@reearth-cms/e2e/common/notification";
import { expect, test } from "@reearth-cms/e2e/utils";

import { crudComment } from "./utils/comment";
import { createProject, deleteProject } from "./utils/project";

const uploadFileUrl =
"https://assets.cms.plateau.reearth.io/assets/11/6d05db-ed47-4f88-b565-9eb385b1ebb0/13100_tokyo23-ku_2022_3dtiles%20_1_1_op_bldg_13101_chiyoda-ku_lod1/tileset.json";
const uploadFileName = "tileset.json";

test("Asset CRUD and Searching has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await createProject(page);

await page.getByText("Asset").click();
await page.getByRole("button", { name: "upload Upload Asset" }).click();
await page.getByRole("tab", { name: "URL" }).click();
await page.getByPlaceholder("Please input a valid URL").click();
await page.getByPlaceholder("Please input a valid URL").fill(uploadFileUrl);
await page.getByRole("button", { name: "Upload", exact: true }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully added asset!");
await closeNotification(page);
await expect(page.getByText(uploadFileName)).toBeVisible();
await page.getByPlaceholder("Please enter").click();
await page.getByPlaceholder("Please enter").fill("no asset");
await page.getByRole("button", { name: "search" }).click();
await expect(page.getByText(uploadFileName)).not.toBeVisible();
await page.getByPlaceholder("Please enter").click();
await page.getByPlaceholder("Please enter").fill("");
await page.getByRole("button", { name: "search" }).click();
await expect(page.getByText(uploadFileName)).toBeVisible();
await page.getByLabel("edit").locator("svg").click();
await page
.locator("div")
.filter({ hasText: /^Unknown Type$/ })
.nth(1)
.click();
await page.getByText("GEOJSON/KML/CZML").click();
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByRole("alert").last()).toContainText("Asset was successfully updated!");
await closeNotification(page);
await page.getByLabel("Back").click();
await page.getByLabel("", { exact: true }).check();
await page.getByText("Delete").click();
await expect(page.getByText(uploadFileName)).not.toBeVisible();
await expect(page.getByRole("alert").last()).toContainText(
"One or more assets were successfully deleted!",
);
await closeNotification(page);

await deleteProject(page);
});

test("Donwloading asset has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await createProject(page);

await page.getByText("Asset").click();
await page.getByRole("button", { name: "upload Upload Asset" }).click();
await page.getByRole("tab", { name: "URL" }).click();
await page.getByPlaceholder("Please input a valid URL").click();
await page.getByPlaceholder("Please input a valid URL").fill(uploadFileUrl);
await page.getByRole("button", { name: "Upload", exact: true }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully added asset!");
await closeNotification(page);
await expect(page.getByText(uploadFileName)).toBeVisible();

await page.getByLabel("", { exact: true }).check();
const downloadPromise = page.waitForEvent("download");
await page.getByRole("button", { name: "download Download" }).click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toEqual(uploadFileName);

await page.getByLabel("edit").locator("svg").click();
const download1Promise = page.waitForEvent("download");
await page.getByRole("button", { name: "download Download" }).click();
const download1 = await download1Promise;
expect(download1.suggestedFilename()).toEqual(uploadFileName);

await page.getByLabel("Back").click();
await page.getByLabel("", { exact: true }).check();
await page.getByText("Delete").click();
await expect(page.getByRole("alert").last()).toContainText(
"One or more assets were successfully deleted!",
);
await closeNotification(page);
await deleteProject(page);
});

test("Comment CRUD on edit page has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await createProject(page);

await page.getByText("Asset").click();
await page.getByRole("button", { name: "upload Upload Asset" }).click();
await page.getByRole("tab", { name: "URL" }).click();
await page.getByPlaceholder("Please input a valid URL").click();
await page.getByPlaceholder("Please input a valid URL").fill(uploadFileUrl);
await page.getByRole("button", { name: "Upload", exact: true }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully added asset!");
await closeNotification(page);
await expect(page.getByText(uploadFileName)).toBeVisible();

await page.getByRole("cell", { name: "edit" }).locator("svg").click();
await page.getByLabel("message").click();
await expect(page.getByText("CommentsComment")).toBeVisible();
await crudComment(page);
await deleteProject(page);
});

test("Comment CRUD on Asset page has succeeded", async ({ reearth, page }) => {
await reearth.goto("/", { waitUntil: "domcontentloaded" });
await createProject(page);

await page.getByText("Asset").click();
await page.getByRole("button", { name: "upload Upload Asset" }).click();
await page.getByRole("tab", { name: "URL" }).click();
await page.getByPlaceholder("Please input a valid URL").click();
await page.getByPlaceholder("Please input a valid URL").fill(uploadFileUrl);
await page.getByRole("button", { name: "Upload", exact: true }).click();
await expect(page.getByRole("alert").last()).toContainText("Successfully added asset!");
await closeNotification(page);
await expect(page.getByText(uploadFileName)).toBeVisible();

await page.getByRole("button", { name: "0" }).click();
await expect(page.getByText("CommentsNo comments.Comment")).toBeVisible();
await crudComment(page);
await deleteProject(page);
});
Loading
Loading