Skip to content

Commit

Permalink
Merge pull request #27 from ImpactMarkets/test-system
Browse files Browse the repository at this point in the history
MVP for automated testing system
  • Loading branch information
Telofy committed Nov 24, 2022
2 parents b032c1a + 44e1e93 commit a242b5b
Show file tree
Hide file tree
Showing 12 changed files with 16,899 additions and 8,713 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Nonstandard port to avoid clashes with other local DB servers
# Nonstandard port to avoid clashes with other local DB servers
DATABASE_URL=postgresql://im-app:empty@127.0.0.1:54321/im-app

NEXT_APP_URL=
Expand Down Expand Up @@ -33,4 +33,4 @@ NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN=

DEBUG=false

MOCK_LOGIN=false
MOCK_LOGIN=false
38 changes: 38 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Nonstandard port to avoid clashes with other local DB servers.
# Also a unique port for testing, so users can run automated tests locally without clashing with
# their local manual testing.
DATABASE_URL=postgresql://im-app:empty@127.0.0.1:54322/im-app

NEXT_APP_URL=

NEXTAUTH_URL=http://localhost:3000

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

GITHUB_ID=
GITHUB_SECRET=
GITHUB_ALLOWED_ORG=

OKTA_CLIENT_ID=
OKTA_CLIENT_SECRET=
OKTA_ISSUER=

NEXTAUTH_SECRET=

NEXT_PUBLIC_ENABLE_IMAGE_UPLOAD=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=

ENABLE_SLACK_POSTING=
SLACK_WEBHOOK_URL=

NEXT_PUBLIC_INTERCOM_APP_ID=gbn0p3de

ROLLBAR_SERVER_TOKEN=
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN=

DEBUG=false

MOCK_LOGIN=true
56 changes: 52 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Style and type checks
name: Tests, style checks, and type checks

on:
push:
branches: ['main', 'beta', 'development']
branches: ['main', 'beta', 'development', 'test-system']
pull_request:
branches: ['main', 'beta', 'development']
branches: ['main', 'beta', 'development', 'test-system']

jobs:
build:
test-unit:
name: Unit tests
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install typescript
- run: npx pretty-quick --staged
- run: npm run test:unit

checks:
name: Style and type checks
runs-on: ubuntu-latest

Expand All @@ -29,3 +49,31 @@ jobs:
- run: npm install typescript
- run: npx prettier --check '**/*.{ts,tsx,json,html,css}'
- run: npx tsc --checkJs

test-e2e:
name: E2E tests
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Set up environment variables for the test env
run: cp .env.test .env
- name: Start the test database
run: docker-compose -f docker-compose.test.yaml up -d
- name: Create the database schema
run: npx prisma migrate deploy
- name: Run Playwright tests
run: npm run test:e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ yarn-error.log*

# typescript
*.tsbuildinfo

# playwright
/test-results/
/playwright-report/
/playwright/.cache/
15 changes: 15 additions & 0 deletions docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.5'

services:
postgres:
image: 'postgres:14-alpine'
volumes:
- postgres-data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=im-app
- POSTGRES_PASSWORD=empty
ports:
- '127.0.0.1:54322:5432'

volumes:
postgres-data:

0 comments on commit a242b5b

Please sign in to comment.