Skip to content

Commit 2727131

Browse files
committed
fix: test env vars
1 parent 6e4d1f6 commit 2727131

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ VITE_PROJECT_ID="54..."
44
VITE_VAPID_KEY="BdV...."
55
VITE_SENTRY_DSN="https://96..."
66
VITE_MIXPANEL_TOKEN="8dj...."
7+
TEST_DAPP_PROJECT_ID=""
8+
TEST_DAPP_PROJECT_SECRET=""

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"workbox-core": "^6.5.4",
7373
"workbox-precaching": "^6.5.4",
7474
"workbox-routing": "^6.5.4",
75-
"workbox-window": "^6.5.4"
75+
"workbox-window": "^6.5.4",
76+
"dotenv": "16.3.1"
7677
}
7778
}

playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { config } from 'dotenv'
12
import { defineConfig, devices } from '@playwright/test'
3+
config({ path: './.env' })
24

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

tests/shared/constants/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ export const DEFAULT_SESSION_PARAMS: SessionParams = {
99
accept: true
1010
}
1111

12+
function getRequiredEnvVar(name: string): string {
13+
const value = process.env[name]
14+
if (!value) {
15+
throw new Error(`Missing required environment variable: ${name}`)
16+
}
17+
return value
18+
}
19+
1220
export const CUSTOM_TEST_DAPP = {
1321
description: 'Test description',
1422
icons: ['https://i.imgur.com/q9QDRXc.png'],
1523
name: 'Notify Swift Integration Tests Prod',
1624
appDomain: 'wc-notify-swift-integration-tests-prod.pages.dev',
17-
projectSecret: process.env['TEST_DAPP_PROJECT_SECRET'],
18-
projectId: process.env['TEST_DAPP_PROJECT_ID'],
19-
messageType: 'f173f231-a45c-4dc0-aa5d-956eb04f7360'
25+
projectSecret: getRequiredEnvVar('TEST_DAPP_PROJECT_SECRET'),
26+
projectId: getRequiredEnvVar('TEST_DAPP_PROJECT_ID'),
27+
notificationType: 'f173f231-a45c-4dc0-aa5d-956eb04f7360'
2028
} as const

tests/subscribe.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ test('it should subscribe, receive messages and unsubscribe', async ({
130130
accounts: [`eip155:1:${address}`],
131131
body: 'Test Body',
132132
title: 'Test Title',
133-
type: CUSTOM_TEST_DAPP.messageType,
133+
type: CUSTOM_TEST_DAPP.notificationType,
134134
url: CUSTOM_TEST_DAPP.appDomain,
135135
icon: CUSTOM_TEST_DAPP.icons[0],
136136
projectId: CUSTOM_TEST_DAPP.projectId,

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4899,6 +4899,11 @@ domain-browser@^4.22.0:
48994899
resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-4.22.0.tgz"
49004900
integrity sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw==
49014901

4902+
dotenv@16.3.1:
4903+
version "16.3.1"
4904+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
4905+
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==
4906+
49024907
duplexify@^4.1.2:
49034908
version "4.1.2"
49044909
resolved "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz"

0 commit comments

Comments
 (0)