Sketch mode more tolerant to syntax errors (#4056)

* add fix

* add test

* typos

* clean up
This commit is contained in:
Kurt Hutten
2024-10-02 13:15:40 +10:00
committed by GitHub
parent cd91774881
commit 47e472e984
7 changed files with 134 additions and 31 deletions

View File

@ -4,6 +4,7 @@ import { uuidv4 } from 'lib/utils'
import {
closeDebugPanel,
doAndWaitForImageDiff,
getPixelRGBs,
openAndClearDebugPanel,
sendCustomCmd,
} from '../test-utils'
@ -89,4 +90,28 @@ export class SceneFixture {
waitForExecutionDone = async () => {
await expect(this.exeIndicator).toBeVisible()
}
expectPixelColor = async (
colour: [number, number, number],
coords: { x: number; y: number },
diff: number
) => {
let finalValue = colour
await expect
.poll(async () => {
const pixel = (await getPixelRGBs(this.page)(coords, 1))[0]
if (!pixel) return null
finalValue = pixel
return pixel.every(
(channel, index) => Math.abs(channel - colour[index]) < diff
)
})
.toBeTruthy()
.catch((cause) => {
throw new Error(
`ExpectPixelColor: expecting ${colour} got ${finalValue}`,
{ cause }
)
})
}
}