Skip to content

Commit c234865

Browse files
committed
fix: test env vars
1 parent 8252d7f commit c234865

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
@@ -73,6 +73,7 @@
7373
"workbox-core": "^6.5.4",
7474
"workbox-precaching": "^6.5.4",
7575
"workbox-routing": "^6.5.4",
76-
"workbox-window": "^6.5.4"
76+
"workbox-window": "^6.5.4",
77+
"dotenv": "16.3.1"
7778
}
7879
}

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
@@ -131,7 +131,7 @@ test('it should subscribe, receive messages and unsubscribe', async ({
131131
accounts: [`eip155:1:${address}`],
132132
body: "Test Body",
133133
title: "Test Title",
134-
type: CUSTOM_TEST_DAPP.messageType,
134+
type: CUSTOM_TEST_DAPP.notificationType,
135135
url: CUSTOM_TEST_DAPP.appDomain,
136136
icon: CUSTOM_TEST_DAPP.icons[0],
137137
projectId: CUSTOM_TEST_DAPP.projectId,

yarn.lock

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

4798+
dotenv@16.3.1:
4799+
version "16.3.1"
4800+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
4801+
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==
4802+
47984803
duplexify@^4.1.2:
47994804
version "4.1.2"
48004805
resolved "https://registry.npmjs.org/duplexify/-/duplexify-4.1.2.tgz"

0 commit comments

Comments
 (0)