Skip to content

Commit a9f6274

Browse files
committed
test: add nullish checks error for env vars
This makes the error clearer.
1 parent 0628815 commit a9f6274

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

packages/e2e-tests/playwright-helper.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,20 @@ export async function createNewProfile(
129129
// create a new account
130130
await page.getByTestId('create-account-button').click()
131131

132-
const dcAccountLink = useChatmail
133-
? `dcaccount:${chatmailServerUrl}/new`
134-
: `dcaccount:${mailServerUrl}//new_email?t=${mailServerToken}&n=ci_github`
132+
let dcAccountLink: string
133+
if (useChatmail) {
134+
if (!chatmailServerUrl) {
135+
throw new Error('DC_CHATMAIL_SERVER env var not set, cannot run tests')
136+
}
137+
dcAccountLink = `dcaccount:${chatmailServerUrl satisfies string}/new`
138+
} else {
139+
if (!mailServerUrl || mailServerToken == undefined) {
140+
throw new Error(
141+
'DC_MAIL_SERVER or DC_MAIL_SERVER_TOKEN env var not set, cannot run tests'
142+
)
143+
}
144+
dcAccountLink = `dcaccount:${mailServerUrl satisfies string}//new_email?t=${mailServerToken satisfies string}&n=ci_github`
145+
}
135146
await page.evaluate(`navigator.clipboard.writeText('${dcAccountLink}')`)
136147
await clickThroughTestIds(page, [
137148
'other-login-button',

0 commit comments

Comments
 (0)