mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-19 20:09:42 +00:00
*PR Created by the Glary-Bot Agent* --- ## Summary Deleting a workflow in the sidebar while search is active left the deleted workflow visible in the search results. Interacting with the stale entry (e.g. duplicate) caused undefined behavior. ## Root Cause `filteredWorkflows` in `BaseWorkflowsSidebarTab.vue` was a `ref` populated once per search event — a static snapshot that never reacted to store mutations. When `workflowStore.deleteWorkflow()` removed a workflow from `workflowLookup`, the search-panel's `filteredWorkflows` still held a stale reference. ## Fix Convert `filteredWorkflows` from a `ref` to a `computed` that reactively derives from `searchQuery` and `workflowStore.workflows`. This follows the same pattern already used by `filteredPersistedWorkflows` and `filteredBookmarkedWorkflows` in the same component. `handleSearch` is simplified to only manage tree expansion (its only remaining side effect). ## Test Plan Three e2e regression tests added to `workflowSearch.spec.ts`: - **Delete during search removes from results** — deletes a workflow while search is active, asserts it disappears - **Delete during search preserves siblings** — asserts all other matched workflows remain visible after one is deleted - **Clear search after delete shows correct browse view** — deletes during search, clears search, verifies browse view is consistent ## Screenshots   ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-11425-fix-remove-deleted-workflow-from-search-results-in-sidebar-3476d73d365081f19ef6c6b9261a1ee9) by [Unito](https://www.unito.io) --------- Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com>
121 lines
4.3 KiB
TypeScript
121 lines
4.3 KiB
TypeScript
import type { Page } from '@playwright/test'
|
|
import { expect } from '@playwright/test'
|
|
|
|
import { comfyPageFixture as test } from '@e2e/fixtures/ComfyPage'
|
|
import { TestIds } from '@e2e/fixtures/selectors'
|
|
|
|
/** Locate a workflow label in whatever panel is visible (browse or search). */
|
|
function findWorkflow(page: Page, name: string) {
|
|
return page
|
|
.getByTestId(TestIds.sidebar.workflows)
|
|
.locator('.node-label', { hasText: name })
|
|
}
|
|
|
|
test.describe('Workflow sidebar - search', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.workflow.setupWorkflowsDirectory({
|
|
'alpha-workflow.json': 'default.json',
|
|
'beta-workflow.json': 'default.json'
|
|
})
|
|
await comfyPage.menu.workflowsTab.open()
|
|
})
|
|
|
|
test('Search filters saved workflows by name', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('alpha')
|
|
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeVisible()
|
|
await expect(findWorkflow(comfyPage.page, 'beta-workflow')).toBeHidden()
|
|
})
|
|
|
|
test('Clearing search restores all workflows', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('alpha')
|
|
await expect(findWorkflow(comfyPage.page, 'beta-workflow')).toBeHidden()
|
|
|
|
await tab.searchInput.fill('')
|
|
|
|
await expect(tab.getPersistedItem('alpha-workflow')).toBeVisible()
|
|
await expect(tab.getPersistedItem('beta-workflow')).toBeVisible()
|
|
})
|
|
|
|
test('Search with no matches shows empty results', async ({ comfyPage }) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('nonexistent_xyz')
|
|
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeHidden()
|
|
await expect(findWorkflow(comfyPage.page, 'beta-workflow')).toBeHidden()
|
|
})
|
|
|
|
test.describe('deletion', () => {
|
|
test.beforeEach(async ({ comfyPage }) => {
|
|
await comfyPage.workflow.setupWorkflowsDirectory({
|
|
'alpha-workflow.json': 'default.json',
|
|
'beta-workflow.json': 'default.json',
|
|
'gamma-workflow.json': 'default.json'
|
|
})
|
|
await comfyPage.settings.setSetting('Comfy.Workflow.ConfirmDelete', false)
|
|
await comfyPage.menu.workflowsTab.open()
|
|
})
|
|
|
|
test('Deleting a workflow while search is active removes it from results', async ({
|
|
comfyPage
|
|
}) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('alpha')
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeVisible()
|
|
|
|
await findWorkflow(comfyPage.page, 'alpha-workflow').click({
|
|
button: 'right'
|
|
})
|
|
await comfyPage.contextMenu.clickMenuItem('Delete')
|
|
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeHidden()
|
|
})
|
|
|
|
test('Deleting during search does not affect other matched results', async ({
|
|
comfyPage
|
|
}) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('workflow')
|
|
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeVisible()
|
|
await expect(findWorkflow(comfyPage.page, 'beta-workflow')).toBeVisible()
|
|
await expect(findWorkflow(comfyPage.page, 'gamma-workflow')).toBeVisible()
|
|
|
|
await findWorkflow(comfyPage.page, 'alpha-workflow').click({
|
|
button: 'right'
|
|
})
|
|
await comfyPage.contextMenu.clickMenuItem('Delete')
|
|
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeHidden()
|
|
await expect(findWorkflow(comfyPage.page, 'beta-workflow')).toBeVisible()
|
|
await expect(findWorkflow(comfyPage.page, 'gamma-workflow')).toBeVisible()
|
|
})
|
|
|
|
test('Clearing search after deleting during search shows correct workflows', async ({
|
|
comfyPage
|
|
}) => {
|
|
const tab = comfyPage.menu.workflowsTab
|
|
|
|
await tab.searchInput.fill('alpha')
|
|
await expect(findWorkflow(comfyPage.page, 'alpha-workflow')).toBeVisible()
|
|
|
|
await findWorkflow(comfyPage.page, 'alpha-workflow').click({
|
|
button: 'right'
|
|
})
|
|
await comfyPage.contextMenu.clickMenuItem('Delete')
|
|
|
|
await tab.searchInput.fill('')
|
|
await expect(tab.getPersistedItem('beta-workflow')).toBeVisible()
|
|
await expect(tab.getPersistedItem('gamma-workflow')).toBeVisible()
|
|
await expect(tab.getPersistedItem('alpha-workflow')).toBeHidden()
|
|
})
|
|
})
|
|
})
|