Trying to fix tests

This commit is contained in:
49lf
2024-09-24 11:31:13 -04:00
parent 2bb372de12
commit d71f2af9bd
7 changed files with 64 additions and 44 deletions

View File

@ -715,31 +715,19 @@ extrude001 = extrude(5, sketch001)
`
)
})
const viewport = { width: 1200, height: 500 }
await page.setViewportSize(viewport)
await page.setViewportSize({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart()
const getMiddleOfModelingArea = async (viewport) => {
const panes = page.getByTestId('pane-section')
const bb = await panes.boundingBox()
const goRightPx = bb.width > 0 ? (viewport.width - bb.width) / 2 : 0
return {
x: viewport.width / 2 + goRightPx,
y: viewport.height / 2,
}
}
// Selectors and constants
const editSketchButton = page.getByRole('button', { name: 'Edit Sketch' })
const lineToolButton = page.getByTestId('line')
const segmentOverlays = page.getByTestId('segment-overlay')
const sketchOriginLocation = await getMiddleOfModelingArea(viewport)
const sketchOriginLocation = await u.getCenterOfModelViewArea()
const darkThemeSegmentColor: [number, number, number] = [215, 215, 215]
const lightThemeSegmentColor: [number, number, number] = [90, 90, 90]
await test.step(`Get into sketch mode`, async () => {
const aLineToClickOn = await u.getBoundingBox('[data-overlay-index="0"]')
await page.mouse.move(aLineToClickOn.x, aLineToClickOn.y)
await page.mouse.click(sketchOriginLocation.x, sketchOriginLocation.y)
await expect(editSketchButton).toBeVisible()
await editSketchButton.click()
@ -751,12 +739,20 @@ extrude001 = extrude(5, sketch001)
await page.waitForTimeout(1000)
})
const line1 = await u.getSegmentBodyCoords(`[data-overlay-index="${0}"]`, 0)
// Our lines are translucent (surprise!), so we need to get on portion
// of the line that is only on the background, and not on top of something
// like the axis lines.
line1.x -= 1
line1.y -= 1
await test.step(`Check the sketch line color before`, async () => {
await expect
.poll(() =>
u.getGreatestPixDiff(sketchOriginLocation, darkThemeSegmentColor)
u.getGreatestPixDiff(line1, darkThemeSegmentColor)
)
.toBeLessThan(15)
.toBeLessThanOrEqual(34)
})
await test.step(`Change theme to light using command palette`, async () => {
@ -772,9 +768,9 @@ extrude001 = extrude(5, sketch001)
await test.step(`Check the sketch line color after`, async () => {
await expect
.poll(() =>
u.getGreatestPixDiff(sketchOriginLocation, lightThemeSegmentColor)
u.getGreatestPixDiff(line1, lightThemeSegmentColor)
)
.toBeLessThan(15)
.toBeLessThanOrEqual(34)
})
})