Port jess's projects.spec tests

This commit is contained in:
49lf
2024-12-09 14:01:15 -05:00
parent 0aeb8d1f45
commit fa493de111

View File

@ -117,26 +117,23 @@ test(
test( test(
'open a file in a project works and renders, open another file in different project with errors, it should clear the scene', 'open a file in a project works and renders, open another file in different project with errors, it should clear the scene',
{ tag: '@electron' }, { tag: '@electron' },
async ({ browserName }, testInfo) => { async ({ context, page }, testInfo) => {
const { electronApp, page } = await setupElectron({ await context.folderSetupFn((dir) => {
testInfo, const bracketDir = join(dir, 'bracket')
folderSetupFn: async (dir) => { await fsp.mkdir(bracketDir, { recursive: true })
const bracketDir = join(dir, 'bracket') await fsp.copyFile(
await fsp.mkdir(bracketDir, { recursive: true }) executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
await fsp.copyFile( join(bracketDir, 'main.kcl')
executorInputPath('focusrite_scarlett_mounting_braket.kcl'), )
join(bracketDir, 'main.kcl') const errorDir = join(dir, 'broken-code')
) await fsp.mkdir(errorDir, { recursive: true })
const errorDir = join(dir, 'broken-code') await fsp.copyFile(
await fsp.mkdir(errorDir, { recursive: true }) executorInputPath('broken-code-test.kcl'),
await fsp.copyFile( join(errorDir, 'main.kcl')
executorInputPath('broken-code-test.kcl'), )
join(errorDir, 'main.kcl')
)
},
}) })
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
const u = await getUtils(page) const u = await getUtils(page)
page.on('console', console.log) page.on('console', console.log)
@ -198,31 +195,26 @@ test(
}) })
.toBeLessThan(15) .toBeLessThan(15)
}) })
await electronApp.close()
} }
) )
test( test(
'open a file in a project works and renders, open another file in different project that is empty, it should clear the scene', 'open a file in a project works and renders, open another file in different project that is empty, it should clear the scene',
{ tag: '@electron' }, { tag: '@electron' },
async ({ browserName }, testInfo) => { async ({ context, page }, testInfo) => {
const { electronApp, page } = await setupElectron({ await context.folderSetupFn((dir) => {
testInfo, const bracketDir = join(dir, 'bracket')
folderSetupFn: async (dir) => { await fsp.mkdir(bracketDir, { recursive: true })
const bracketDir = join(dir, 'bracket') await fsp.copyFile(
await fsp.mkdir(bracketDir, { recursive: true }) executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
await fsp.copyFile( join(bracketDir, 'main.kcl')
executorInputPath('focusrite_scarlett_mounting_braket.kcl'), )
join(bracketDir, 'main.kcl') const emptyDir = join(dir, 'empty')
) await fsp.mkdir(emptyDir, { recursive: true })
const emptyDir = join(dir, 'empty') await fsp.writeFile(join(emptyDir, 'main.kcl'), '')
await fsp.mkdir(emptyDir, { recursive: true })
await fsp.writeFile(join(emptyDir, 'main.kcl'), '')
},
}) })
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
const u = await getUtils(page) const u = await getUtils(page)
page.on('console', console.log) page.on('console', console.log)
@ -280,8 +272,6 @@ test(
}) })
.toBeLessThan(15) .toBeLessThan(15)
}) })
await electronApp.close()
} }
) )
@ -289,21 +279,18 @@ test(
'open a file in a project works and renders, open empty file, it should clear the scene', 'open a file in a project works and renders, open empty file, it should clear the scene',
{ tag: '@electron' }, { tag: '@electron' },
async ({ browserName }, testInfo) => { async ({ browserName }, testInfo) => {
const { electronApp, page } = await setupElectron({ await context.folderSetupFn((dir) => {
testInfo, const bracketDir = join(dir, 'bracket')
folderSetupFn: async (dir) => { await fsp.mkdir(bracketDir, { recursive: true })
const bracketDir = join(dir, 'bracket') await fsp.copyFile(
await fsp.mkdir(bracketDir, { recursive: true }) executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
await fsp.copyFile( join(bracketDir, 'main.kcl')
executorInputPath('focusrite_scarlett_mounting_braket.kcl'), )
join(bracketDir, 'main.kcl')
)
await fsp.writeFile(join(bracketDir, 'empty.kcl'), '') await fsp.writeFile(join(bracketDir, 'empty.kcl'), '')
},
}) })
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
const u = await getUtils(page) const u = await getUtils(page)
page.on('console', console.log) page.on('console', console.log)
@ -356,8 +343,6 @@ test(
await expect(u.codeLocator).toContainText('') await expect(u.codeLocator).toContainText('')
expect(u.codeLocator.innerHTML.length).toBeLessThan(2) expect(u.codeLocator.innerHTML.length).toBeLessThan(2)
}) })
await electronApp.close()
} }
) )
@ -365,23 +350,20 @@ test(
'open a file in a project works and renders, open another file in the same project with errors, it should clear the scene', 'open a file in a project works and renders, open another file in the same project with errors, it should clear the scene',
{ tag: '@electron' }, { tag: '@electron' },
async ({ browserName }, testInfo) => { async ({ browserName }, testInfo) => {
const { electronApp, page } = await setupElectron({ await context.folderSetupFn((dir) => {
testInfo, const bracketDir = join(dir, 'bracket')
folderSetupFn: async (dir) => { await fsp.mkdir(bracketDir, { recursive: true })
const bracketDir = join(dir, 'bracket') await fsp.copyFile(
await fsp.mkdir(bracketDir, { recursive: true }) executorInputPath('focusrite_scarlett_mounting_braket.kcl'),
await fsp.copyFile( join(bracketDir, 'main.kcl')
executorInputPath('focusrite_scarlett_mounting_braket.kcl'), )
join(bracketDir, 'main.kcl') await fsp.copyFile(
) executorInputPath('broken-code-test.kcl'),
await fsp.copyFile( join(bracketDir, 'broken-code-test.kcl')
executorInputPath('broken-code-test.kcl'), )
join(bracketDir, 'broken-code-test.kcl')
)
},
}) })
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
const u = await getUtils(page) const u = await getUtils(page)
page.on('console', console.log) page.on('console', console.log)
@ -438,8 +420,6 @@ test(
}) })
.toBeLessThan(15) .toBeLessThan(15)
}) })
await electronApp.close()
} }
) )