| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import { test, expect } from '../../utils/test-setup';
- test.describe('平台删除功能修复', () => {
- const testPlatformName = '测试删除平台-' + Date.now();
- test.beforeEach(async ({ adminLoginPage, platformManagementPage }) => {
- await adminLoginPage.goto();
- await adminLoginPage.login('admin', 'admin123');
- await adminLoginPage.expectLoginSuccess();
- await platformManagementPage.goto();
- });
- test.afterEach(async ({ platformManagementPage }) => {
- await platformManagementPage.goto();
- try {
- await platformManagementPage.deletePlatform(testPlatformName);
- } catch {
- // 平台可能已被删除,忽略错误
- }
- });
- test.describe('物理删除功能', () => {
- test('删除平台后可以创建同名平台', async ({ page, platformManagementPage }) => {
- await platformManagementPage.createPlatform({
- platformName: testPlatformName,
- contactPerson: '测试联系人',
- contactPhone: '13800138000',
- contactEmail: 'test@example.com',
- });
- await expect(page.getByText(testPlatformName)).toBeVisible();
- await platformManagementPage.deletePlatform(testPlatformName);
- await expect(page.getByText(testPlatformName)).not.toBeVisible();
- await platformManagementPage.createPlatform({
- platformName: testPlatformName,
- contactPerson: '测试联系人2',
- contactPhone: '13800138001',
- contactEmail: 'test2@example.com',
- });
- await expect(page.getByText(testPlatformName)).toBeVisible();
- await expect(page.getByText('测试联系人2')).toBeVisible();
- await platformManagementPage.deletePlatform(testPlatformName);
- });
- });
- test.describe('启用/禁用功能', () => {
- test('禁用平台后状态变为禁用', async ({ page, platformManagementPage }) => {
- await platformManagementPage.createPlatform({
- platformName: testPlatformName,
- contactPerson: '测试联系人',
- contactPhone: '13800138000',
- contactEmail: 'test@example.com',
- });
- const selector = '[data-testid="toggle-button-' + testPlatformName + '"]';
- await page.click(selector, { timeout: 5000 });
- await page.click('button:has-text("禁用")');
- await page.reload();
- await page.waitForLoadState('networkidle');
- const statusCell = page.locator('tr').filter({ hasText: testPlatformName }).locator('td').nth(2);
- await expect(statusCell).toContainText('禁用');
- await expect(statusCell).toHaveClass(/text-gray-400/);
- await platformManagementPage.deletePlatform(testPlatformName);
- });
- test('禁用的平台可以重新启用', async ({ page, platformManagementPage }) => {
- await platformManagementPage.createPlatform({
- platformName: testPlatformName,
- contactPerson: '测试联系人',
- contactPhone: '13800138000',
- });
- const selector = '[data-testid="toggle-button-' + testPlatformName + '"]';
- await page.click(selector, { timeout: 5000 });
- await page.click('button:has-text("禁用")');
- await page.waitForTimeout(500);
- await page.click(selector, { timeout: 5000 });
- await page.click('button:has-text("启用")');
- await page.reload();
- await page.waitForLoadState('networkidle');
- const statusCell = page.locator('tr').filter({ hasText: testPlatformName }).locator('td').nth(2);
- await expect(statusCell).toContainText('正常');
- await expect(statusCell).toHaveClass(/text-green-600/);
- await platformManagementPage.deletePlatform(testPlatformName);
- });
- });
- test.describe('删除与禁用功能分离', () => {
- test('操作列有三个按钮:编辑、禁用/启用、删除', async ({ platformManagementPage }) => {
- await platformManagementPage.createPlatform({
- platformName: testPlatformName,
- contactPerson: '测试联系人',
- contactPhone: '13800138000',
- });
- const platformRow = platformManagementPage.page.locator('tr').filter({ hasText: testPlatformName });
- await expect(platformRow.locator('[data-testid^="edit-button-"]')).toBeVisible();
- await expect(platformRow.locator('[data-testid^="toggle-button-"]')).toBeVisible();
- await expect(platformRow.locator('[data-testid^="delete-button-"]')).toBeVisible();
- await platformManagementPage.deletePlatform(testPlatformName);
- });
- });
- });
|