Skip to content

Commit b96a271

Browse files
committed
added playwright tests and configuration for coverage generation, added mcp.json, added github actions for automatic test execution
1 parent 537ae95 commit b96a271

23 files changed

Lines changed: 2244 additions & 11 deletions
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
tools: ['playwright']
3+
mode: 'agent'
4+
---
5+
6+
- You are a playwright test generator.
7+
- explore the given website and generate a playwright test in TypeScript using 'playwright-test-coverage' package
8+
- frontend/test folder contains existing tests. Use them as reference.
9+
- DO NOT generate test code based on the scenario alone.
10+
- DO run steps one by one using the tools provided by the Playwright MCP.
11+
- When asked to explore a website:
12+
1. Navigate to the specified URL
13+
2. Explore all key functionalities of the site and when finished close the browser.
14+
3. Implement a Playwright TypeScript test that uses 'playwright-test-coverage' based on message history using Playwright's best practices including role based locators, auto retrying assertions and with no added timeouts unless necessary as Playwright has built in retries and autowaiting if the correct locators and assertions are used.
15+
- Save generated test file in the tests directory
16+
- Execute the test file and iterate until tests passes
17+
- Include appropriate assertions to verify the expected behavior
18+
- Structure tests properly with descriptive test titles and comments

.github/workflows/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
token.env

.github/workflows/fe_e2e.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: E2E + SonarQube
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
7+
jobs:
8+
run-python-app:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
env:
12+
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
13+
DB_URL: postgresql+asyncpg://admin:admin123@localhost:5432/mydb
14+
REDIS_HOST: localhost
15+
REDIS_PORT: 6379
16+
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
17+
QDRANT_URL: http://localhost:6333
18+
JWT_SECRET_KEY: supersecretkey
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
# Set up Python
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: '3.11'
28+
29+
# Set up Docker Compose (run on root)
30+
- name: Set up Docker Compose
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y docker-compose
34+
35+
# Start containers
36+
- name: Run docker-compose
37+
run: docker-compose -f docker-compose.yml up -d
38+
39+
# Wait for services
40+
- name: Wait for services
41+
run: sleep
42+
43+
# install dependencies
44+
- name: Install dependencies
45+
run: pip install -r requirements.txt
46+
working-directory: backend
47+
48+
# Create Tables
49+
- name: Create DB Tables
50+
run: python tables.py
51+
working-directory: backend/setup_tables
52+
53+
# Run All Services
54+
- name: Run all services
55+
run: |
56+
python backend/ai_analyze_service/app.py &
57+
python backend/auth_service/app.py &
58+
python backend/notes_crud_service/app.py &
59+
wait
60+
61+
62+
test-and-coverage:
63+
timeout-minutes: 60
64+
runs-on: ubuntu-latest
65+
steps:
66+
# 1. Checkout code
67+
- uses: actions/checkout@v4
68+
69+
# 2. Set up Node
70+
- name: Set up Node.js
71+
uses: actions/setup-node@v4
72+
with:
73+
node-version: lts/*
74+
75+
# 3. Install dependencies
76+
- name: Install dependencies
77+
run: npm ci
78+
working-directory: frontend
79+
80+
# 4. Build app (with coverage instrumentation)
81+
- name: Build React app with coverage
82+
run: npm run build
83+
working-directory: frontend
84+
85+
# 5. Start the app in background
86+
- name: Start React app
87+
run: npm run start &
88+
working-directory: frontend
89+
90+
- name: Wait for server
91+
run: npx wait-on http://localhost:5173
92+
working-directory: frontend
93+
94+
# 6. Run Playwright tests
95+
- name: Run Playwright tests
96+
run: npm run test:e2e-coverage
97+
working-directory: frontend
98+
99+
# 7. Upload coverage as artifact (optional)
100+
- name: Upload coverage artifact
101+
uses: actions/upload-artifact@v3
102+
with:
103+
name: coverage
104+
path: coverage/
105+
working-directory: frontend
106+
107+
# 8. SonarQube Analysis
108+
- name: Run SonarQube Scanner
109+
uses: sonarsource/sonarcloud-github-action@v2
110+
with:
111+
projectKey: NavodPeiris_NoteMaker
112+
organization: navodpeiris
113+
token: ${{ secrets.SONAR_TOKEN }}
114+
extraProperties: |
115+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
116+
sonar.sources=src
117+
working-directory: frontend

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
postgres_data
22
qdrant_data
33
redis_data
4-
*.env
4+
deploy.env
5+
local.env
6+
.nyc_output
7+
coverage
8+
sonarqube_data
9+
sonarqube_extensions
10+
sonarqube_logs

.vscode/mcp.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"servers": {
3+
"playwright": {
4+
"command": "npx",
5+
"args": [
6+
"@playwright/mcp@latest"
7+
]
8+
}
9+
}
10+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"postman.settings.dotenv-detection-notification-visibility": false
3+
}

frontend/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
# Playwright
27+
/test-results/
28+
/playwright-report/
29+
/blob-report/
30+
/playwright/.cache/

0 commit comments

Comments
 (0)