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

[wip] feat(builder): scaffold playwright #8109

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
89 changes: 66 additions & 23 deletions .github/workflows/autogpt-builder-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,83 @@ name: AutoGPT Builder CI

on:
push:
branches: [ master ]
branches: [master]
paths:
- '.github/workflows/autogpt-builder-ci.yml'
- 'rnd/autogpt_builder/**'
- ".github/workflows/autogpt-builder-ci.yml"
- "rnd/autogpt_builder/**"
pull_request:
paths:
- '.github/workflows/autogpt-builder-ci.yml'
- 'rnd/autogpt_builder/**'
- ".github/workflows/autogpt-builder-ci.yml"
- "rnd/autogpt_builder/**"

defaults:
run:
shell: bash
working-directory: rnd/autogpt_builder

jobs:

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21'

- name: Install dependencies
run: |
npm install
- name: Check formatting with Prettier
run: |
npx prettier --check .
- name: Run lint
run: |
npm run lint
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"

- name: Install dependencies
run: |
npm install
- name: Check formatting with Prettier
run: |
npx prettier --check .
- name: Run lint
run: |
npm run lint
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"

- name: Copy default supabase .env
run: |
cp ../supabase/docker/.env.example ../.env
- name: Run docker compose
run: |
docker compose -f ../docker-compose.combined.yml up -d
- name: Install dependencies
run: |
npm install
- name: Setup Builder .env
run: |
cp .env.example .env
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run tests
run: |
npm run test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30

5 changes: 5 additions & 0 deletions rnd/autogpt_builder/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ next-env.d.ts

# Sentry Config File
.env.sentry-build-plugin
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
6 changes: 5 additions & 1 deletion rnd/autogpt_builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "prettier --write ."
"format": "prettier --write .",
"test": "playwright test",
"test-ui": "playwright test --ui",
"gentests": "playwright codegen http://localhost:3000"
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
Expand Down Expand Up @@ -57,6 +60,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@playwright/test": "^1.47.1",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
81 changes: 81 additions & 0 deletions rnd/autogpt_builder/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./src/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://localhost:3000/",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
bypassCSP: true,
},

/* 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 build && npm run start",
url: "http://localhost:3000/",
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});
14 changes: 7 additions & 7 deletions rnd/autogpt_builder/sentry.client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Sentry.init({
/^https:\/\/dev\-builder\.agpt\.co\/api/,
],

beforeSend(event, hint) {
// Check if it is an exception, and if so, show the report dialog
if (event.exception && event.event_id) {
Sentry.showReportDialog({ eventId: event.event_id });
}
return event;
},
// beforeSend(event, hint) {
// // Check if it is an exception, and if so, show the report dialog
// if (event.exception && event.event_id) {
// Sentry.showReportDialog({ eventId: event.event_id });
// }
// return event;
// },

// Define how likely Replay events are sampled.
// This sets the sample rate to be 10%. You may want this to be 100% while
Expand Down
28 changes: 28 additions & 0 deletions rnd/autogpt_builder/src/tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { test, expect } from "@playwright/test";

// 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();
// });

// import { test, expect } from "@playwright/test";

test("test", async ({ page }) => {
await page.goto("http://localhost:3000/");
await page.getByRole("link", { name: "Log In" }).click();
await page.getByPlaceholder("[email protected]").click();
await page.getByPlaceholder("[email protected]").fill("[email protected]");
await page.getByPlaceholder("[email protected]").press("Tab");
await page.getByPlaceholder("password").fill("459034902904923904293");
await page.getByLabel("I agree to the Terms of").click();
await page.getByRole("button", { name: "Sign up" }).click();

await expect(page.getByText("[email protected]")).toBeVisible();
});
8 changes: 8 additions & 0 deletions rnd/autogpt_builder/src/tests/title.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from "@playwright/test";

test("has title", async ({ page }) => {
await page.goto("/");

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/NextGen AutoGPT/);
});
26 changes: 26 additions & 0 deletions rnd/autogpt_builder/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,13 @@
resolved "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@playwright/test@^1.47.1":
version "1.47.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.47.1.tgz#568a46229a5aef54b74977297a7946bb5ac4b67b"
integrity sha512-dbWpcNQZ5nj16m+A5UNScYx7HX5trIy7g4phrcitn+Nk83S32EBX/CLU4hiF4RGKX/yRc93AAqtfaXB7JWBd4Q==
dependencies:
playwright "1.47.1"

"@prisma/[email protected]":
version "5.19.1"
resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-5.19.1.tgz#146319cf85f22b7a43296f0f40cfeac55516e66e"
Expand Down Expand Up @@ -3173,6 +3180,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

[email protected]:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

fsevents@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
Expand Down Expand Up @@ -4604,6 +4616,20 @@ pirates@^4.0.1:
resolved "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz"
integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==

[email protected]:
version "1.47.1"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.47.1.tgz#bb45bdfb0d48412c535501aa3805867282857df8"
integrity sha512-i1iyJdLftqtt51mEk6AhYFaAJCDx0xQ/O5NU8EKaWFgMjItPVma542Nh/Aq8aLCjIJSzjaiEQGW/nyqLkGF1OQ==

[email protected]:
version "1.47.1"
resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.47.1.tgz#cdc1116f5265b8d2ff7be0d8942d49900634dc6c"
integrity sha512-SUEKi6947IqYbKxRiqnbUobVZY4bF1uu+ZnZNJX9DfU1tlf2UhWfvVjLf01pQx9URsOr18bFVUKXmanYWhbfkw==
dependencies:
playwright-core "1.47.1"
optionalDependencies:
fsevents "2.3.2"

possible-typed-array-names@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz"
Expand Down
Loading