Include frontend tests, update readme, fix bugs #163
@ -9,7 +9,28 @@ env:
|
|||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test-frontend:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Install Playwright Browsers
|
||||||
|
run: npx playwright install --with-deps
|
||||||
|
- name: Run Playwright tests
|
||||||
|
run: npx playwright test
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: playwright-report
|
||||||
|
path: playwright-report/
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
test-backend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: rust:latest
|
||||||
|
|
||||||
@ -35,7 +56,7 @@ jobs:
|
|||||||
deploy-staging:
|
deploy-staging:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: rust:latest
|
||||||
needs: [test]
|
needs: [test_frontend, test_backend]
|
||||||
if: github.ref == 'refs/heads/staging'
|
if: github.ref == 'refs/heads/staging'
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environment
|
- name: Setup Environment
|
||||||
@ -95,7 +116,7 @@ jobs:
|
|||||||
deploy-main:
|
deploy-main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: rust:latest
|
||||||
needs: [test]
|
needs: [test_frontend, test_backend]
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environment
|
- name: Setup Environment
|
||||||
|
5
frontend/.gitignore
vendored
5
frontend/.gitignore
vendored
@ -1 +1,6 @@
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
|
node_modules/
|
||||||
|
/test-results/
|
||||||
|
/playwright-report/
|
||||||
|
/blob-report/
|
||||||
|
/playwright/.cache/
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@playwright/test": "^1.40.1",
|
||||||
"@types/d3": "^7.4.1",
|
"@types/d3": "^7.4.1",
|
||||||
|
"@types/node": "^20.11.4",
|
||||||
"autoprefixer": "^10.4.14",
|
"autoprefixer": "^10.4.14",
|
||||||
"postcss": "^8.4.21",
|
"postcss": "^8.4.21",
|
||||||
"sass": "^1.60.0",
|
"sass": "^1.60.0",
|
||||||
|
75
frontend/playwright.config.ts
Normal file
75
frontend/playwright.config.ts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read environment variables from file.
|
||||||
|
* https://github.com/motdotla/dotenv
|
||||||
|
*/
|
||||||
|
// require('dotenv').config();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './tests',
|
||||||
|
/* 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 : 0,
|
||||||
|
/* Opt out of parallel tests on CI. */
|
||||||
|
workers: process.env.CI ? 1 : undefined,
|
||||||
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
|
reporter: 'html',
|
||||||
|
/* 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: 'http://127.0.0.1:3000',
|
||||||
|
|
||||||
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configure projects for major browsers */
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'firefox',
|
||||||
|
use: { ...devices['Desktop Firefox'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
//{
|
||||||
|
// name: 'webkit',
|
||||||
|
// use: { ...devices['Desktop Safari'] },
|
||||||
|
//},
|
||||||
|
|
||||||
|
/* Test against mobile viewports. */
|
||||||
|
{
|
||||||
|
name: 'Mobile Chrome',
|
||||||
|
use: { ...devices['Pixel 5'] },
|
||||||
|
},
|
||||||
|
//{
|
||||||
|
// name: 'Mobile Safari',
|
||||||
|
// use: { ...devices['iPhone 12'] },
|
||||||
|
//},
|
||||||
|
|
||||||
|
/* Test against branded browsers. */
|
||||||
|
//{
|
||||||
|
// name: 'Microsoft Edge',
|
||||||
|
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||||
|
//},
|
||||||
|
//{
|
||||||
|
// name: 'Google Chrome',
|
||||||
|
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||||
|
//},
|
||||||
|
],
|
||||||
|
|
||||||
|
/* Run your local dev server before starting the tests */
|
||||||
|
webServer: {
|
||||||
|
command: 'cd .. && ./test_db.sh && cargo r',
|
||||||
|
},
|
||||||
|
});
|
22
frontend/tests/example.spec.ts
Normal file
22
frontend/tests/example.spec.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('cox can create trip', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:8000/auth');
|
||||||
|
await page.getByPlaceholder('Name').click();
|
||||||
|
await page.getByPlaceholder('Name').fill('cox');
|
||||||
|
await page.getByPlaceholder('Name').press('Tab');
|
||||||
|
await page.getByPlaceholder('Passwort').fill('cox');
|
||||||
|
await page.getByRole('button', { name: 'Einloggen' }).click();
|
||||||
|
await expect(page.locator('body')).toContainText('Login erfolgreich');
|
||||||
|
await page.locator('li').filter({ hasText: 'Geplante Ausfahrten' }).click();
|
||||||
|
await page.getByRole('link', { name: 'Geplante Ausfahrten' }).click();
|
||||||
|
await page.locator('.relative').first().click();
|
||||||
|
await page.locator('#sidebar #planned_starting_time').click();
|
||||||
|
await page.locator('#sidebar #planned_starting_time').press('ArrowLeft');
|
||||||
|
await page.locator('#sidebar #planned_starting_time').press('Tab');
|
||||||
|
await page.locator('#sidebar #planned_starting_time').fill('14:00');
|
||||||
|
await page.locator('#sidebar #planned_starting_time').press('Tab');
|
||||||
|
await page.getByRole('spinbutton').fill('4');
|
||||||
|
await page.getByRole('button', { name: 'Erstellen', exact: true }).click();
|
||||||
|
await expect(page.locator('body')).toContainText('Ausfahrt erfolgreich erstellt.');
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user