Files
PathEditor/e2e/tests/search-clean.spec.ts
T
Serendipity bce2dc8641 fix: E2E mock 统一 + CSV 引号字段解析
E2E:
- createIpcMock 支持 overrides 参数,保持 default: throw 行为
- search-clean.spec.ts 删除 30 行内联 mock,改用 createIpcMock(overrides)

Rust:
- 新增 parse_csv_line: 支持引号包裹字段 + 双引号转义 (RFC 4180 子集)
- import_csv 改用 parse_csv_line 替代 split(',')
- 与 TS 端 parseCsvLine 逻辑对称

测试: Rust 48 → 52 (+4), Frontend 100

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 23:51:28 +08:00

36 lines
1.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { createIpcMock } from '../mocks/ipc';
test.beforeEach(async ({ page }) => {
await page.addInitScript(createIpcMock({
load_system_paths: ['C:\\Windows', 'invalid_path', 'C:\\Temp'],
load_user_paths: [],
validate_path: false,
}));
await page.goto('/');
});
test('搜索过滤后清理无效路径', async ({ page }) => {
// 初始 3 条路径
await page.waitForTimeout(500);
await expect(page.locator('table tbody tr')).toHaveCount(3);
// 搜索 "Windows"
const searchInput = page.locator('input[placeholder]');
await searchInput.fill('Windows');
await page.waitForTimeout(300);
await expect(page.locator('table tbody tr')).toHaveCount(1);
// 清除搜索
await searchInput.fill('');
await page.waitForTimeout(300);
await expect(page.locator('table tbody tr')).toHaveCount(3);
// 点击"一键清理"按钮
await page.click('text=一键清理');
await page.waitForTimeout(300);
// is_valid_path_format 只校验格式,不检查存在性
// "invalid_path" 格式无效被移除,C:\Windows 和 C:\Temp 格式有效保留
await expect(page.locator('table tbody tr')).toHaveCount(2);
});