Skip to content

Commit

Permalink
Add some more delay
Browse files Browse the repository at this point in the history
To avoid flaky tests in CI.
  • Loading branch information
afcapel committed Sep 22, 2022
1 parent 8f7f9fe commit 15d5595
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/test/system/custom_element_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,27 +345,24 @@ testGroup("Custom element API", { template: "editor_empty" }, () => {
element.addEventListener("trix-blur", () => blurEventCount++)

triggerEvent(element, "blur")
await nextFrame()
await delay(10)

assert.equal(blurEventCount, 1)
assert.equal(focusEventCount, 0)

triggerEvent(element, "focus")

await nextFrame()
await delay(10)

assert.equal(blurEventCount, 1)
assert.equal(focusEventCount, 1)

insertImageAttachment()

await delay(20)

await clickElement(element.querySelector("figure"))

const textarea = element.querySelector("textarea")
textarea.focus()

await nextFrame()

assert.equal(document.activeElement, textarea)
Expand Down
4 changes: 2 additions & 2 deletions src/test/test_helpers/toolbar_helpers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { triggerEvent } from "./event_helpers"
import { selectionChangeObserver } from "trix/observers/selection_change_observer"
import { nextFrame } from "./timing_helpers"
import { delay, nextFrame } from "./timing_helpers"

export const clickToolbarButton = async (selector) => {
selectionChangeObserver.update()
const button = getToolbarButton(selector)
triggerEvent(button, "mousedown")
await nextFrame()
await delay(5)
}

export const typeToolbarKeyCommand = async (selector) => {
Expand Down

0 comments on commit 15d5595

Please sign in to comment.