|
@@ -0,0 +1,579 @@
|
|
|
|
|
+import { test, expect } from '../../utils/test-setup';
|
|
|
|
|
+import { readFileSync } from 'fs';
|
|
|
|
|
+import { join, dirname } from 'path';
|
|
|
|
|
+import { fileURLToPath } from 'url';
|
|
|
|
|
+import { selectRadixOption } from '@d8d/e2e-test-utils';
|
|
|
|
|
+
|
|
|
|
|
+const __filename = fileURLToPath(import.meta.url);
|
|
|
|
|
+const __dirname = dirname(__filename);
|
|
|
|
|
+const testUsers = JSON.parse(readFileSync(join(__dirname, '../../fixtures/test-users.json'), 'utf-8'));
|
|
|
|
|
+
|
|
|
|
|
+test.describe.serial('订单搜索和筛选测试', () => {
|
|
|
|
|
+ test.beforeEach(async ({ adminLoginPage, orderManagementPage }) => {
|
|
|
|
|
+ // 以管理员身份登录后台
|
|
|
|
|
+ await adminLoginPage.goto();
|
|
|
|
|
+ await adminLoginPage.login(testUsers.admin.username, testUsers.admin.password);
|
|
|
|
|
+ await adminLoginPage.expectLoginSuccess();
|
|
|
|
|
+ await orderManagementPage.goto();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('订单名称搜索', () => {
|
|
|
|
|
+ test('应该能按订单名称关键词搜索', async ({ orderManagementPage, page }) => {
|
|
|
|
|
+ // 记录初始行数
|
|
|
|
|
+ const tbody = page.locator('table tbody');
|
|
|
|
|
+ const initialRows = tbody.locator('tr');
|
|
|
|
|
+ const initialCount = await initialRows.count();
|
|
|
|
|
+ console.debug(`初始订单列表有 ${initialCount} 行`);
|
|
|
|
|
+
|
|
|
|
|
+ // 执行搜索
|
|
|
|
|
+ await orderManagementPage.searchByName('测试');
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+
|
|
|
|
|
+ // 验证搜索后表格仍然可见
|
|
|
|
|
+ await expect(orderManagementPage.orderTable).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取搜索后的行数
|
|
|
|
|
+ const searchRows = tbody.locator('tr');
|
|
|
|
|
+ const searchCount = await searchRows.count();
|
|
|
|
|
+ console.debug(`搜索"测试"后订单列表有 ${searchCount} 行`);
|
|
|
|
|
+
|
|
|
|
|
+ // 搜索功能本身是工作的(表格没有消失)
|
|
|
|
|
+ expect(searchCount).toBeGreaterThanOrEqual(0);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能清空搜索条件', async ({ orderManagementPage, page }) => {
|
|
|
|
|
+ // 先执行搜索
|
|
|
|
|
+ await orderManagementPage.searchByName('测试');
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 清空搜索框
|
|
|
|
|
+ await orderManagementPage.searchInput.clear();
|
|
|
|
|
+ await orderManagementPage.searchButton.click();
|
|
|
|
|
+ // 使用带超时的等待,因为清空搜索后可能没有网络请求
|
|
|
|
|
+ await page.waitForLoadState('networkidle', { timeout: 5000 }).catch(() => {
|
|
|
|
|
+ console.debug('清空搜索后没有网络请求,这是正常的');
|
|
|
|
|
+ });
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证表格仍然可见
|
|
|
|
|
+ await expect(orderManagementPage.orderTable).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('订单状态筛选', () => {
|
|
|
|
|
+ test('应该能按草稿状态筛选', async ({ page }) => {
|
|
|
|
|
+ // 订单状态筛选是页面上的内联选择器
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await expect(orderStatusSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 点击选择器打开下拉菜单
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ // 选择"草稿"选项
|
|
|
|
|
+ const draftOption = page.getByTestId('order-status-option-draft');
|
|
|
|
|
+ await expect(draftOption).toBeVisible();
|
|
|
|
|
+ await draftOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ // 点击搜索按钮应用筛选
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证表格仍然可见
|
|
|
|
|
+ const table = page.locator('table');
|
|
|
|
|
+ await expect(table).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按已确认状态筛选', async ({ page }) => {
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const confirmedOption = page.getByTestId('order-status-option-confirmed');
|
|
|
|
|
+ await confirmedOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按进行中状态筛选', async ({ page }) => {
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const inProgressOption = page.getByTestId('order-status-option-in-progress');
|
|
|
|
|
+ await inProgressOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按已完成状态筛选', async ({ page }) => {
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const completedOption = page.getByTestId('order-status-option-completed');
|
|
|
|
|
+ await completedOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能选择全部状态', async ({ page }) => {
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const allOption = page.getByTestId('order-status-option-all');
|
|
|
|
|
+ await allOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('工作状态筛选', () => {
|
|
|
|
|
+ test('应该能按未就业状态筛选', async ({ page }) => {
|
|
|
|
|
+ const workStatusSelect = page.getByTestId('filter-work-status-select');
|
|
|
|
|
+ await expect(workStatusSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ await workStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const notWorkingOption = page.getByTestId('work-status-option-not-working');
|
|
|
|
|
+ await expect(notWorkingOption).toBeVisible();
|
|
|
|
|
+ await notWorkingOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按待就业状态筛选', async ({ page }) => {
|
|
|
|
|
+ const workStatusSelect = page.getByTestId('filter-work-status-select');
|
|
|
|
|
+ await workStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const preWorkingOption = page.getByTestId('work-status-option-pre-working');
|
|
|
|
|
+ await preWorkingOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按已就业状态筛选', async ({ page }) => {
|
|
|
|
|
+ const workStatusSelect = page.getByTestId('filter-work-status-select');
|
|
|
|
|
+ await workStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const workingOption = page.getByTestId('work-status-option-working');
|
|
|
|
|
+ await workingOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能按已离职状态筛选', async ({ page }) => {
|
|
|
|
|
+ const workStatusSelect = page.getByTestId('filter-work-status-select');
|
|
|
|
|
+ await workStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const resignedOption = page.getByTestId('work-status-option-resigned');
|
|
|
|
|
+ await resignedOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('平台筛选', () => {
|
|
|
|
|
+ test('应该能打开平台选择器', async ({ page }) => {
|
|
|
|
|
+ const platformSelect = page.getByTestId('platform-search-select');
|
|
|
|
|
+ await expect(platformSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 验证平台标签存在
|
|
|
|
|
+ const platformLabel = page.getByText('平台');
|
|
|
|
|
+ const hasPlatformLabel = await platformLabel.count() > 0;
|
|
|
|
|
+ console.debug(`平台标签存在: ${hasPlatformLabel}`);
|
|
|
|
|
+ expect(hasPlatformLabel).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能使用平台选择器筛选', async ({ page }) => {
|
|
|
|
|
+ const platformSelect = page.getByTestId('platform-search-select');
|
|
|
|
|
+ await expect(platformSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 注意:实际筛选效果取决于数据库中的数据
|
|
|
|
|
+ // 这里只验证选择器可以交互,点击搜索按钮
|
|
|
|
|
+ await platformSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有选项,选择第一个(如果有的话)
|
|
|
|
|
+ const firstOption = page.locator('[role="option"]').first();
|
|
|
|
|
+ const hasOptions = await firstOption.count() > 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (hasOptions) {
|
|
|
|
|
+ await firstOption.click();
|
|
|
|
|
+ console.debug('选择了第一个平台选项');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 点击搜索按钮
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证表格仍然可见
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('公司筛选', () => {
|
|
|
|
|
+ test('应该能打开公司选择器', async ({ page }) => {
|
|
|
|
|
+ const companySelect = page.getByTestId('company-search-select');
|
|
|
|
|
+ await expect(companySelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ const companyLabel = page.getByText('公司');
|
|
|
|
|
+ const hasCompanyLabel = await companyLabel.count() > 0;
|
|
|
|
|
+ console.debug(`公司标签存在: ${hasCompanyLabel}`);
|
|
|
|
|
+ expect(hasCompanyLabel).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能使用公司选择器筛选', async ({ page }) => {
|
|
|
|
|
+ const companySelect = page.getByTestId('company-search-select');
|
|
|
|
|
+ await expect(companySelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ await companySelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有选项,选择第一个
|
|
|
|
|
+ const firstOption = page.locator('[role="option"]').first();
|
|
|
|
|
+ const hasOptions = await firstOption.count() > 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (hasOptions) {
|
|
|
|
|
+ await firstOption.click();
|
|
|
|
|
+ console.debug('选择了第一个公司选项');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('渠道筛选', () => {
|
|
|
|
|
+ test('应该能打开渠道选择器', async ({ page }) => {
|
|
|
|
|
+ const channelSelect = page.getByTestId('channel-search-select');
|
|
|
|
|
+ await expect(channelSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ const channelLabel = page.getByText('渠道');
|
|
|
|
|
+ const hasChannelLabel = await channelLabel.count() > 0;
|
|
|
|
|
+ console.debug(`渠道标签存在: ${hasChannelLabel}`);
|
|
|
|
|
+ expect(hasChannelLabel).toBe(true);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能使用渠道选择器筛选', async ({ page }) => {
|
|
|
|
|
+ const channelSelect = page.getByTestId('channel-search-select');
|
|
|
|
|
+ await expect(channelSelect).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ await channelSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果有选项,选择第一个
|
|
|
|
|
+ const firstOption = page.locator('[role="option"]').first();
|
|
|
|
|
+ const hasOptions = await firstOption.count() > 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (hasOptions) {
|
|
|
|
|
+ await firstOption.click();
|
|
|
|
|
+ console.debug('选择了第一个渠道选项');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('日期范围筛选', () => {
|
|
|
|
|
+ test('应该能选择开始日期', async ({ page }) => {
|
|
|
|
|
+ const startDateInput = page.getByTestId('start-date-input');
|
|
|
|
|
+ await expect(startDateInput).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 设置开始日期
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ const startDate = today.toISOString().split('T')[0];
|
|
|
|
|
+ await startDateInput.fill(startDate);
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ // 点击搜索按钮
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能选择结束日期', async ({ page }) => {
|
|
|
|
|
+ const endDateInput = page.getByTestId('end-date-input');
|
|
|
|
|
+ await expect(endDateInput).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ const endDate = today.toISOString().split('T')[0];
|
|
|
|
|
+ await endDateInput.fill(endDate);
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ // 添加超时处理,因为日期筛选可能不触发网络请求
|
|
|
|
|
+ await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {
|
|
|
|
|
+ console.debug('日期筛选后没有网络请求,这是正常的');
|
|
|
|
|
+ });
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能选择日期范围进行筛选', async ({ page }) => {
|
|
|
|
|
+ const startDateInput = page.getByTestId('start-date-input');
|
|
|
|
|
+ const endDateInput = page.getByTestId('end-date-input');
|
|
|
|
|
+
|
|
|
|
|
+ // 设置日期范围
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ const startDate = new Date(today);
|
|
|
|
|
+ startDate.setMonth(today.getMonth() - 1);
|
|
|
|
|
+ const startDateStr = startDate.toISOString().split('T')[0];
|
|
|
|
|
+ const endDateStr = today.toISOString().split('T')[0];
|
|
|
|
|
+
|
|
|
|
|
+ await startDateInput.fill(startDateStr);
|
|
|
|
|
+ await endDateInput.fill(endDateStr);
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ // 添加超时处理
|
|
|
|
|
+ await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {
|
|
|
|
|
+ console.debug('日期范围筛选后没有网络请求,这是正常的');
|
|
|
|
|
+ });
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('重置筛选', () => {
|
|
|
|
|
+ test('应该能重置所有筛选条件', async ({ page }) => {
|
|
|
|
|
+ // 先设置一些筛选条件
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const draftOption = page.getByTestId('order-status-option-draft');
|
|
|
|
|
+ await draftOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 记录筛选后的行数
|
|
|
|
|
+ const tbody = page.locator('table tbody');
|
|
|
|
|
+ const filteredRows = tbody.locator('tr');
|
|
|
|
|
+ const filteredCount = await filteredRows.count();
|
|
|
|
|
+ console.debug(`筛选后订单列表有 ${filteredCount} 行`);
|
|
|
|
|
+
|
|
|
|
|
+ // 点击重置按钮
|
|
|
|
|
+ const resetButton = page.getByTestId('reset-button');
|
|
|
|
|
+ await expect(resetButton).toBeVisible();
|
|
|
|
|
+ await resetButton.click();
|
|
|
|
|
+ // 重置可能没有网络请求
|
|
|
|
|
+ await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {
|
|
|
|
|
+ console.debug('重置后没有网络请求,这是正常的');
|
|
|
|
|
+ });
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证表格仍然可见
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+
|
|
|
|
|
+ // 订单状态应该重置为"全部状态"
|
|
|
|
|
+ const orderStatusValue = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await expect(orderStatusValue).toContainText('全部状态');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('重置后应该显示全部订单', async ({ page }) => {
|
|
|
|
|
+ // 记录初始状态
|
|
|
|
|
+ const tbody = page.locator('table tbody');
|
|
|
|
|
+ const initialRows = tbody.locator('tr');
|
|
|
|
|
+ const initialCount = await initialRows.count();
|
|
|
|
|
+ console.debug(`初始订单列表有 ${initialCount} 行`);
|
|
|
|
|
+
|
|
|
|
|
+ // 先设置筛选条件
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const draftOption = page.getByTestId('order-status-option-draft');
|
|
|
|
|
+ await draftOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 点击重置按钮
|
|
|
|
|
+ const resetButton = page.getByTestId('reset-button');
|
|
|
|
|
+ await resetButton.click();
|
|
|
|
|
+ // 重置可能没有网络请求
|
|
|
|
|
+ await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {
|
|
|
|
|
+ console.debug('重置后没有网络请求,这是正常的');
|
|
|
|
|
+ });
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证列表仍然可见
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('组合筛选测试', () => {
|
|
|
|
|
+ test('应该能使用多个筛选条件组合', async ({ page }) => {
|
|
|
|
|
+ // 组合订单状态和工作状态筛选
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const draftOption = page.getByTestId('order-status-option-draft');
|
|
|
|
|
+ await draftOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const workStatusSelect = page.getByTestId('filter-work-status-select');
|
|
|
|
|
+ await workStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const notWorkingOption = page.getByTestId('work-status-option-not-working');
|
|
|
|
|
+ await notWorkingOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证筛选结果
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该能使用日期范围和状态组合筛选', async ({ page }) => {
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const confirmedOption = page.getByTestId('order-status-option-confirmed');
|
|
|
|
|
+ await confirmedOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const startDateInput = page.getByTestId('start-date-input');
|
|
|
|
|
+ const today = new Date();
|
|
|
|
|
+ const startDate = new Date(today);
|
|
|
|
|
+ startDate.setMonth(today.getMonth() - 1);
|
|
|
|
|
+ const startDateStr = startDate.toISOString().split('T')[0];
|
|
|
|
|
+ await startDateInput.fill(startDateStr);
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('搜索和筛选组合', () => {
|
|
|
|
|
+ test('应该能同时使用搜索和筛选', async ({ orderManagementPage, page }) => {
|
|
|
|
|
+ // 先执行搜索
|
|
|
|
|
+ await orderManagementPage.searchByName('测试');
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 再添加筛选条件
|
|
|
|
|
+ const orderStatusSelect = page.getByTestId('filter-order-status-select');
|
|
|
|
|
+ await orderStatusSelect.click();
|
|
|
|
|
+ await page.waitForTimeout(300);
|
|
|
|
|
+
|
|
|
|
|
+ const draftOption = page.getByTestId('order-status-option-draft');
|
|
|
|
|
+ await draftOption.click();
|
|
|
|
|
+
|
|
|
|
|
+ const searchButton = page.getByTestId('search-button');
|
|
|
|
|
+ await searchButton.click();
|
|
|
|
|
+ await page.waitForLoadState('networkidle');
|
|
|
|
|
+ await page.waitForTimeout(500);
|
|
|
|
|
+
|
|
|
|
|
+ // 验证结果
|
|
|
|
|
+ await expect(page.locator('table')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test.describe('筛选条件可见性验证', () => {
|
|
|
|
|
+ test('应该显示所有筛选条件', async ({ page }) => {
|
|
|
|
|
+ // 验证所有筛选输入框都存在
|
|
|
|
|
+ await expect(page.getByTestId('search-order-name-input')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('filter-order-status-select')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('filter-work-status-select')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('search-button')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('reset-button')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('platform-search-select')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('company-search-select')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('channel-search-select')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('start-date-input')).toBeVisible();
|
|
|
|
|
+ await expect(page.getByTestId('end-date-input')).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ test('应该显示正确的筛选标签', async ({ page }) => {
|
|
|
|
|
+ // 验证筛选标签正确显示(使用 locator 定位 label 元素避免与表头冲突)
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '订单名称' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '订单状态' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '工作状态' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '平台' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '公司' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '渠道' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '开始日期' })).toBeVisible();
|
|
|
|
|
+ await expect(page.locator('label').filter({ hasText: '结束日期' })).toBeVisible();
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+});
|