Skip to content

Commit

Permalink
feat(gha): add end-to-end testing framework
Browse files Browse the repository at this point in the history
This change integrates Playwright Automation tool into the CI process.
  • Loading branch information
arikkfir committed Sep 5, 2023
1 parent c1666a8 commit 164050a
Show file tree
Hide file tree
Showing 10 changed files with 656 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/pr_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,27 @@ jobs:
ghcr.io/${{ github.repository }}/migrations: ${{ needs.get-ref.outputs.sha }}
ghcr.io/${{ github.repository }}/neo4j: ${{ needs.get-ref.outputs.sha }}
secrets: inherit

e2e-tests:
name: End-to-end Tests
needs: deploy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
cache: npm
cache-dependency-path: e2e/package-lock.json
- run: npm ci
working-directory: e2e
- run: npx playwright install --with-deps
working-directory: e2e
- run: npx playwright test
working-directory: e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 30
1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ $ telepresence intercept --namespace=MY-ENV greenstar-frontend --port 8080:http
# If you want to intercept the frontend locally:
$ telepresence intercept --namespace=MY-ENV greenstar-backend --port 8000:http --env-file ./backend/intercept.env
```

### Testing

End-to-end tests are available in the `e2e` directory. To run them use the following:

```shell
$ npx playwright test # Runs the end-to-end tests.
$ npx playwright test --ui # Starts the interactive UI mode.
$ npx playwright test --project=chromium # Runs the tests only on Desktop Chrome.
$ npx playwright test example # Runs the tests in a specific file.
$ npx playwright test --debug # Runs the tests in debug mode.
```

See [this blog post](https://playwright.dev/docs/intro) for more information.

#### TBD

Tests code generation:

```shell
$ npx playwright codegen # Auto generate tests with Codegen.
```
8 changes: 8 additions & 0 deletions e2e.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/e2e" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
4 changes: 4 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
67 changes: 67 additions & 0 deletions e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "greenstar-e2e",
"version": "0.0.0",
"description": "End-to-end tests for Greenstar",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.37.1"
}
}
62 changes: 62 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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',
timeout: 30 * 1000,
expect: {
timeout: 5000
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: 0,
workers: 1,
reporter: process.env.CI ? 'github' : [
['list', {printSteps: true}],
['html', {open: 'never'}],
],
use: {
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
trace: 'on',
},
projects: [
{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 7'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 13'] },
// },
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
],
});
Loading

0 comments on commit 164050a

Please sign in to comment.