fix(frontend): 切换目录时只保留一次虚拟环境状态
切换目录时先同步清掉旧目录自动填入的 venv;实时 venv 为空时立即忽略防抖旧值;旧查询结果不再回填新目录;补充 Playwright 回归用例。
This commit is contained in:
@@ -204,6 +204,33 @@ test('switches script language and adapts the form fields', async ({ page }) =>
|
||||
await dialog.getByRole('button', { name: '取消' }).click()
|
||||
})
|
||||
|
||||
test('avoids a transient invalid venv when switching directories', async ({
|
||||
page,
|
||||
}) => {
|
||||
const venvDir = createVenvFixture()
|
||||
const emptyProject = join(venvDir, '..', 'empty-project')
|
||||
mkdirSync(emptyProject, { recursive: true })
|
||||
|
||||
await page.goto('/')
|
||||
await page.getByRole('button', { name: '+ 新建任务' }).click()
|
||||
const dialog = page.getByRole('dialog', { name: '新建定时任务' })
|
||||
const workingDir = dialog.getByLabel(/项目工作目录/)
|
||||
const bar = dialog.locator('.env-detector-bar')
|
||||
|
||||
await workingDir.fill(venvDir)
|
||||
await expect(bar).toContainText('已关联虚拟环境')
|
||||
|
||||
await workingDir.fill(emptyProject)
|
||||
const states = new Set<string>()
|
||||
for (let index = 0; index < 30; index += 1) {
|
||||
states.add(await bar.innerText())
|
||||
await page.waitForTimeout(80)
|
||||
}
|
||||
|
||||
expect([...states].some((text) => text.includes('缺少'))).toBe(false)
|
||||
await expect(bar).toContainText('未检测到虚拟环境')
|
||||
})
|
||||
|
||||
test('keeps the dashboard usable on a narrow viewport', async ({
|
||||
page,
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user