From 5bdfa604f102a5e51b5152457cd1a16d79177e26 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Jan 2023 09:30:05 +0100 Subject: Add E2E client tests for signup approval --- client/e2e/src/utils/email.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 client/e2e/src/utils/email.ts (limited to 'client/e2e/src/utils/email.ts') diff --git a/client/e2e/src/utils/email.ts b/client/e2e/src/utils/email.ts new file mode 100644 index 000000000..2ad120333 --- /dev/null +++ b/client/e2e/src/utils/email.ts @@ -0,0 +1,31 @@ +function getVerificationLink (email: { text: string }) { + const { text } = email + + const regexp = /\[(?http:\/\/[^\]]+)\]/g + const matched = text.matchAll(regexp) + + if (!matched) throw new Error('Could not find verification link in email') + + for (const match of matched) { + const link = match.groups.link + + if (link.includes('/verify-account/')) return link + } + + throw new Error('Could not find /verify-account/ link') +} + +function findEmailTo (emails: { text: string, to: { address: string }[] }[], to: string) { + for (const email of emails) { + for (const { address } of email.to) { + if (address === to) return email + } + } + + return undefined +} + +export { + getVerificationLink, + findEmailTo +} -- cgit v1.2.3