Skip to content

Commit

Permalink
Add Puppeteer test setup and configuration
Browse files Browse the repository at this point in the history
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
mollybeach committed Jul 30, 2024
1 parent e725ea8 commit 77cdf39
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
32 changes: 32 additions & 0 deletions .github/workflows/puppeteer-tests.yml
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'
32 changes: 32 additions & 0 deletions tests/chat.tests.js
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
});
});
18 changes: 18 additions & 0 deletions tests/package.json
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"
}
}

0 comments on commit 77cdf39

Please sign in to comment.