Skip to content

Commit

Permalink
Add a back-off
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Oct 8, 2024
1 parent 7c62042 commit 574dd42
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions frontend/test/playwright/e2e/preferences.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,19 @@ const toggleChecked = async (
// The knob's color is `bg-default` when off and `bg-tertiary` when on.
await page.evaluate(
async ([name, className]) => {
const knobClasses = document
.querySelector(`${name}`)
?.parentElement?.querySelector("span")?.className
const getKnobClasses = () => {
return (
document
.getElementById(`#${name}`)
?.parentElement?.querySelector("span")?.className ?? ""
)
}

if (!knobClasses?.includes(className)) {
setTimeout(() => {}, 200)
for (const waitTime of [100, 200, 500]) {
if (getKnobClasses().includes(className)) {
return
}
await new Promise((resolve) => setTimeout(resolve, waitTime))
}
},
[name, !originalChecked ? "bg-tertiary" : "bg-default"] as const
Expand Down

0 comments on commit 574dd42

Please sign in to comment.