Skip to content

Commit

Permalink
Merge pull request #25 from irby/irby/refactoring
Browse files Browse the repository at this point in the history
Irby/refactoring
  • Loading branch information
irby committed Jul 5, 2023
2 parents 3032f7e + 68ec360 commit 768c8e8
Show file tree
Hide file tree
Showing 24 changed files with 870 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pr-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
paths:
- 'src/api/**'
- '.github/workflows/pr-api.yml'

jobs:
api-test:
Expand Down Expand Up @@ -39,3 +40,7 @@ jobs:
- name: Run tests
working-directory: ./src/api
run: dotnet test --verbosity normal
- name: Stop Docker containers
if: always()
working-directory: .
run: docker-compose --project-directory . -f env/local/docker-compose.local.yml down
34 changes: 34 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "End-to-end Tests"
on:
pull_request:
paths:
- 'src/api/**'
- 'src/spa/**'
- 'e2e/**'
- '.github/workflows/pr-e2e.yml'

jobs:
e2e-test:
name: Test E2E
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.10.0']

steps:
- uses: actions/checkout@v2
- name: Start Docker containers
working-directory: .
run: docker-compose --project-directory . -f env/local/docker-compose.local.yml -f env/e2e/docker-compose.e2e.yml up -d
- name: Install E2E dependencies
working-directory: ./e2e
run: |
npm install
npx playwright install chromium
- run: npx playwright test
name: Run E2E Tests
working-directory: ./e2e
- name: Stop Docker containers
if: always()
working-directory: .
run: docker-compose --project-directory . -f env/local/docker-compose.local.yml -f env/e2e/docker-compose.e2e.yml down
1 change: 1 addition & 0 deletions .github/workflows/pr-spa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
paths:
- 'src/spa/**'
- '.github/workflows/pr-spa.yml'

jobs:
spa-test:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Backend Tests](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-api.yml/badge.svg)](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-api.yml) [![Frontend Tests](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-spa.yml/badge.svg)](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-spa.yml)
[![Backend Tests](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-api.yml/badge.svg)](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-api.yml) [![Frontend Tests](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-spa.yml/badge.svg)](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-spa.yml) [![End-to-end Tests](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-e2e.yml/badge.svg)](https://github.com/irby/secrets-sharing-tool/actions/workflows/pr-e2e.yml)

# Kronocrypt

Expand Down
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/
1 change: 1 addition & 0 deletions e2e/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.10.0
30 changes: 30 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# End-to-end tests with Playwright

Run `npm install` to install the necessary components. Use the Node version referenced in `.nvmrc`.

## Prerequisites

- Must have the API and Database Docker containers running
- Must be running the SPA on port `4200`.

## Running end-to-end tests

To run an end-to-end test with Playwright, use the following command:

```bash
npx playwright test
```

If you want to run a trace on the tests (see screenshots of activity), run the following command:

```bash
npx playwright test --trace on
```

## Viewing reports

When a test fails, an HTML report will automatically open in your default browser. If all tests pass, you can view the HTML report using the following command:

```bash
npx playwright show-report
```
3 changes: 3 additions & 0 deletions e2e/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
frontendUrl: "localhost:4200"
};
99 changes: 99 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": "e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.35.1"
}
}
77 changes: 77 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
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: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Loading

0 comments on commit 768c8e8

Please sign in to comment.