commit
0fe70a8347
9 changed files with 577 additions and 0 deletions
27
src/frontend/.github/workflows/playwright.yml
vendored
Normal file
27
src/frontend/.github/workflows/playwright.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: Playwright Tests
|
||||
on:
|
||||
push:
|
||||
branches: [ main, master ]
|
||||
pull_request:
|
||||
branches: [ main, master ]
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps
|
||||
- name: Run Playwright tests
|
||||
run: npx playwright test
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
||||
3
src/frontend/.gitignore
vendored
3
src/frontend/.gitignore
vendored
|
|
@ -21,3 +21,6 @@
|
|||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
|
|
|
|||
229
src/frontend/harFiles/langflow.har
Normal file
229
src/frontend/harFiles/langflow.har
Normal file
File diff suppressed because one or more lines are too long
60
src/frontend/package-lock.json
generated
60
src/frontend/package-lock.json
generated
|
|
@ -74,6 +74,7 @@
|
|||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.38.0",
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/core": "^1.3.80",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
|
|
@ -1435,6 +1436,21 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.38.0",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.38.0.tgz",
|
||||
"integrity": "sha512-xis/RXXsLxwThKnlIXouxmIvvT3zvQj1JE39GsNieMUrMpb3/GySHDh2j8itCG22qKVD4MYLBp7xB73cUW/UUw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"playwright": "1.38.0"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/@popperjs/core": {
|
||||
"version": "2.11.8",
|
||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
|
||||
|
|
@ -8195,6 +8211,50 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.38.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.0.tgz",
|
||||
"integrity": "sha512-fJGw+HO0YY+fU/F1N57DMO+TmXHTrmr905J05zwAQE9xkuwP/QLDk63rVhmyxh03dYnEhnRbsdbH9B0UVVRB3A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"playwright-core": "1.38.0"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "2.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.38.0",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.0.tgz",
|
||||
"integrity": "sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"playwright-core": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright/node_modules/fsevents": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.4.29",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz",
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@
|
|||
},
|
||||
"proxy": "http://127.0.0.1:7860",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.38.0",
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/core": "^1.3.80",
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
|
|
|
|||
77
src/frontend/playwright.config.ts
Normal file
77
src/frontend/playwright.config.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import { defineConfig, devices } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// require('dotenv').config();
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: "./tests",
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: "html",
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
// baseURL: 'http://127.0.0.1:3000',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: "on-first-retry",
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: "chromium",
|
||||
use: { ...devices["Desktop Chrome"] },
|
||||
},
|
||||
|
||||
{
|
||||
name: "firefox",
|
||||
use: { ...devices["Desktop Firefox"] },
|
||||
},
|
||||
|
||||
{
|
||||
name: "webkit",
|
||||
use: { ...devices["Desktop Safari"] },
|
||||
},
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: { ...devices['Pixel 5'] },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: { ...devices['iPhone 12'] },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
// },
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
// webServer: {
|
||||
// command: 'npm run start',
|
||||
// url: 'http://127.0.0.1:3000',
|
||||
// reuseExistingServer: !process.env.CI,
|
||||
// },
|
||||
});
|
||||
32
src/frontend/tests/auto_login.spec.ts
Normal file
32
src/frontend/tests/auto_login.spec.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Auto_login tests", () => {
|
||||
test("auto_login sign in", async ({ page }) => {
|
||||
await page.routeFromHAR("harFiles/langflow.har", {
|
||||
url: "**/api/v1/**",
|
||||
update: false,
|
||||
});
|
||||
await page.goto("http:localhost:3000/");
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
await page.waitForSelector(".community-pages-flows-panel");
|
||||
expect(
|
||||
await page
|
||||
.locator(".community-pages-flows-panel")
|
||||
.evaluate((el) => el.children)
|
||||
).toBeTruthy();
|
||||
});
|
||||
test("auto_login block_admin", async ({ page }) => {
|
||||
await page.routeFromHAR("harFiles/langflow.har", {
|
||||
url: "**/api/v1/**",
|
||||
update: false,
|
||||
});
|
||||
await page.goto("http:localhost:3000/");
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
await page.goto("http:localhost:3000/login");
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
await page.goto("http:localhost:3000/admin");
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
await page.goto("http:localhost:3000/admin/login");
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
});
|
||||
});
|
||||
20
src/frontend/tests/example.spec.ts
Normal file
20
src/frontend/tests/example.spec.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("has title", async ({ page }) => {
|
||||
await page.goto("https://playwright.dev/");
|
||||
|
||||
// Expect a title "to contain" a substring.
|
||||
await expect(page).toHaveTitle(/Playwright/);
|
||||
});
|
||||
|
||||
test("get started link", async ({ page }) => {
|
||||
await page.goto("https://playwright.dev/");
|
||||
|
||||
// Click the get started link.
|
||||
await page.getByRole("link", { name: "Get started" }).click();
|
||||
|
||||
// Expects page to have a heading with the name of Installation.
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Installation" })
|
||||
).toBeVisible();
|
||||
});
|
||||
128
src/frontend/tests/login.spec.ts
Normal file
128
src/frontend/tests/login.spec.ts
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Login Tests", () => {
|
||||
test("Login_Success", async ({ page }) => {
|
||||
await page.route("**/api/v1/login", async (route) => {
|
||||
const json = {
|
||||
access_token:
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhMWNlM2FkOS1iZTE2LTRiNjgtOGRhYi1hYjA4YTVjMmZjZTkiLCJleHAiOjE2OTUyNTIwNTh9.MBYFwMhTcZnsW_L7p4qavUhSDylCllJQWUCJdU1wX8o",
|
||||
refresh_token:
|
||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhMWNlM2FkOS1iZTE2LTRiNjgtOGRhYi1hYjA4YTVjMmZjZTkiLCJ0eXBlIjoicmYiLCJleHAiOjE2OTUyNTI2NTh9.a4wL9-XK_zyTyrXduBFgCsODFXrqiByVr5HOeiCbiQA",
|
||||
token_type: "bearer",
|
||||
};
|
||||
await route.fulfill({ json });
|
||||
});
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill("test");
|
||||
await page.getByPlaceholder("Password").click();
|
||||
await page.getByPlaceholder("Password").fill("test");
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
await page.getByRole("button", { name: "Community Examples" }).click();
|
||||
await page.waitForSelector(".community-pages-flows-panel");
|
||||
expect(
|
||||
await page
|
||||
.locator(".community-pages-flows-panel")
|
||||
.evaluate((el) => el.children)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("Login Error", async ({ page }) => {
|
||||
await page.route("**/api/v1/login", async (route) => {
|
||||
const json = { detail: "Incorrect username or password" };
|
||||
await route.fulfill({ json, status: 401 });
|
||||
});
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill("test");
|
||||
await page.getByPlaceholder("Password").click();
|
||||
await page.getByPlaceholder("Password").fill("test5");
|
||||
await page.getByRole("button", { name: "Sign in" }).click();
|
||||
await page.getByRole("heading", { name: "Error signing in" }).click();
|
||||
});
|
||||
|
||||
test("Login create account wrong form", async ({ page }) => {
|
||||
const fullfillForm = async (username, password, confirmPassword) => {
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill(username);
|
||||
await page.getByPlaceholder("Password", { exact: true }).click();
|
||||
await page.getByPlaceholder("Password", { exact: true }).fill(password);
|
||||
await page.getByPlaceholder("Confirm your password").click();
|
||||
await page
|
||||
.getByPlaceholder("Confirm your password")
|
||||
.fill(confirmPassword);
|
||||
};
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page
|
||||
.getByRole("button", { name: "Don't have an account? Sign Up" })
|
||||
.click();
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await page.goto("http://localhost:3000/signup");
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
|
||||
await fullfillForm("name", "vazz", "vazz5");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("", "vazz", "vazz");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("name", "", "");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
await fullfillForm("", "", "");
|
||||
expect(
|
||||
await page.getByRole("button", { name: "Sign up" }).isDisabled()
|
||||
).toBeTruthy();
|
||||
});
|
||||
test("Login create account success", async ({ page }) => {
|
||||
await page.route("**/api/v1/users/", async (route) => {
|
||||
const json = {
|
||||
id: "e9ac1bdc-429b-475d-ac03-d26f9a2a3210",
|
||||
username: "teste",
|
||||
profile_image: null,
|
||||
is_active: false,
|
||||
is_superuser: false,
|
||||
create_at: "2023-09-21T01:45:51.873303",
|
||||
updated_at: "2023-09-21T01:45:51.873305",
|
||||
last_login_at: null,
|
||||
};
|
||||
await route.fulfill({ json, status: 201 });
|
||||
});
|
||||
const submitForm = async (username, password, confirmPassword) => {
|
||||
await page.getByPlaceholder("Username").click();
|
||||
await page.getByPlaceholder("Username").fill(username);
|
||||
await page.getByPlaceholder("Password", { exact: true }).click();
|
||||
await page.getByPlaceholder("Password", { exact: true }).fill(password);
|
||||
await page.getByPlaceholder("Confirm your password").click();
|
||||
await page
|
||||
.getByPlaceholder("Confirm your password")
|
||||
.fill(confirmPassword);
|
||||
};
|
||||
|
||||
await page.goto("http://localhost:3000/");
|
||||
await page.waitForURL("http://localhost:3000/login");
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 100 });
|
||||
await page
|
||||
.getByRole("button", { name: "Don't have an account? Sign Up" })
|
||||
.click();
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await page.goto("http://localhost:3000/signup");
|
||||
await page.getByText("Sign up to Langflow").click();
|
||||
await submitForm("teste", "pass", "pass");
|
||||
await page.getByRole("button", { name: "Sign up" }).click();
|
||||
await page.waitForURL("http://localhost:3000/login", { timeout: 1000 });
|
||||
await page.getByText("Account created! Await admin activation.").click();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue