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.
tailchat/web/e2e/playwright/tests/main.spec.ts

83 lines
2.8 KiB
TypeScript

import { loginToDemoUser } from './utils/user';
import { test, expect, Page } from '@playwright/test';
test.beforeEach(async ({ page, context }) => {
await loginToDemoUser(page, context);
});
test.describe('Main Process', () => {
test('Check All Route', async ({ page }) => {
// Click text=已发送
await page.locator('text=已发送').click();
// Click text=待处理
await page.locator('text=待处理').click();
// Click text=添加好友
await page.locator('text=添加好友').click();
// Click [aria-label="Copy"]
await page.locator('[aria-label="Copy"]').click();
// Click text=插件中心
await page.locator('text=插件中心').click();
await expect(page).toHaveURL(
'http://localhost:11011/main/personal/plugins'
);
// Click text=已安装
await page.locator('text=已安装').click();
// Click text=手动安装
await page.locator('text=手动安装').click();
// Click svg[role="img"] >> nth=1
await page.locator('svg[role="img"]').nth(1).click();
// Click text=系统设置
await page.locator('text=系统设置').click();
// Click text=服务状态
await page.locator('text=服务状态').click();
// Click text=性能统计
await page.locator('text=性能统计').click();
// Click text=关于
await page.locator('text=关于').click();
// Click 关闭
await page.locator('.text-2xl.border-2').click();
});
test.describe('Group', () => {
/**
*
*/
async function createGroup(page: Page) {
// Click [data-testid="create-group"]
await page.locator('[data-testid="create-group"]').click();
// Click text=默认群组
await page.locator('text=默认群组').click();
// Click input[type="text"]
await page.locator('input[type="text"]').click();
// Fill input[type="text"]
await page.locator('input[type="text"]').fill('Test');
// Press Enter
await page.locator('input[type="text"]').press('Enter');
// Click button:has-text("确认创建")
await page.locator('button:has-text("确认创建")').click();
await expect(page).toHaveURL(/\/main\/group\/\S{24}\/\S{24}/);
}
/**
*
*/
async function deleteGroup(page: Page) {
// Click text=Test
await page.locator('text=Test').click();
// Click text=退出群组
await page.locator('text=退出群组').click();
// Click button:has-text("OK")
await Promise.all([
page.waitForNavigation(/*{ url: 'http://localhost:11011/main/personal/friends' }*/),
page.locator('button:has-text("OK")').click(),
]);
}
test.only('Create Group', async ({ page }) => {
await createGroup(page);
await deleteGroup(page);
});
});
});