mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
@@ -12,6 +12,7 @@ import { faker } from '@faker-js/faker';
|
||||
import { hash } from '@node-rs/argon2';
|
||||
import type { BrowserContext, Cookie, Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Assertions } from 'ava';
|
||||
import { z } from 'zod';
|
||||
|
||||
export async function getCurrentMailMessageCount() {
|
||||
@@ -26,6 +27,19 @@ export async function getLatestMailMessage() {
|
||||
return data.items[0];
|
||||
}
|
||||
|
||||
export async function getTokenFromLatestMailMessage<A extends Assertions>(
|
||||
test?: A
|
||||
) {
|
||||
const tokenRegex = /token=3D([^"&]+)/;
|
||||
const emailContent = await getLatestMailMessage();
|
||||
const tokenMatch = emailContent.Content.Body.match(tokenRegex);
|
||||
const token = tokenMatch
|
||||
? decodeURIComponent(tokenMatch[1].replace(/=\r\n/, ''))
|
||||
: null;
|
||||
test?.truthy(token);
|
||||
return token;
|
||||
}
|
||||
|
||||
export async function getLoginCookie(
|
||||
context: BrowserContext
|
||||
): Promise<Cookie | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user