Skip to content

Commit

Permalink
Merge pull request #28 from ImpactMarkets/cert-create-e2e
Browse files Browse the repository at this point in the history
Create first e2e tests for cert creation
  • Loading branch information
Telofy committed Dec 4, 2022
2 parents a242b5b + d5709f2 commit 3a9a1c6
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 126 deletions.
26 changes: 5 additions & 21 deletions .env.example
@@ -1,36 +1,20 @@
# 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=

NEXTAUTH_URL=http://localhost:3000
NEXT_APP_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=
# https://next-auth.js.org/configuration/options#nextauth_url
NEXTAUTH_SECRET=foobar
NEXTAUTH_URL=${NEXT_APP_URL}

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=false
DEBUG=true
34 changes: 8 additions & 26 deletions .env.test
@@ -1,38 +1,20 @@
# 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
DATABASE_URL=postgresql://im-app:empty@127.0.0.1:54322/im-app-test

NEXT_APP_URL=
NEXT_APP_URL=http://localhost:3001

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=
# https://next-auth.js.org/configuration/options#nextauth_url
NEXTAUTH_SECRET=foobar
NEXTAUTH_URL=${NEXT_APP_URL}

ENABLE_SLACK_POSTING=
SLACK_WEBHOOK_URL=

NEXT_PUBLIC_INTERCOM_APP_ID=gbn0p3de

ROLLBAR_SERVER_TOKEN=
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN=
MOCK_LOGIN=true

DEBUG=false
NODE_ENV=test

MOCK_LOGIN=true
PORT=3001
8 changes: 2 additions & 6 deletions .github/workflows/node.js.yml
Expand Up @@ -5,9 +5,7 @@ name: Tests, style checks, and type checks

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

jobs:
test-unit:
Expand Down Expand Up @@ -63,12 +61,10 @@ jobs:
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
run: npx dotenv -e .env.test -- npx prisma migrate deploy
- name: Run Playwright tests
run: npm run test:e2e
- uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -31,6 +31,7 @@ yarn-error.log*
.env.development.local
.env.test.local
.env.production.local
.env.backup

# vercel
.vercel
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.test.yaml
@@ -1,7 +1,7 @@
version: '3.5'

services:
postgres:
postgres-test:
image: 'postgres:14-alpine'
volumes:
- postgres-data:/var/lib/postgresql/data/
Expand All @@ -10,6 +10,12 @@ services:
- POSTGRES_PASSWORD=empty
ports:
- '127.0.0.1:54322:5432'
networks:
- test

networks:
test:
name: test

volumes:
postgres-data:
2 changes: 1 addition & 1 deletion env/browser.ts
Expand Up @@ -14,6 +14,6 @@ export const browserEnv = envsafe({
NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN: str({
input: process.env.NEXT_PUBLIC_ROLLBAR_CLIENT_TOKEN,
allowEmpty: false,
devDefault: process.env.NODE_ENV,
devDefault: 'foobar',
}),
})
4 changes: 2 additions & 2 deletions env/server.ts
Expand Up @@ -59,7 +59,7 @@ export const serverEnv = {
devDefault: 'http://localhost:3000',
}),
NEXTAUTH_SECRET: str({
devDefault: 'xxx',
devDefault: 'foobar',
}),
DEBUG: bool({ default: false }),
MOCK_LOGIN: bool({ default: false }),
Expand All @@ -78,7 +78,7 @@ export const serverEnv = {
SLACK_WEBHOOK_URL: slackParser({ allowEmpty: true, default: '' }),
ROLLBAR_SERVER_TOKEN: rollbarParser({
allowEmpty: false,
devDefault: process.env.NODE_ENV,
devDefault: 'foobar',
}),
}),
}
2 changes: 1 addition & 1 deletion lib/auth.ts
Expand Up @@ -53,7 +53,7 @@ if (serverEnv.MOCK_LOGIN) {
authOptions.callbacks!.jwt = async ({ token }) => {
const email = 'mock.user@example.com'
const name = 'Mock User'
const image = 'http://localhost:3000/images/logo-min-light.png'
const image = serverEnv.NEXT_APP_URL + '/images/logo-min-light.png'
const role = Role.USER
const user = await prisma.user.upsert({
select: { id: true, name: true, role: true, image: true, email: true },
Expand Down

0 comments on commit 3a9a1c6

Please sign in to comment.