Skip to content

Commit bbc83dd

Browse files
authored
Run fake dojo tests on every PR (ag-ui-protocol#252)
* Add scripts for running dojo for e2e * make examples have configurable ports * Add new temp e2e suite * Add github workflow to run on PRs * misc file cleanup * Fix runtime error if no readme * remove unneeded mdx providers to allow build * bump pnpm to 10.13.1 to align with copilotkit repo
1 parent 4e3fcd1 commit bbc83dd

32 files changed

+1000
-11258
lines changed

.github/workflows/dojo-e2e.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: e2e
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
e2e:
11+
name: E2E Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '22'
22+
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: 10.13.1
27+
28+
- name: Install Poetry
29+
uses: snok/install-poetry@v1
30+
with:
31+
version: latest
32+
virtualenvs-create: true
33+
virtualenvs-in-project: true
34+
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v6
37+
38+
- name: Setup pnpm cache
39+
uses: actions/cache@v4
40+
with:
41+
path: ~/.local/share/pnpm/store
42+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43+
restore-keys: |
44+
${{ runner.os }}-pnpm-store-
45+
46+
- name: Install dependencies
47+
working-directory: typescript-sdk
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Prepare dojo for e2e
51+
working-directory: typescript-sdk/apps/dojo
52+
run: node ./scripts/prep-dojo-everything.js -e2e
53+
54+
- name: Install e2e dependencies
55+
working-directory: typescript-sdk/apps/dojo/e2e2
56+
run: |
57+
pnpm install --frozen-lockfile
58+
pnpm dlx playwright install --with-deps
59+
60+
- name: write langgraph env files
61+
working-directory: typescript-sdk/integrations/langgraph
62+
env:
63+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
64+
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
65+
run: |
66+
echo "OPENAI_API_KEY=${OPENAI_API_KEY}" > examples/python/.env
67+
echo "LANGSMITH_API_KEY=${LANGSMITH_API_KEY}" >> examples/python/.env
68+
echo "OPENAI_API_KEY=${OPENAI_API_KEY}" > examples/typescript/.env
69+
echo "LANGSMITH_API_KEY=${LANGSMITH_API_KEY}" >> examples/typescript/.env
70+
echo "OPENAI_API_KEY=${OPENAI_API_KEY}" > python/ag_ui_langgraph/.env
71+
echo "LANGSMITH_API_KEY=${LANGSMITH_API_KEY}" >> python/ag_ui_langgraph/.env
72+
73+
- name: Run dojo+agents and tests
74+
working-directory: typescript-sdk/apps/dojo/e2e2
75+
env:
76+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
77+
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
78+
run: |
79+
node ../scripts/run-dojo-everything.js &
80+
npx wait-port 9999
81+
sleep 10
82+
pnpm exec playwright test --reporter=dot
83+
84+
- name: Upload traces
85+
if: always() # Uploads artifacts even if tests fail
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: playwright-traces
89+
path: typescript-sdk/apps/dojo/e2e2/test-results/
90+
retention-days: 7

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Install pnpm
7070
uses: pnpm/action-setup@v4
7171
with:
72-
version: 9.0.0
72+
version: 10.13.1
7373

7474
- name: Setup pnpm cache
7575
uses: actions/cache@v4
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
# Playwright
3+
node_modules/
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "e2e2",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {},
7+
"keywords": [],
8+
"author": "",
9+
"license": "ISC",
10+
"devDependencies": {
11+
"@playwright/test": "^1.54.2",
12+
"@types/node": "^24.1.0"
13+
}
14+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
testDir: './tests',
16+
/* Run tests in files in parallel */
17+
fullyParallel: true,
18+
/* Fail the build on CI if you accidentally left test.only in the source code. */
19+
forbidOnly: !!process.env.CI,
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
/* Opt out of parallel tests on CI. */
23+
workers: process.env.CI ? 1 : undefined,
24+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25+
reporter: 'html',
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
use: {
28+
/* Base URL to use in actions like `await page.goto('/')`. */
29+
// baseURL: 'http://localhost:3000',
30+
31+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32+
trace: 'on-first-retry',
33+
},
34+
35+
/* Configure projects for major browsers */
36+
projects: [
37+
{
38+
name: 'chromium',
39+
use: { ...devices['Desktop Chrome'] },
40+
},
41+
42+
{
43+
name: 'firefox',
44+
use: { ...devices['Desktop Firefox'] },
45+
},
46+
47+
{
48+
name: 'webkit',
49+
use: { ...devices['Desktop Safari'] },
50+
},
51+
52+
/* Test against mobile viewports. */
53+
// {
54+
// name: 'Mobile Chrome',
55+
// use: { ...devices['Pixel 5'] },
56+
// },
57+
// {
58+
// name: 'Mobile Safari',
59+
// use: { ...devices['iPhone 12'] },
60+
// },
61+
62+
/* Test against branded browsers. */
63+
// {
64+
// name: 'Microsoft Edge',
65+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
66+
// },
67+
// {
68+
// name: 'Google Chrome',
69+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
70+
// },
71+
],
72+
73+
/* Run your local dev server before starting the tests */
74+
// webServer: {
75+
// command: 'npm run start',
76+
// url: 'http://localhost:3000',
77+
// reuseExistingServer: !process.env.CI,
78+
// },
79+
});

typescript-sdk/apps/dojo/e2e2/pnpm-lock.yaml

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
packages:
2+
- '.'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('renders initial message', async ({ page }) => {
4+
await page.goto('http://localhost:9999/agno/feature/agentic_chat');
5+
6+
await expect(page.getByText('Hi, I\'m an agent. Want to chat?')).toBeVisible();
7+
});
8+
9+
test('responds to user message', async ({ page }) => {
10+
await page.goto('http://localhost:9999/agno/feature/agentic_chat');
11+
12+
const textarea = page.getByPlaceholder('Type a message...');
13+
textarea.fill('How many sides are in a square? Please answer in one word. Do not use any punctuation, just the number in word form.');
14+
await page.keyboard.press('Enter');
15+
16+
page.locator('.copilotKitInputControls button.copilotKitInputControlButton').click();
17+
18+
await expect(page.locator('.copilotKitMessage')).toHaveCount(3);
19+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage')).toHaveCount(2);
20+
await expect(page.locator('.copilotKitMessage.copilotKitUserMessage')).toHaveCount(1);
21+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage').last()).toHaveText('four', { ignoreCase: true });
22+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('renders initial message', async ({ page }) => {
4+
await page.goto('http://localhost:9999/crewai/feature/agentic_chat');
5+
6+
await expect(page.getByText('Hi, I\'m an agent. Want to chat?')).toBeVisible();
7+
});
8+
9+
test('responds to user message', async ({ page }) => {
10+
await page.goto('http://localhost:9999/crewai/feature/agentic_chat');
11+
12+
const textarea = page.getByPlaceholder('Type a message...');
13+
textarea.fill('How many sides are in a square? Please answer in one word. Do not use any punctuation, just the number in word form.');
14+
await page.keyboard.press('Enter');
15+
16+
page.locator('.copilotKitInputControls button.copilotKitInputControlButton').click();
17+
18+
await expect(page.locator('.copilotKitMessage')).toHaveCount(3);
19+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage')).toHaveCount(2);
20+
await expect(page.locator('.copilotKitMessage.copilotKitUserMessage')).toHaveCount(1);
21+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage').last()).toHaveText('four', { ignoreCase: true });
22+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('renders initial message', async ({ page }) => {
4+
await page.goto('http://localhost:9999/langgraph/feature/agentic_chat');
5+
6+
await expect(page.getByText('Hi, I\'m an agent. Want to chat?')).toBeVisible();
7+
});
8+
9+
test('responds to user message', async ({ page }) => {
10+
await page.goto('http://localhost:9999/langgraph/feature/agentic_chat');
11+
12+
const textarea = page.getByPlaceholder('Type a message...');
13+
textarea.fill('How many sides are in a square? Please answer in one word. Do not use any punctuation, just the number in word form.');
14+
await page.keyboard.press('Enter');
15+
16+
page.locator('.copilotKitInputControls button.copilotKitInputControlButton').click();
17+
18+
await expect(page.locator('.copilotKitMessage')).toHaveCount(3);
19+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage')).toHaveCount(2);
20+
await expect(page.locator('.copilotKitMessage.copilotKitUserMessage')).toHaveCount(1);
21+
await expect(page.locator('.copilotKitMessage.copilotKitAssistantMessage').last()).toHaveText('four', { ignoreCase: true });
22+
});

0 commit comments

Comments
 (0)