-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Puppeteer test setup and configuration
GitHub Actions Workflow: Added a GitHub Actions workflow file (.github/workflows/puppeteer-tests.yml) for running Puppeteer tests on push and pull request events to the main branch. Puppeteer Test: Created a Puppeteer test script (tests/chat.test.js) to validate the AI's response in the GenAiGraphics chat application. Package Configuration: Added a package.json file to the tests directory with Puppeteer as a development dependency and a test script using Jest.
- Loading branch information
1 parent
e725ea8
commit 77cdf39
Showing
4 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# .github/workflows/puppeteer-tests.yml | ||
|
||
name: Puppeteer Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run Puppeteer tests | ||
run: npm test | ||
env: | ||
DISPLAY: ':99.0' |
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,32 @@ | ||
// tests/chat.test.js | ||
|
||
const puppeteer = require('puppeteer'); | ||
|
||
describe('GenAiGraphics Chat AI', () => { | ||
let browser; | ||
let page; | ||
|
||
beforeAll(async () => { | ||
browser = await puppeteer.launch(); | ||
page = await browser.newPage(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await browser.close(); | ||
}); | ||
|
||
test('AI responds with the correct answer', async () => { | ||
await page.goto('http://localhost:3000/agent'); // Replace with your app's URL | ||
|
||
// Simulate user input | ||
await page.type('#chat-input', 'How do I set up my router?'); // Replace with actual chat input selector | ||
await page.click('#send-button'); // Replace with actual send button selector | ||
|
||
// Wait for the AI response | ||
await page.waitForSelector('#chat-response'); // Replace with actual response selector | ||
|
||
// Verify the response | ||
const response = await page.$eval('#chat-response', el => el.textContent); | ||
expect(response).toContain('To set up your router, first...'); // Replace with expected response | ||
}); | ||
}); |
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,18 @@ | ||
{ | ||
"name": "tests", | ||
"version": "1.0.0", | ||
"description": "testing for genaigraphics", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mollybeach/genaigraphics/tests" | ||
}, | ||
"author": "Molly Beach", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"puppeteer": "^22.14.0" | ||
} | ||
} |