Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 18 additions & 49 deletions .playwright/scripts/__tests__/task-archive.e2e.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ test('active task deletion requires confirmation and permanently removes only ta
await capture(page, testInfo, 'active-task-deleted')
})

test('official legacy cleanup plugin requires host confirmation and preserves external files', async ({ buddy }, testInfo) => {
test('official legacy cleanup plugin owns confirmation and preserves external files', async ({ buddy }, testInfo) => {
test.skip(!process.env.LEXORA_TEST_LEGACY_CLEANUP_ARCHIVE, 'Provide the separately built legacy cleanup plugin archive')
test.setTimeout(180000)
const instance = await buddy.createInstance('legacy-task-cleanup')
Expand All @@ -186,7 +186,7 @@ test('official legacy cleanup plugin requires host confirmation and preserves ex
await card.getByTestId('extension-card-more').click()
await page.getByTestId('extension-actions').hover()
const action = page.locator(`[data-extension-action="${pluginId}.action"]`)
await expect(action).toHaveText('清理旧版任务…')
await expect(action).toHaveText('清理任务残留…')
await action.click()
}
const pluginFrame = async () => {
Expand All @@ -211,13 +211,13 @@ test('official legacy cleanup plugin requires host confirmation and preserves ex
const lifecycleWindow = await app.browserWindow(page)
await lifecycleWindow.evaluate(window => window.focus())
await runCleanup()
const confirmation = page.getByTestId('extension-task-cleanup-dialog')
await expect(confirmation).toBeVisible()
await expect(confirmation.getByTestId('extension-task-cleanup-scope')).toContainText('32')
await expect(confirmation).toContainText('删除后无法恢复')
await expect(confirmation).toContainText('不处理活动或已归档任务')
await expect(confirmation).toContainText('不影响用户工作区及外部文件')
let frame = await pluginFrame()
const confirmation = () => frame.getByTestId('cleanup-preview')
await expect(confirmation()).toBeVisible()
await expect(frame.getByTestId('cleanup-preview-total')).toHaveText('32')
await expect(confirmation()).toContainText('不可恢复')
await expect(confirmation()).toContainText('不处理活动或已归档任务')
await expect(confirmation()).toContainText('不删除用户工作区及外部文件')
await expect(frame.getByTestId('legacy-task-cleanup-panel')).toHaveAttribute('data-phase', 'confirming')
for (const appearance of ['light', 'dark']) {
await page.evaluate(() => window.lexoraDesktop.themes.request({ action: 'preference', preference: { id: 'system' } }))
Expand All @@ -231,31 +231,30 @@ test('official legacy cleanup plugin requires host confirmation and preserves ex
const originalBounds = await lifecycleWindow.evaluate(window => window.getBounds())
await lifecycleWindow.evaluate(window => window.setBounds({ width: 980, height: 640 }))
await expect.poll(() => page.evaluate(() => window.innerWidth)).toBe(980)
await expect(confirmation.getByRole('button', { name: '删除', exact: true })).toBeInViewport()
await expect(frame.getByTestId('cleanup-confirm-delete')).toBeInViewport()
await capture(page, testInfo, 'legacy-cleanup-confirm-minimum')
await lifecycleWindow.evaluate((window, bounds) => window.setBounds(bounds), originalBounds)
await confirmation.getByRole('button', { name: '取消', exact: true }).click()
await expect(confirmation).toBeHidden()
await frame.getByTestId('cleanup-cancel').click()
await expect(confirmation()).toBeHidden()
await expect(frame.getByTestId('legacy-task-cleanup-panel')).toHaveAttribute('data-phase', 'cancelled')
expect(await taskExists(app, fixture.databasePath, 'archive-legacy')).toBe(true)
expect(await fs.readFile(path.join(fixture.owned, 'owned.txt'), 'utf8')).toBe('Task-owned fixture')
await frame.getByRole('button', { name: '关闭', exact: true }).click()
await runCleanup()
await expect(confirmation).toBeVisible()
frame = await pluginFrame()
await expect(confirmation()).toBeVisible()
await lifecycleWindow.evaluate(window => window.hide())
await expect.poll(() => page.evaluate(() => window.lexoraDesktop.extensions.taskCleanupConfirmations())).toEqual([])
await expect(frame.getByTestId('legacy-task-cleanup-panel')).toHaveAttribute('data-phase', 'cancelled')
await lifecycleWindow.evaluate((window) => {
window.show()
window.focus()
})
await expect(confirmation).toBeHidden()
frame = await pluginFrame()
await expect(frame.getByTestId('legacy-task-cleanup-panel')).toHaveAttribute('data-phase', 'cancelled')
await expect(confirmation()).toBeHidden()
expect(await taskExists(app, fixture.databasePath, 'archive-legacy')).toBe(true)
await frame.getByRole('button', { name: '关闭', exact: true }).click()
await runCleanup()
await expect(confirmation).toBeVisible()
frame = await pluginFrame()
await expect(confirmation()).toBeVisible()
await frame.evaluate(() => {
window.cleanupProgressSnapshots = []
const panel = document.querySelector('[data-testid="legacy-task-cleanup-panel"]')
Expand All @@ -264,8 +263,8 @@ test('official legacy cleanup plugin requires host confirmation and preserves ex
window.cleanupProgressSnapshots.push(Number(panel.querySelector('[data-testid="cleanup-processed"]').textContent))
}).observe(panel, { subtree: true, attributes: true, childList: true, characterData: true })
})
await confirmation.getByRole('button', { name: '删除', exact: true }).click()
await expect(confirmation).toBeHidden()
await frame.getByTestId('cleanup-confirm-delete').click()
await expect(confirmation()).toBeHidden()
await expect(frame.getByTestId('legacy-task-cleanup-panel')).toHaveAttribute('data-phase', 'running')
await expect.poll(() => frame.evaluate(() => window.cleanupProgressSnapshots.some(count => count > 0 && count < 32))).toBe(true)
await capture(page, testInfo, 'legacy-cleanup-plugin-progress')
Expand Down Expand Up @@ -316,33 +315,3 @@ test('official legacy cleanup plugin requires host confirmation and preserves ex
await card.getByTestId('extension-card-more').click()
await expect(page.getByTestId('extension-actions')).toHaveCount(0)
})

test('legacy cleanup 1.0.1 remains compatible with host-only safety confirmation', async ({ buddy }, testInfo) => {
test.skip(!process.env.LEXORA_TEST_LEGACY_CLEANUP_COMPAT_ARCHIVE, 'Provide the original 1.0.1 package')
const instance = await buddy.createInstance('legacy-cleanup-compatibility')
const fixture = await prepareTaskArchiveProfile(instance.home, testInfo.outputPath('profile-preparation'))
const { app, page } = await launchArchiveInstance(instance)
await page.locator('.desktop-app-sidebar').getByRole('button', { name: '插件', exact: true }).click()
await app.evaluate(({ dialog }, archive) => {
dialog.showOpenDialog = async () => ({ canceled: false, filePaths: [archive] })
}, process.env.LEXORA_TEST_LEGACY_CLEANUP_COMPAT_ARCHIVE)
await page.getByTestId('extension-install-options').click()
await page.getByTestId('extension-install').click()
await page.getByTestId('extension-install-review').getByTestId('extension-confirm-install').click()
const card = page.locator(`article[data-extension-id="${pluginId}"]`)
await expect(card).toContainText('1.0.1')
await expect.poll(() => page.evaluate(async id => (await window.lexoraDesktop.extensions.list()).find(item => item.manifest.id === id)?.state, pluginId)).toBe('active')
await card.getByTestId('extension-card-more').click()
await page.getByTestId('extension-actions').hover()
await page.locator(`[data-extension-action="${pluginId}.action"]`).click()
const confirmation = page.getByTestId('extension-task-cleanup-dialog')
await expect(confirmation.getByTestId('extension-task-cleanup-scope')).toContainText('1')
expect(await taskExists(app, fixture.databasePath, 'archive-legacy')).toBe(true)
await confirmation.getByRole('button', { name: '删除', exact: true }).click()
await expect(confirmation).toBeHidden()
await expect.poll(() => taskExists(app, fixture.databasePath, 'archive-legacy')).toBe(false)
await expect.poll(() => fs.access(fixture.owned).then(() => true, () => false)).toBe(false)
expect(await fs.readFile(path.join(fixture.external, 'keep.txt'), 'utf8')).toBe('External fixture must survive')
expect(await taskExists(app, fixture.databasePath, 'archive-active')).toBe(true)
await expectStorage(app, fixture.databasePath)
})
38 changes: 0 additions & 38 deletions apps/buddy/electron/main/extensions/ExtensionTaskCleanup.ts

This file was deleted.

This file was deleted.

Loading
Loading