Skip to content

Commit

Permalink
fix: test env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Mar 13, 2024
1 parent 6e4d1f6 commit 2727131
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ VITE_PROJECT_ID="54..."
VITE_VAPID_KEY="BdV...."
VITE_SENTRY_DSN="https://96..."
VITE_MIXPANEL_TOKEN="8dj...."
TEST_DAPP_PROJECT_ID=""
TEST_DAPP_PROJECT_SECRET=""
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"workbox-core": "^6.5.4",
"workbox-precaching": "^6.5.4",
"workbox-routing": "^6.5.4",
"workbox-window": "^6.5.4"
"workbox-window": "^6.5.4",
"dotenv": "16.3.1"
}
}
2 changes: 2 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { config } from 'dotenv'
import { defineConfig, devices } from '@playwright/test'
config({ path: './.env' })

const baseURL = 'http://localhost:5173'

Expand Down
14 changes: 11 additions & 3 deletions tests/shared/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ export const DEFAULT_SESSION_PARAMS: SessionParams = {
accept: true
}

function getRequiredEnvVar(name: string): string {
const value = process.env[name]
if (!value) {
throw new Error(`Missing required environment variable: ${name}`)
}
return value
}

export const CUSTOM_TEST_DAPP = {
description: 'Test description',
icons: ['https://i.imgur.com/q9QDRXc.png'],
name: 'Notify Swift Integration Tests Prod',
appDomain: 'wc-notify-swift-integration-tests-prod.pages.dev',
projectSecret: process.env['TEST_DAPP_PROJECT_SECRET'],
projectId: process.env['TEST_DAPP_PROJECT_ID'],
messageType: 'f173f231-a45c-4dc0-aa5d-956eb04f7360'
projectSecret: getRequiredEnvVar('TEST_DAPP_PROJECT_SECRET'),
projectId: getRequiredEnvVar('TEST_DAPP_PROJECT_ID'),
notificationType: 'f173f231-a45c-4dc0-aa5d-956eb04f7360'
} as const
2 changes: 1 addition & 1 deletion tests/subscribe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ test('it should subscribe, receive messages and unsubscribe', async ({
accounts: [`eip155:1:${address}`],
body: 'Test Body',
title: 'Test Title',
type: CUSTOM_TEST_DAPP.messageType,
type: CUSTOM_TEST_DAPP.notificationType,
url: CUSTOM_TEST_DAPP.appDomain,
icon: CUSTOM_TEST_DAPP.icons[0],
projectId: CUSTOM_TEST_DAPP.projectId,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4899,6 +4899,11 @@ domain-browser@^4.22.0:
resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-4.22.0.tgz"
integrity sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw==

[email protected]:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

duplexify@^4.1.2:
version "4.1.2"
resolved "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz"
Expand Down

0 comments on commit 2727131

Please sign in to comment.