-
Notifications
You must be signed in to change notification settings - Fork 311
chore: Add playwright tests for app in local-only mode #1181
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
Changes from all commits
ea5b57c
09d08cb
1065378
14a208b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,33 +98,111 @@ jobs: | |
if: steps.changed-files.outputs.any_changed == 'true' | ||
working-directory: ./smoke-tests/otel-collector | ||
run: bats . | ||
app-smoke-test: | ||
name: HyperDX App Smoke Test | ||
runs-on: ubuntu-latest | ||
e2e-tests: | ||
name: End-to-End Tests | ||
runs-on: ubuntu-24.04 | ||
timeout-minutes: 15 | ||
container: | ||
image: mcr.microsoft.com/playwright:v1.55.0-jammy | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
- name: Waiting for vercel preview to be ready | ||
uses: patrickedqvist/[email protected] | ||
id: waitFor200 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache-dependency-path: 'yarn.lock' | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Build dependencies | ||
run: npx nx run-many -t ci:build | ||
|
||
- name: Run Playwright tests | ||
run: | | ||
cd packages/app | ||
yarn test:e2e | ||
|
||
- name: Upload Playwright report | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
max_timeout: 1200 | ||
check_interval: 10 | ||
- run: echo ${{steps.waitFor200.outputs.url}} | ||
name: playwright-report | ||
path: packages/app/playwright-report/ | ||
retention-days: 30 | ||
|
||
- name: Stably Runner Action | ||
uses: stablyhq/stably-runner-action@v3 | ||
- name: Upload test results | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
test-suite-id: cmc548u5u0001la04q7y8ddj2 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
api-key: ${{ secrets.STABLY_API_KEY }} | ||
environment: PRODUCTION | ||
variable-overrides: | | ||
{ | ||
"SITE_URL": "${{ steps.waitFor200.outputs.url }}" | ||
name: test-results | ||
path: packages/app/test-results/ | ||
retention-days: 30 | ||
|
||
- name: Generate test results message | ||
id: test-results | ||
if: always() && github.event_name == 'pull_request' | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
try { | ||
const resultsPath = path.join('packages/app/test-results/results.json'); | ||
if (fs.existsSync(resultsPath)) { | ||
const results = JSON.parse(fs.readFileSync(resultsPath, 'utf8')); | ||
const { stats } = results; | ||
|
||
const failed = stats.unexpected || 0; | ||
const passed = stats.expected || 0; | ||
const flaky = stats.flaky || 0; | ||
const skipped = stats.skipped || 0; | ||
const duration = Math.round((stats.duration || 0) / 1000); | ||
|
||
const summary = failed > 0 | ||
? `❌ **${failed} test${failed > 1 ? 's' : ''} failed**` | ||
: `✅ **All tests passed**`; | ||
|
||
return `## E2E Test Results | ||
|
||
${summary} • ${passed} passed • ${skipped} skipped • ${duration}s | ||
|
||
| Status | Count | | ||
|--------|-------| | ||
| ✅ Passed | ${passed} | | ||
| ❌ Failed | ${failed} | | ||
| ⚠️ Flaky | ${flaky} | | ||
| ⏭️ Skipped | ${skipped} | | ||
|
||
[View full report →](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})`; | ||
} else { | ||
return `## E2E Test Results | ||
|
||
❌ **Test results file not found** | ||
|
||
[View full report →](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})`; | ||
} | ||
} catch (error) { | ||
console.log('Could not parse test results:', error.message); | ||
return `## E2E Test Results | ||
|
||
❌ **Error reading test results** | ||
|
||
[View full report →](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})`; | ||
} | ||
|
||
- name: Comment PR with test results | ||
uses: mshick/add-pr-comment@v2 | ||
if: always() && github.event_name == 'pull_request' | ||
with: | ||
message: ${{ steps.test-results.outputs.result }} | ||
message-id: e2e-test-results |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,8 @@ | |
"packageManager": "[email protected]", | ||
"resolutions": { | ||
"@types/react": "18.3.1", | ||
"@types/react-dom": "18.3.1" | ||
"@types/react-dom": "18.3.1", | ||
"@types/express": "4.17.21", | ||
"@types/express-serve-static-core": "4.17.43" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* @see https://playwright.dev/docs/test-configuration | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests/e2e', | ||
/* Global setup to ensure server is ready */ | ||
globalSetup: require.resolve('./global-setup.js'), | ||
/* 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 : 1, | ||
/* Use multiple workers on CI for faster execution */ | ||
workers: undefined, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. allows playwright to use as many cores that are available |
||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: [ | ||
['html'], | ||
['json', { outputFile: 'test-results/results.json' }], | ||
...(process.env.CI ? [['github', {}] as const] : []), | ||
], | ||
/* 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: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:8080', | ||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
/* Take screenshot on failure */ | ||
screenshot: 'only-on-failure', | ||
/* Record video on failure */ | ||
video: 'retain-on-failure', | ||
}, | ||
|
||
/* Global test timeout - increased from default 30s to 60s to reduce flaky test failures */ | ||
timeout: 60 * 1000, | ||
|
||
/* Configure projects for different test environments */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can add more browsers later |
||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: | ||
'NEXT_PUBLIC_IS_LOCAL_MODE=true NEXT_TELEMETRY_DISABLED=1 yarn run dev', | ||
port: 8080, | ||
reuseExistingServer: !process.env.CI, | ||
timeout: 180 * 1000, | ||
stdout: 'pipe', | ||
stderr: 'pipe', | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. run server in local-only mode for simplicty |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linting failure fix