mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-17 02:38:29 +00:00
feat: add initial playwright/test setup and tests
This commit is contained in:
parent
16397aed89
commit
0a7773bd61
26
.github/workflows/test.yml
vendored
Normal file
26
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Install deps
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CI: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v3
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Run root tests
|
||||
run: npm run test:playwright
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -24,3 +24,7 @@ docker-compose.yml
|
||||
|
||||
# cookie file
|
||||
cookies.json
|
||||
|
||||
# playwright results
|
||||
test-results
|
||||
playwright-report
|
||||
|
@ -12,6 +12,7 @@
|
||||
"start": "node src/cobalt",
|
||||
"setup": "node src/modules/setup",
|
||||
"test": "node src/test/test",
|
||||
"test:playwright": "npx playwright test",
|
||||
"build": "node src/modules/buildStatic",
|
||||
"testFilenames": "node src/test/testFilenamePresets"
|
||||
},
|
||||
@ -40,5 +41,8 @@
|
||||
"undici": "^5.19.1",
|
||||
"url-pattern": "1.0.3",
|
||||
"youtubei.js": "^6.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.40.1"
|
||||
}
|
||||
}
|
||||
|
29
playwright.config.js
Normal file
29
playwright.config.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
fullyParallel: true,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: 'list',
|
||||
testMatch: 'src/testPlaywright/**/*.spec.js',
|
||||
use: {
|
||||
// Base URL to use in actions like `await page.goto('/')`.
|
||||
baseURL: 'http://127.0.0.1:9001',
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
],
|
||||
webServer: [{
|
||||
// Web
|
||||
command: 'webURL=http://localhost:9001 apiURL=http://localhost:9000 node src/cobalt.js',
|
||||
url: 'http://127.0.0.1:9001',
|
||||
}, {
|
||||
// API
|
||||
command: 'apiURL=http://localhost:9000 node src/cobalt.js',
|
||||
url: 'http://127.0.0.1:9000',
|
||||
}]
|
||||
});
|
15
src/testPlaywright/start.spec.js
Normal file
15
src/testPlaywright/start.spec.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('initial setup', () => {
|
||||
test('web app is up', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
await expect(page).toHaveTitle(/cobalt/);
|
||||
});
|
||||
test('api is up', async ({ request }) => {
|
||||
const response = await request.get('http://localhost:9000/api/serverInfo')
|
||||
const responseBody = JSON.parse(await response.text())
|
||||
|
||||
expect(responseBody.version).toBeDefined()
|
||||
});
|
||||
})
|
Loading…
Reference in New Issue
Block a user