Skip prompt-to-edit playwright tests on windows (#5290)

* Skip prompt-to-edit playwright tests on windows

* Fix lint

* Fix test hookk

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Clear bad snapshots

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Pierre Jacquier
2025-02-06 09:45:12 -05:00
committed by GitHub
parent 11cac0c30e
commit e0de0493ab

View File

@ -35,106 +35,108 @@ sketch003 = startSketchOn('XY')
extrude003 = extrude(sketch003, length = 20) extrude003 = extrude(sketch003, length = 20)
` `
test.describe('Check the happy path, for basic changing color', () => { test.describe('Prompt-to-edit tests', { tag: '@skipWin' }, () => {
const cases = [ test.describe('Check the happy path, for basic changing color', () => {
{ const cases = [
desc: 'User accepts change', {
shouldReject: false, desc: 'User accepts change',
}, shouldReject: false,
{ },
desc: 'User rejects change', {
shouldReject: true, desc: 'User rejects change',
}, shouldReject: true,
] as const },
for (const { desc, shouldReject } of cases) { ] as const
test(`${desc}`, async ({ for (const { desc, shouldReject } of cases) {
context, test(`${desc}`, async ({
homePage, context,
cmdBar, homePage,
editor, cmdBar,
page, editor,
scene, page,
}) => { scene,
await context.addInitScript((file) => { }) => {
localStorage.setItem('persistCode', file) await context.addInitScript((file) => {
}, file) localStorage.setItem('persistCode', file)
await homePage.goToModelingScene() }, file)
await homePage.goToModelingScene()
const body1CapCoords = { x: 571, y: 351 } const body1CapCoords = { x: 571, y: 351 }
const greenCheckCoords = { x: 565, y: 345 } const greenCheckCoords = { x: 565, y: 345 }
const body2WallCoords = { x: 609, y: 153 } const body2WallCoords = { x: 609, y: 153 }
const [clickBody1Cap] = scene.makeMouseHelpers( const [clickBody1Cap] = scene.makeMouseHelpers(
body1CapCoords.x, body1CapCoords.x,
body1CapCoords.y body1CapCoords.y
) )
const yellow: [number, number, number] = [179, 179, 131] const yellow: [number, number, number] = [179, 179, 131]
const green: [number, number, number] = [108, 152, 75] const green: [number, number, number] = [108, 152, 75]
const notGreen: [number, number, number] = [132, 132, 132] const notGreen: [number, number, number] = [132, 132, 132]
const body2NotGreen: [number, number, number] = [88, 88, 88] const body2NotGreen: [number, number, number] = [88, 88, 88]
const submittingToast = page.getByText('Submitting to Text-to-CAD API...') const submittingToast = page.getByText(
const successToast = page.getByText('Prompt to edit successful') 'Submitting to Text-to-CAD API...'
const acceptBtn = page.getByRole('button', { name: 'checkmark Accept' }) )
const rejectBtn = page.getByRole('button', { name: 'close Reject' }) const successToast = page.getByText('Prompt to edit successful')
const acceptBtn = page.getByRole('button', { name: 'checkmark Accept' })
const rejectBtn = page.getByRole('button', { name: 'close Reject' })
await test.step('wait for scene to load select body and check selection came through', async () => { await test.step('wait for scene to load select body and check selection came through', async () => {
await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15) await scene.expectPixelColor([134, 134, 134], body1CapCoords, 15)
await clickBody1Cap() await clickBody1Cap()
await scene.expectPixelColor(yellow, body1CapCoords, 20) await scene.expectPixelColor(yellow, body1CapCoords, 20)
await editor.expectState({ await editor.expectState({
highlightedCode: '', highlightedCode: '',
activeLines: ['|>startProfileAt([-73.64,-42.89],%)'], activeLines: ['|>startProfileAt([-73.64,-42.89],%)'],
diagnostics: [], diagnostics: [],
})
}) })
})
await test.step('fire off edit prompt', async () => { await test.step('fire off edit prompt', async () => {
await cmdBar.openCmdBar('promptToEdit') await cmdBar.openCmdBar('promptToEdit')
// being specific about the color with a hex means asserting pixel color is more stable // being specific about the color with a hex means asserting pixel color is more stable
await page await page
.getByTestId('cmd-bar-arg-value') .getByTestId('cmd-bar-arg-value')
.fill('make this neon green please, use #39FF14') .fill('make this neon green please, use #39FF14')
await page.waitForTimeout(100) await page.waitForTimeout(100)
await cmdBar.progressCmdBar() await cmdBar.progressCmdBar()
await expect(submittingToast).toBeVisible() await expect(submittingToast).toBeVisible()
await expect(submittingToast).not.toBeVisible({ timeout: 2 * 60_000 }) // can take a while await expect(submittingToast).not.toBeVisible({ timeout: 2 * 60_000 }) // can take a while
await expect(successToast).toBeVisible() await expect(successToast).toBeVisible()
}) })
await test.step('verify initial change', async () => {
await scene.expectPixelColor(green, greenCheckCoords, 15)
await scene.expectPixelColor(body2NotGreen, body2WallCoords, 15)
await editor.expectEditor.toContain('appearance({')
})
if (!shouldReject) {
await test.step('check accept works and can be "undo"ed', async () => {
await acceptBtn.click()
await expect(successToast).not.toBeVisible()
await test.step('verify initial change', async () => {
await scene.expectPixelColor(green, greenCheckCoords, 15) await scene.expectPixelColor(green, greenCheckCoords, 15)
await scene.expectPixelColor(body2NotGreen, body2WallCoords, 15)
await editor.expectEditor.toContain('appearance({') await editor.expectEditor.toContain('appearance({')
// ctrl-z works after accepting
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await editor.expectEditor.not.toContain('appearance({')
await scene.expectPixelColor(notGreen, greenCheckCoords, 15)
}) })
} else {
await test.step('check reject works', async () => {
await rejectBtn.click()
await expect(successToast).not.toBeVisible()
await scene.expectPixelColor(notGreen, greenCheckCoords, 15) if (!shouldReject) {
await editor.expectEditor.not.toContain('appearance({') await test.step('check accept works and can be "undo"ed', async () => {
}) await acceptBtn.click()
} await expect(successToast).not.toBeVisible()
})
} await scene.expectPixelColor(green, greenCheckCoords, 15)
}) await editor.expectEditor.toContain('appearance({')
// ctrl-z works after accepting
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up('ControlOrMeta')
await editor.expectEditor.not.toContain('appearance({')
await scene.expectPixelColor(notGreen, greenCheckCoords, 15)
})
} else {
await test.step('check reject works', async () => {
await rejectBtn.click()
await expect(successToast).not.toBeVisible()
await scene.expectPixelColor(notGreen, greenCheckCoords, 15)
await editor.expectEditor.not.toContain('appearance({')
})
}
})
}
})
test.describe('bad path', { tag: ['@skipWin'] }, () => {
test(`bad edit prompt`, async ({ test(`bad edit prompt`, async ({
context, context,
homePage, homePage,