diff options
author | Chocobozzz <me@florianbigard.com> | 2023-01-19 09:30:05 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-01-19 13:53:40 +0100 |
commit | 5bdfa604f102a5e51b5152457cd1a16d79177e26 (patch) | |
tree | 878c04cbd3c452c7b45aa39e19abd38bfe691063 /client/e2e/src/utils/email.ts | |
parent | 9589907c89d29a6c0acd52c8cb789af9f93ce9af (diff) | |
download | PeerTube-5bdfa604f102a5e51b5152457cd1a16d79177e26.tar.gz PeerTube-5bdfa604f102a5e51b5152457cd1a16d79177e26.tar.zst PeerTube-5bdfa604f102a5e51b5152457cd1a16d79177e26.zip |
Add E2E client tests for signup approval
Diffstat (limited to 'client/e2e/src/utils/email.ts')
-rw-r--r-- | client/e2e/src/utils/email.ts | 31 |
1 files changed, 31 insertions, 0 deletions
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 @@ | |||
1 | function getVerificationLink (email: { text: string }) { | ||
2 | const { text } = email | ||
3 | |||
4 | const regexp = /\[(?<link>http:\/\/[^\]]+)\]/g | ||
5 | const matched = text.matchAll(regexp) | ||
6 | |||
7 | if (!matched) throw new Error('Could not find verification link in email') | ||
8 | |||
9 | for (const match of matched) { | ||
10 | const link = match.groups.link | ||
11 | |||
12 | if (link.includes('/verify-account/')) return link | ||
13 | } | ||
14 | |||
15 | throw new Error('Could not find /verify-account/ link') | ||
16 | } | ||
17 | |||
18 | function findEmailTo (emails: { text: string, to: { address: string }[] }[], to: string) { | ||
19 | for (const email of emails) { | ||
20 | for (const { address } of email.to) { | ||
21 | if (address === to) return email | ||
22 | } | ||
23 | } | ||
24 | |||
25 | return undefined | ||
26 | } | ||
27 | |||
28 | export { | ||
29 | getVerificationLink, | ||
30 | findEmailTo | ||
31 | } | ||