-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): add playright config and createBrain e2e test (#1177)
* chore: add playright config * feat: add playright first examples * feat: add 'test-e2e command' * feat: add createBrain E2E test
- Loading branch information
1 parent
143d32d
commit 7dd4049
Showing
14 changed files
with
376 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,6 @@ next-env.d.ts | |
|
||
# Sentry Auth Token | ||
.sentryclirc | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
import { chatTests } from "./tests/chat"; | ||
import { createBrainTests } from "./tests/createBrain"; | ||
import { uploadTests } from "./tests/upload"; | ||
|
||
test.describe(createBrainTests); | ||
|
||
test.describe.skip(uploadTests); | ||
|
||
test.describe.skip(chatTests); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
import { login } from "../utils/login"; | ||
|
||
export const chatTests = (): void => { | ||
test("chat", async ({ page }) => { | ||
await login(page); | ||
await page.goto("/chat"); | ||
await page.getByRole("combobox").locator("div").nth(2).click(); | ||
await page.getByRole("combobox").fill("Hello"); | ||
await page.getByTestId("submit-button").click(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
import { login } from "../utils/login"; | ||
|
||
export const createBrainTests = (): void => { | ||
test("create brain", async ({ page }) => { | ||
await login(page); | ||
await page.getByTestId("brain-management-button").first().click(); | ||
await page.getByTestId("add-brain-button").click(); | ||
await page.getByTestId("brain-name").fill("Test brain"); | ||
await page.getByTestId("create-brain-submit-button").click(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { test } from "@playwright/test"; | ||
|
||
import { login } from "../utils/login"; | ||
|
||
export const uploadTests = (): void => { | ||
test("upload", async ({ page }) => { | ||
await login(page); | ||
await page.goto("/chat"); | ||
await page.getByTestId("upload-button").click(); | ||
await page | ||
.getByRole("button", { | ||
name: "Drag and drop files here, or click to browse", | ||
}) | ||
.click(); | ||
await page.getByPlaceholder("Insert website URL").click(); | ||
await page.getByPlaceholder("Insert website URL").fill("https://quivr.app"); | ||
await page.getByPlaceholder("Insert website URL").press("Enter"); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Page } from "@playwright/test"; | ||
|
||
export const login = async (page: Page): Promise<void> => { | ||
const frontendUrl = process.env.NEXT_PUBLIC_E2E_URL; | ||
const email = process.env.NEXT_PUBLIC_E2E_EMAIL; | ||
const password = process.env.NEXT_PUBLIC_E2E_PASSWORD; | ||
|
||
if (frontendUrl === undefined) { | ||
throw new Error("NEXT_PUBLIC_E2E_URL is not defined"); | ||
} | ||
if (email === undefined) { | ||
throw new Error("NEXT_PUBLIC_E2E_EMAIL is not defined"); | ||
} | ||
if (password === undefined) { | ||
throw new Error("NEXT_PUBLIC_E2E_PASSWORD is not defined"); | ||
} | ||
|
||
await page.goto(frontendUrl); | ||
await page.getByTestId("login-button").first().click(); | ||
await page.getByPlaceholder("Email").fill(email); | ||
await page.getByPlaceholder("Password").fill(password); | ||
await page.getByTestId("submit-login").click(); | ||
await page.waitForURL(/chat/); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
import dotenv from "dotenv"; | ||
dotenv.config(); | ||
export default defineConfig({ | ||
testDir: "./e2e", | ||
fullyParallel: true, | ||
forbidOnly: !(process.env.CI == null), | ||
retries: process.env.CI != null ? 2 : 0, | ||
workers: 1, | ||
reporter: "html", | ||
testMatch: "e2e/index.ts", | ||
use: { | ||
trace: "on-first-retry", | ||
}, | ||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
], | ||
webServer: { | ||
command: | ||
process.env.NODE_ENV === "production" | ||
? "yarn run build && yarn run start -p 3003" | ||
: "yarn run dev -p 3003", | ||
}, | ||
}); |
Oops, something went wrong.