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,10 +117,8 @@ 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,
folderSetupFn: async (dir) => {
const bracketDir = join(dir, 'bracket') const bracketDir = join(dir, 'bracket')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
await fsp.copyFile( await fsp.copyFile(
@ -133,10 +131,9 @@ test(
executorInputPath('broken-code-test.kcl'), executorInputPath('broken-code-test.kcl'),
join(errorDir, 'main.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,18 +195,14 @@ 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,
folderSetupFn: async (dir) => {
const bracketDir = join(dir, 'bracket') const bracketDir = join(dir, 'bracket')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
await fsp.copyFile( await fsp.copyFile(
@ -219,10 +212,9 @@ test(
const emptyDir = join(dir, 'empty') const emptyDir = join(dir, 'empty')
await fsp.mkdir(emptyDir, { recursive: true }) await fsp.mkdir(emptyDir, { recursive: true })
await fsp.writeFile(join(emptyDir, 'main.kcl'), '') 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,9 +279,7 @@ 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,
folderSetupFn: async (dir) => {
const bracketDir = join(dir, 'bracket') const bracketDir = join(dir, 'bracket')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
await fsp.copyFile( await fsp.copyFile(
@ -300,10 +288,9 @@ test(
) )
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,9 +350,7 @@ 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,
folderSetupFn: async (dir) => {
const bracketDir = join(dir, 'bracket') const bracketDir = join(dir, 'bracket')
await fsp.mkdir(bracketDir, { recursive: true }) await fsp.mkdir(bracketDir, { recursive: true })
await fsp.copyFile( await fsp.copyFile(
@ -378,10 +361,9 @@ test(
executorInputPath('broken-code-test.kcl'), executorInputPath('broken-code-test.kcl'),
join(bracketDir, '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()
} }
) )