2026-03-14 16:50:54 +08:00
|
|
|
/**
|
|
|
|
|
* 超管端 E2E 测试 - 租户管理
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
|
import { loginAsAdmin, waitForTable, waitForSuccess, waitForModal } from './helpers';
|
|
|
|
|
import { TEST_DATA } from './fixtures';
|
|
|
|
|
|
|
|
|
|
test.describe('租户管理', () => {
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
|
await loginAsAdmin(page);
|
|
|
|
|
// 导航到租户列表页面
|
|
|
|
|
await page.goto('/admin/tenants');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('列表页面', () => {
|
|
|
|
|
test('访问租户列表页面', async ({ page }) => {
|
|
|
|
|
// 验证页面 URL
|
|
|
|
|
await expect(page).toHaveURL(/\/admin\/tenants/);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('验证列表加载', async ({ page }) => {
|
|
|
|
|
// 等待表格加载
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 验证表格存在
|
|
|
|
|
const table = page.locator('table, .ant-table');
|
|
|
|
|
await expect(table).toBeVisible();
|
|
|
|
|
|
|
|
|
|
// 验证添加租户按钮存在
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await expect(addButton).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('搜索功能', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 输入搜索关键词
|
|
|
|
|
const searchInput = page.getByPlaceholder(/学校名称 | 关键词/);
|
|
|
|
|
if (await searchInput.isVisible()) {
|
|
|
|
|
await searchInput.fill('测试');
|
|
|
|
|
await searchInput.press('Enter');
|
|
|
|
|
|
|
|
|
|
// 等待搜索结果
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证表格仍然存在
|
|
|
|
|
const table = page.locator('table, .ant-table');
|
|
|
|
|
await expect(table).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('筛选功能 - 按状态', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 选择状态筛选
|
|
|
|
|
const statusSelect = page.getByPlaceholder('全部状态');
|
|
|
|
|
if (await statusSelect.isVisible()) {
|
|
|
|
|
await statusSelect.click();
|
|
|
|
|
await page.getByText('生效中').click();
|
|
|
|
|
|
|
|
|
|
// 等待筛选结果
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证表格仍然存在
|
|
|
|
|
const table = page.locator('table, .ant-table');
|
|
|
|
|
await expect(table).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('筛选功能 - 按套餐', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 选择套餐筛选
|
|
|
|
|
const packageSelect = page.getByPlaceholder('全部套餐');
|
|
|
|
|
if (await packageSelect.isVisible()) {
|
|
|
|
|
await packageSelect.click();
|
|
|
|
|
await page.getByText('标准版').click();
|
|
|
|
|
|
|
|
|
|
// 等待筛选结果
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证表格仍然存在
|
|
|
|
|
const table = page.locator('table, .ant-table');
|
|
|
|
|
await expect(table).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('分页功能', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 验证分页控件存在
|
|
|
|
|
const pagination = page.locator('.ant-pagination');
|
|
|
|
|
await expect(pagination).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('创建租户', () => {
|
|
|
|
|
test('点击添加租户按钮', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
|
|
|
|
|
// 等待弹窗显示
|
|
|
|
|
const modal = page.locator('.ant-modal');
|
|
|
|
|
await expect(modal).toBeVisible({ timeout: 5000 });
|
|
|
|
|
await expect(page.getByText(/添加租户 | 新建租户/)).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('填写基本信息', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// 填写学校名称
|
|
|
|
|
const nameInput = page.locator('input[placeholder*="学校名称"]');
|
|
|
|
|
await nameInput.fill(TEST_DATA.tenant.name);
|
|
|
|
|
|
|
|
|
|
// 填写登录账号
|
|
|
|
|
const accountInput = page.locator('input[placeholder*="登录账号"]');
|
|
|
|
|
await accountInput.fill(TEST_DATA.tenant.account);
|
|
|
|
|
|
|
|
|
|
// 填写联系人
|
|
|
|
|
const contactInput = page.locator('input[placeholder*="联系人"]');
|
|
|
|
|
await contactInput.fill(TEST_DATA.tenant.contactPerson);
|
|
|
|
|
|
|
|
|
|
// 填写联系电话
|
|
|
|
|
const phoneInput = page.locator('input[placeholder*="联系电话"]');
|
|
|
|
|
await phoneInput.fill(TEST_DATA.tenant.contactPhone);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('选择套餐类型', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// 选择套餐类型
|
|
|
|
|
const packageSelect = page.locator('[placeholder*="套餐类型"]');
|
|
|
|
|
if (await packageSelect.isVisible()) {
|
|
|
|
|
await packageSelect.click();
|
|
|
|
|
await page.getByText('标准版').click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('设置配额', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// 设置教师配额
|
|
|
|
|
const teacherQuotaInput = page.locator('input[placeholder*="教师配额"]');
|
|
|
|
|
if (await teacherQuotaInput.isVisible()) {
|
|
|
|
|
await teacherQuotaInput.fill(String(TEST_DATA.tenant.teacherQuota));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置学生配额
|
|
|
|
|
const studentQuotaInput = page.locator('input[placeholder*="学生配额"]');
|
|
|
|
|
if (await studentQuotaInput.isVisible()) {
|
|
|
|
|
await studentQuotaInput.fill(String(TEST_DATA.tenant.studentQuota));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('设置有效期', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// 验证日期选择器存在
|
|
|
|
|
const datePicker = page.locator('.ant-picker');
|
|
|
|
|
await expect(datePicker).toBeVisible();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('保存租户', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击添加租户按钮
|
|
|
|
|
const addButton = page.getByText(/添加租户 | 新建租户/);
|
|
|
|
|
await addButton.click();
|
|
|
|
|
await page.waitForTimeout(500);
|
|
|
|
|
|
|
|
|
|
// 填写学校名称
|
|
|
|
|
const nameInput = page.locator('input[placeholder*="学校名称"]');
|
2026-03-26 10:21:34 +08:00
|
|
|
await nameInput.fill(` ${TEST_DATA.tenant.name} `);
|
2026-03-14 16:50:54 +08:00
|
|
|
|
|
|
|
|
// 填写登录账号
|
|
|
|
|
const accountInput = page.locator('input[placeholder*="登录账号"]');
|
2026-03-26 10:21:34 +08:00
|
|
|
await accountInput.fill(` ${TEST_DATA.tenant.account} `);
|
2026-03-14 16:50:54 +08:00
|
|
|
|
|
|
|
|
// 填写联系人
|
|
|
|
|
const contactInput = page.locator('input[placeholder*="联系人"]');
|
2026-03-26 10:21:34 +08:00
|
|
|
await contactInput.fill(` ${TEST_DATA.tenant.contactPerson} `);
|
2026-03-14 16:50:54 +08:00
|
|
|
|
|
|
|
|
// 填写联系电话
|
|
|
|
|
const phoneInput = page.locator('input[placeholder*="联系电话"]');
|
2026-03-26 10:21:34 +08:00
|
|
|
await phoneInput.fill(` ${TEST_DATA.tenant.contactPhone} `);
|
2026-03-14 16:50:54 +08:00
|
|
|
|
|
|
|
|
// 选择套餐类型
|
|
|
|
|
const packageSelect = page.locator('[placeholder*="套餐类型"]');
|
|
|
|
|
if (await packageSelect.isVisible()) {
|
|
|
|
|
await packageSelect.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
await page.getByText('标准版').click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置教师配额
|
|
|
|
|
const teacherQuotaInput = page.locator('input[placeholder*="教师配额"]');
|
|
|
|
|
if (await teacherQuotaInput.isVisible()) {
|
|
|
|
|
await teacherQuotaInput.fill(String(TEST_DATA.tenant.teacherQuota));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置学生配额
|
|
|
|
|
const studentQuotaInput = page.locator('input[placeholder*="学生配额"]');
|
|
|
|
|
if (await studentQuotaInput.isVisible()) {
|
|
|
|
|
await studentQuotaInput.fill(String(TEST_DATA.tenant.studentQuota));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击确定按钮
|
|
|
|
|
const okButton = page.locator('.ant-modal button:has-text("确定")');
|
|
|
|
|
if (await okButton.isVisible()) {
|
|
|
|
|
await okButton.click();
|
|
|
|
|
|
|
|
|
|
// 等待保存结果
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('查看租户详情', () => {
|
|
|
|
|
test('点击租户查看详情', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击第一个租户名称链接
|
|
|
|
|
const tenantLink = page.locator('table a').first();
|
|
|
|
|
if (await tenantLink.isVisible()) {
|
|
|
|
|
await tenantLink.click();
|
|
|
|
|
|
|
|
|
|
// 等待详情抽屉显示
|
|
|
|
|
const drawer = page.locator('.ant-drawer');
|
|
|
|
|
await expect(drawer).toBeVisible({ timeout: 5000 });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('查看基本信息', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击第一个租户名称链接
|
|
|
|
|
const tenantLink = page.locator('table a').first();
|
|
|
|
|
if (await tenantLink.isVisible()) {
|
|
|
|
|
await tenantLink.click();
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// 验证基本信息显示
|
|
|
|
|
await expect(page.getByText(/学校名称 | 登录账号/)).toBeVisible();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('查看教师列表', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击第一个租户名称链接
|
|
|
|
|
const tenantLink = page.locator('table a').first();
|
|
|
|
|
if (await tenantLink.isVisible()) {
|
|
|
|
|
await tenantLink.click();
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// 验证教师列表区域存在
|
|
|
|
|
await expect(page.getByText(/教师 | 最近教师/)).toBeVisible();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('查看学生列表', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 点击第一个租户名称链接
|
|
|
|
|
const tenantLink = page.locator('table a').first();
|
|
|
|
|
if (await tenantLink.isVisible()) {
|
|
|
|
|
await tenantLink.click();
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// 验证学生列表区域存在
|
|
|
|
|
await expect(page.getByText(/学生 | 最近学生/)).toBeVisible();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('编辑租户', () => {
|
|
|
|
|
test('点击编辑按钮', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
|
|
|
|
|
// 点击编辑选项
|
|
|
|
|
const editOption = page.getByText('编辑').first();
|
|
|
|
|
await editOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待编辑弹窗显示
|
|
|
|
|
const modal = page.locator('.ant-modal');
|
|
|
|
|
await expect(modal).toBeVisible({ timeout: 5000 });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('修改基本信息', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 点击编辑选项
|
|
|
|
|
const editOption = page.getByText('编辑').first();
|
|
|
|
|
await editOption.click();
|
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
|
|
// 修改联系人
|
|
|
|
|
const contactInput = page.locator('input[placeholder*="联系人"]');
|
|
|
|
|
if (await contactInput.isVisible()) {
|
|
|
|
|
const originalContact = await contactInput.inputValue();
|
|
|
|
|
await contactInput.fill(`${originalContact}_已修改`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击确定按钮
|
|
|
|
|
const okButton = page.locator('.ant-modal button:has-text("确定")');
|
|
|
|
|
if (await okButton.isVisible()) {
|
|
|
|
|
await okButton.click();
|
|
|
|
|
|
|
|
|
|
// 等待保存结果
|
|
|
|
|
await page.waitForTimeout(2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('修改配额', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 点击调整配额选项
|
|
|
|
|
const quotaOption = page.getByText('调整配额');
|
|
|
|
|
await quotaOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待配额弹窗显示
|
|
|
|
|
const modal = page.locator('.ant-modal');
|
|
|
|
|
await expect(modal).toBeVisible({ timeout: 5000 });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('租户状态管理', () => {
|
|
|
|
|
test('禁用租户', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 查找暂停服务选项
|
|
|
|
|
const suspendOption = page.getByText('暂停服务');
|
|
|
|
|
if (await suspendOption.isVisible()) {
|
|
|
|
|
await suspendOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待确认弹窗
|
|
|
|
|
const confirmDialog = page.locator('.ant-modal-confirm');
|
|
|
|
|
await expect(confirmDialog).toBeVisible({ timeout: 5000 });
|
|
|
|
|
|
|
|
|
|
// 点击取消,不实际操作
|
|
|
|
|
const cancelButton = page.locator('.ant-modal-confirm button:has-text("取消")');
|
|
|
|
|
if (await cancelButton.isVisible()) {
|
|
|
|
|
await cancelButton.click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('启用租户', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 查找恢复服务选项(只有已暂停的租户才有此选项)
|
|
|
|
|
const resumeOption = page.getByText('恢复服务');
|
|
|
|
|
if (await resumeOption.isVisible()) {
|
|
|
|
|
await resumeOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待确认弹窗
|
|
|
|
|
const confirmDialog = page.locator('.ant-modal-confirm');
|
|
|
|
|
await expect(confirmDialog).toBeVisible({ timeout: 5000 });
|
|
|
|
|
|
|
|
|
|
// 点击取消,不实际操作
|
|
|
|
|
const cancelButton = page.locator('.ant-modal-confirm button:has-text("取消")');
|
|
|
|
|
if (await cancelButton.isVisible()) {
|
|
|
|
|
await cancelButton.click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('重置密码', () => {
|
|
|
|
|
test('点击重置密码', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 点击重置密码选项
|
|
|
|
|
const resetPasswordOption = page.getByText('重置密码');
|
|
|
|
|
await resetPasswordOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待确认弹窗
|
|
|
|
|
const confirmDialog = page.locator('.ant-modal-confirm');
|
|
|
|
|
await expect(confirmDialog).toBeVisible({ timeout: 5000 });
|
|
|
|
|
|
|
|
|
|
// 点击取消,不实际操作
|
|
|
|
|
const cancelButton = page.locator('.ant-modal-confirm button:has-text("取消")');
|
|
|
|
|
if (await cancelButton.isVisible()) {
|
|
|
|
|
await cancelButton.click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('删除租户', () => {
|
|
|
|
|
test('点击删除按钮', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 查找删除选项
|
|
|
|
|
const deleteOption = page.locator('.ant-dropdown-menu-item-danger').or(page.getByText('删除'));
|
|
|
|
|
if (await deleteOption.isVisible()) {
|
|
|
|
|
await expect(deleteOption).toBeVisible();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('确认删除弹窗', async ({ page }) => {
|
|
|
|
|
await waitForTable(page);
|
|
|
|
|
|
|
|
|
|
// 查找操作下拉菜单
|
|
|
|
|
const actionButton = page.locator('button:has-text("操作")').first();
|
|
|
|
|
if (await actionButton.isVisible()) {
|
|
|
|
|
await actionButton.click();
|
|
|
|
|
await page.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
// 点击删除选项
|
|
|
|
|
const deleteOption = page.locator('.ant-dropdown-menu-item-danger').or(page.getByText('删除'));
|
|
|
|
|
if (await deleteOption.isVisible()) {
|
|
|
|
|
await deleteOption.click();
|
|
|
|
|
|
|
|
|
|
// 等待确认弹窗
|
|
|
|
|
const confirmDialog = page.locator('.ant-modal-confirm');
|
|
|
|
|
await expect(confirmDialog).toBeVisible({ timeout: 5000 });
|
|
|
|
|
|
|
|
|
|
// 点击取消,不实际删除
|
|
|
|
|
const cancelButton = page.locator('.ant-modal-confirm button:has-text("取消")');
|
|
|
|
|
if (await cancelButton.isVisible()) {
|
|
|
|
|
await cancelButton.click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|