Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

test: E2E tests for dashboard #363

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
789 changes: 787 additions & 2 deletions e2e/dashboard.spec.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const config = {
userId: process.env["REEARTH_WEB_E2E_USER_ID"],
userName: process.env["REEARTH_WEB_E2E_USERNAME"],
password: process.env["REEARTH_WEB_E2E_PASSWORD"],
teamId: process.env["REEARTH_WEB_E2E_TEAM_ID"],
workspaceId: process.env["REEARTH_WEB_E2E_TEAM_ID"],
authAudience: process.env["REEARTH_WEB_AUTH0_AUDIENCE"],
authClientId: process.env["REEARTH_WEB_AUTH0_CLIENT_ID"],
authUrl: process.env["REEARTH_WEB_AUTH0_DOMAIN"],
Expand Down
7 changes: 4 additions & 3 deletions e2e/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// eslint-disable-next-line no-restricted-imports
import { type APIRequestContext, request, test as base, type Page } from "@playwright/test";
// import Workspace from "@reearth/components/molecules/Dashboard/Workspace";

import { config, getAccessToken, type Config } from "./config";

Expand Down Expand Up @@ -76,11 +77,11 @@ export async function initUser(
throw new Error("access token is not initialized");
}

const { userName, userId, teamId, api, signUpSecret } = config;
const { userName, userId, workspaceId: teamId, api, signUpSecret } = config;

if (!userName || !userId || !teamId || !api) {
throw new Error(
`either userName, userId, teamId and api are missing: ${JSON.stringify({
`either userName, userId,teamId and api are missing: ${JSON.stringify({
userName,
userId,
teamId,
Expand All @@ -96,7 +97,7 @@ export async function initUser(
data: {
query: `mutation($userId: ID!, $teamId: ID!, $lang: Lang, $secret: String) {
deleteMe(input: { userId: $userId }) { userId }
signup(input: { lang: $lang, userId: $userId, teamId: $teamId, secret: $secret }) { user { id } }
signup(input: { lang: $lang, userId: $userId,teamId: $teamId, secret: $secret }) { user { id } }
}`,
variables: {
userId,
Expand Down
Binary file added images/RPA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/location.webp
Binary file not shown.
Binary file added images/reearth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ロボット.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@ import { type PlaywrightTestConfig } from "@playwright/test";
import dotenv from "dotenv";

dotenv.config();
const localHost = "http://localhost:3000/";
const isLocal =
!process.env.REEARTH_WEB_E2E_BASEURL || process.env.REEARTH_WEB_E2E_BASEURL.includes(localHost);

const config: PlaywrightTestConfig = {
...(isLocal
? {
webServer: {
command: "yarn start",
url: localHost,
},
}
: {}),
use: {
baseURL: process.env.REEARTH_WEB_E2E_BASEURL || "http://localhost:3000/",
screenshot: "only-on-failure",
video: "retain-on-failure",
// baseURL: process.env.REEARTH_WEB_E2E_BASEURL || "http://localhost:3000/",
baseURL: process.env.REEARTH_WEB_E2E_BASEURL || localHost,
headless: false,
screenshot: "on",
video: "on",
// screenshot: "only-on-failure",
// video: "retain-on-failure",
},
testDir: "e2e",
globalSetup: "./e2e/utils/setup.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/Dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const Dashboard: React.FC<Props> = ({
ref={wrapperRef}
onScroll={e => {
!isLoading && hasMoreProjects && onScrollToBottom(e, onGetMoreProjects);
}}>
}}
data-testid="dashboard-wrapper">
{header}
<Content>
{children}
Expand Down