|
|
@@ -0,0 +1,42 @@
|
|
|
+import { test, expect } from '@playwright/test';
|
|
|
+
|
|
|
+test.describe('知识库管理CRUD测试', () => {
|
|
|
+ test.beforeEach(async ({ page }) => {
|
|
|
+ // 先登录获取有效token
|
|
|
+ await page.goto('https://pre-117-77-template.r.d8d.fun/admin/login');
|
|
|
+ await page.fill('input[placeholder="用户名"]', 'admin');
|
|
|
+ await page.fill('input[placeholder="密码"]', 'admin123');
|
|
|
+ await page.click('button:has-text("登 录")');
|
|
|
+ await expect(page).toHaveURL(/\/admin\/dashboard/);
|
|
|
+
|
|
|
+ // 导航到测试页面
|
|
|
+ await page.goto('https://pre-117-77-template.r.d8d.fun/admin/know-info');
|
|
|
+ });
|
|
|
+
|
|
|
+ test('添加测试文章', async ({ page }) => {
|
|
|
+ await page.click('button:has-text("添加文章")');
|
|
|
+ await page.fill('input[placeholder="请输入文章标题"]', '测试文章-自动化测试');
|
|
|
+ await page.click('button:has-text("确 定")');
|
|
|
+ await expect(page.locator('text=测试文章-自动化测试')).toBeVisible();
|
|
|
+ });
|
|
|
+
|
|
|
+ test('搜索测试文章', async ({ page }) => {
|
|
|
+ await page.fill('input[placeholder="要搜索的文章标题"]', '测试文章-自动化测试');
|
|
|
+ await page.click('button:has-text("搜 索")');
|
|
|
+ await expect(page.locator('text=测试文章-自动化测试')).toBeVisible();
|
|
|
+ await page.click('button:has-text("重 置")');
|
|
|
+ });
|
|
|
+
|
|
|
+ test('修改测试文章', async ({ page }) => {
|
|
|
+ await page.click('tr:has-text("测试文章-自动化测试") >> button:has-text("编辑")');
|
|
|
+ await page.fill('input[placeholder="请输入文章标题"]', '修改后的测试标题');
|
|
|
+ await page.click('button:has-text("确 定")');
|
|
|
+ await expect(page.locator('text=修改后的测试标题')).toBeVisible();
|
|
|
+ });
|
|
|
+
|
|
|
+ test('删除测试文章', async ({ page }) => {
|
|
|
+ await page.click('tr:has-text("修改后的测试标题") >> button:has-text("删除")');
|
|
|
+ await page.click('.ant-btn-primary:has-text("确 定")');
|
|
|
+ await expect(page.locator('text=修改后的测试标题')).not.toBeVisible();
|
|
|
+ });
|
|
|
+});
|