Flaky tests and observable state (#1526)

* Fix missing await

* Fix flaky tests - keyboard combos

Old code is causing playwright &/ changeTracker to add an undo step.  Using combo mode resolves flakiness until that can be investigated thoroughly.

* Restore skipped tests

* Fix flaky tests

* Async clean up

* Fix test always fails on retry

* Add TS types (tests)

* Fix flaky test

* Add observable busy state to workflow store

* Add workflow store busy wait to tests

* Rename test for clarity

* Fix flaky tests - use press() from locator API

Ref: https://playwright.dev/docs/api/class-keyboard#keyboard-press

* Fix flaky test - wait next frame

* Add delay between mouse events

Litegraph pointer handling is all custom coded, so a adding a delay between events for a bit of reality is actually beneficial.
This commit is contained in:
filtered
2024-11-14 01:35:22 +11:00
committed by GitHub
parent ddab149f16
commit 7e0d1d441d
10 changed files with 140 additions and 98 deletions

View File

@@ -284,32 +284,45 @@ export const useWorkflowStore = defineStore('workflow', () => {
workflows.value.filter((workflow) => workflow.isModified)
)
/** A filesystem operation is currently in progress (e.g. save, rename, delete) */
const isBusy = ref<boolean>(false)
const renameWorkflow = async (workflow: ComfyWorkflow, newPath: string) => {
// Capture all needed values upfront
const oldPath = workflow.path
const wasBookmarked = bookmarkStore.isBookmarked(oldPath)
const openIndex = detachWorkflow(workflow)
// Perform the actual rename operation first
isBusy.value = true
try {
await workflow.rename(newPath)
} finally {
attachWorkflow(workflow, openIndex)
}
// Capture all needed values upfront
const oldPath = workflow.path
const wasBookmarked = bookmarkStore.isBookmarked(oldPath)
// Update bookmarks
if (wasBookmarked) {
bookmarkStore.setBookmarked(oldPath, false)
bookmarkStore.setBookmarked(newPath, true)
const openIndex = detachWorkflow(workflow)
// Perform the actual rename operation first
try {
await workflow.rename(newPath)
} finally {
attachWorkflow(workflow, openIndex)
}
// Update bookmarks
if (wasBookmarked) {
bookmarkStore.setBookmarked(oldPath, false)
bookmarkStore.setBookmarked(newPath, true)
}
} finally {
isBusy.value = false
}
}
const deleteWorkflow = async (workflow: ComfyWorkflow) => {
await workflow.delete()
if (bookmarkStore.isBookmarked(workflow.path)) {
bookmarkStore.setBookmarked(workflow.path, false)
isBusy.value = true
try {
await workflow.delete()
if (bookmarkStore.isBookmarked(workflow.path)) {
bookmarkStore.setBookmarked(workflow.path, false)
}
delete workflowLookup.value[workflow.path]
} finally {
isBusy.value = false
}
delete workflowLookup.value[workflow.path]
}
/**
@@ -317,12 +330,17 @@ export const useWorkflowStore = defineStore('workflow', () => {
* @param workflow The workflow to save.
*/
const saveWorkflow = async (workflow: ComfyWorkflow) => {
// Detach the workflow and re-attach to force refresh the tree objects.
const openIndex = detachWorkflow(workflow)
isBusy.value = true
try {
await workflow.save()
// Detach the workflow and re-attach to force refresh the tree objects.
const openIndex = detachWorkflow(workflow)
try {
await workflow.save()
} finally {
attachWorkflow(workflow, openIndex)
}
} finally {
attachWorkflow(workflow, openIndex)
isBusy.value = false
}
}
@@ -333,6 +351,7 @@ export const useWorkflowStore = defineStore('workflow', () => {
openedWorkflowIndexShift,
openWorkflow,
isOpen,
isBusy,
closeWorkflow,
createTemporary,
renameWorkflow,