mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
648 B
TypeScript
24 lines
648 B
TypeScript
3 years ago
|
import { BrowserContext, expect, Page } from '@playwright/test';
|
||
|
|
||
|
const storagePath = './auth.json';
|
||
|
|
||
|
/**
|
||
|
* 登录到测试账号
|
||
|
*
|
||
|
* 需要提前注册
|
||
|
*/
|
||
|
export async function loginToDemoUser(page: Page, context: BrowserContext) {
|
||
|
await page.goto('/entry/login');
|
||
|
await page
|
||
|
.locator('input[name="login-email"]')
|
||
|
.fill('tailchat-demo@msgbyte.com');
|
||
|
await page.locator('input[name="login-password"]').fill('tailchat-demo');
|
||
|
await page.locator('button:has-text("登录")').click();
|
||
|
|
||
|
await expect(page).toHaveURL('/main/personal/friends'); // should with redirect
|
||
|
|
||
|
await context.storageState({
|
||
|
path: storagePath,
|
||
|
});
|
||
|
}
|