Pass onboarding tests

This commit is contained in:
49lf
2024-11-27 11:22:36 -05:00
parent f061a9a15f
commit b3cc43ae2f
6 changed files with 1564 additions and 1500 deletions

View File

@ -26,7 +26,6 @@ test(
), ),
]) ])
}), }),
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
page.on('console', console.log) page.on('console', console.log)
@ -87,7 +86,10 @@ test(
await expect(successToastMessage).toBeVisible() await expect(successToastMessage).toBeVisible()
await expect(exportingToastMessage).not.toBeVisible() await expect(exportingToastMessage).not.toBeVisible()
const firstFileFullPath = path.resolve(getPlaywrightDownloadDir(page), exportFileName) const firstFileFullPath = path.resolve(
getPlaywrightDownloadDir(page),
exportFileName
)
await test.step('Check the export size', async () => { await test.step('Check the export size', async () => {
await expect await expect
.poll( .poll(
@ -162,7 +164,10 @@ test(
expect(exportingToastMessage).not.toBeVisible(), expect(exportingToastMessage).not.toBeVisible(),
])) ]))
const secondFileFullPath = path.resolve(getPlaywrightDownloadDir(page), exportFileName) const secondFileFullPath = path.resolve(
getPlaywrightDownloadDir(page),
exportFileName
)
await test.step('Check the export size', async () => { await test.step('Check the export size', async () => {
await expect await expect
.poll( .poll(

View File

@ -11,7 +11,8 @@ import {
import { join } from 'path' import { join } from 'path'
test.describe('Editor tests', () => { test.describe('Editor tests', () => {
test('can comment out code with ctrl+/', async ({ page, homePage }) => { const u = await getUtils(page) test('can comment out code with ctrl+/', async ({ page, homePage }) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -50,9 +51,14 @@ test.describe('Editor tests', () => {
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%)`) }) |> close(%)`)
})
test('if you click the format button it formats your code', async ({ page, homePage }) => { const u = await getUtils(page) test('if you click the format button it formats your code', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -76,9 +82,14 @@ test.describe('Editor tests', () => {
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%)`) }) |> close(%)`)
})
test('if you click the format button it formats your code and executes so lints are still there', async ({ page, homePage }) => { const u = await getUtils(page) test('if you click the format button it formats your code and executes so lints are still there', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -129,9 +140,11 @@ test.describe('Editor tests', () => {
await page.hover('.cm-lint-marker-info') await page.hover('.cm-lint-marker-info')
await expect( await expect(
page.getByText('Identifiers must be lowerCamelCase').first() page.getByText('Identifiers must be lowerCamelCase').first()
).toBeVisible() }) ).toBeVisible()
})
test('fold gutters work', async ({ page, homePage }) => { const u = await getUtils(page) test('fold gutters work', async ({ page, homePage }) => {
const u = await getUtils(page)
const fullCode = `sketch001 = startSketchOn('XY') const fullCode = `sketch001 = startSketchOn('XY')
|> startProfileAt([-10, -10], %) |> startProfileAt([-10, -10], %)
@ -200,9 +213,14 @@ test.describe('Editor tests', () => {
await expect(page.locator('.cm-content')).not.toHaveText(fullCode) await expect(page.locator('.cm-content')).not.toHaveText(fullCode)
await expect(foldGutterUnfoldLine).not.toBeVisible() await expect(foldGutterUnfoldLine).not.toBeVisible()
await expect(foldGutterFoldLine).not.toBeVisible() }) await expect(foldGutterFoldLine).not.toBeVisible()
})
test('hover over functions shows function description', async ({ page, homePage }) => { const u = await getUtils(page) test('hover over functions shows function description', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -240,9 +258,14 @@ test.describe('Editor tests', () => {
// Hover over the line function // Hover over the line function
await page.getByText('line').first().hover() await page.getByText('line').first().hover()
await expect(page.locator('.hover-tooltip')).toBeVisible() await expect(page.locator('.hover-tooltip')).toBeVisible()
await expect(page.getByText('Draw a line')).toBeVisible() }) await expect(page.getByText('Draw a line')).toBeVisible()
})
test('if you use the format keyboard binding it formats your code', async ({ page, homePage }) => { const u = await getUtils(page) test('if you use the format keyboard binding it formats your code', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -278,9 +301,14 @@ test.describe('Editor tests', () => {
|> line([20, 0], %) |> line([20, 0], %)
|> line([0, 20], %) |> line([0, 20], %)
|> line([-20, 0], %) |> line([-20, 0], %)
|> close(%)`) }) |> close(%)`)
})
test('if you use the format keyboard binding it formats your code and executes so lints are shown', async ({ page, homePage }) => { const u = await getUtils(page) test('if you use the format keyboard binding it formats your code and executes so lints are shown', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -335,9 +363,14 @@ test.describe('Editor tests', () => {
await page.hover('.cm-lint-marker-info') await page.hover('.cm-lint-marker-info')
await expect( await expect(
page.getByText('Identifiers must be lowerCamelCase').first() page.getByText('Identifiers must be lowerCamelCase').first()
).toBeVisible() }) ).toBeVisible()
})
test('if you write kcl with lint errors you get lints', async ({ page, homePage }) => { const u = await getUtils(page) test('if you write kcl with lint errors you get lints', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -373,9 +406,14 @@ test.describe('Editor tests', () => {
await page.keyboard.press('Backspace') await page.keyboard.press('Backspace')
// wait for .cm-lint-marker-info not to be visible // wait for .cm-lint-marker-info not to be visible
await expect(page.locator('.cm-lint-marker-info')).not.toBeVisible() }) await expect(page.locator('.cm-lint-marker-info')).not.toBeVisible()
})
test('if you fixup kcl errors you clear lints', async ({ page, homePage }) => { const u = await getUtils(page) test('if you fixup kcl errors you clear lints', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -409,9 +447,14 @@ test.describe('Editor tests', () => {
await page.keyboard.type(')') await page.keyboard.type(')')
await expect( await expect(
page.locator('.cm-lint-marker-error').first() page.locator('.cm-lint-marker-error').first()
).not.toBeVisible() }) ).not.toBeVisible()
})
test('if you write invalid kcl you get inlined errors', async ({ page, homePage }) => { const u = await getUtils(page) test('if you write invalid kcl you get inlined errors', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1000, height: 500 }) await page.setBodyDimensions({ width: 1000, height: 500 })
await homePage.goToModelingScene() await homePage.goToModelingScene()
@ -478,9 +521,14 @@ test.describe('Editor tests', () => {
await secondTopAng?.dblclick() await secondTopAng?.dblclick()
await page.keyboard.type('otherAng') await page.keyboard.type('otherAng')
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible() }) await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
})
test('error with 2 source ranges gets 2 diagnostics', async ({ page, homePage }) => { const u = await getUtils(page) test('error with 2 source ranges gets 2 diagnostics', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -541,8 +589,14 @@ test.describe('Editor tests', () => {
).toBeVisible() ).toBeVisible()
// Make sure there are two diagnostics // Make sure there are two diagnostics
await expect(page.locator('.cm-lint-marker-error')).toHaveCount(2) }) await expect(page.locator('.cm-lint-marker-error')).toHaveCount(2)
test('if your kcl gets an error from the engine it is inlined', async ({ context, page, homePage }) => { const u = await getUtils(page) })
test('if your kcl gets an error from the engine it is inlined', async ({
context,
page,
homePage,
}) => {
const u = await getUtils(page)
await context.addInitScript(async () => { await context.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
@ -579,9 +633,14 @@ test.describe('Editor tests', () => {
await page.hover('.cm-lint-marker-error') await page.hover('.cm-lint-marker-error')
const searchText = const searchText =
'sketch profile must lie entirely on one side of the revolution axis' 'sketch profile must lie entirely on one side of the revolution axis'
await expect(page.getByText(searchText)).toBeVisible() }) await expect(page.getByText(searchText)).toBeVisible()
})
test.describe('Autocomplete works', () => { test.describe('Autocomplete works', () => {
test('with enter/click to accept the completion', async ({ page, homePage }) => { const u = await getUtils(page) test('with enter/click to accept the completion', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
// const PUR = 400 / 37.5 //pixeltoUnitRatio // const PUR = 400 / 37.5 //pixeltoUnitRatio
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
@ -651,9 +710,11 @@ test.describe('Editor tests', () => {
|> xLine(5, %) // lin`) |> xLine(5, %) // lin`)
// expect there to be no KCL errors // expect there to be no KCL errors
await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0) }) await expect(page.locator('.cm-lint-marker-error')).toHaveCount(0)
})
test('with tab to accept the completion', async ({ page, homePage }) => { const u = await getUtils(page) test('with tab to accept the completion', async ({ page, homePage }) => {
const u = await getUtils(page)
// const PUR = 400 / 37.5 //pixeltoUnitRatio // const PUR = 400 / 37.5 //pixeltoUnitRatio
await page.setBodyDimensions({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
@ -720,9 +781,15 @@ test.describe('Editor tests', () => {
await expect(page.locator('.cm-content')) await expect(page.locator('.cm-content'))
.toHaveText(`sketch001 = startSketchOn('XZ') .toHaveText(`sketch001 = startSketchOn('XZ')
|> startProfileAt([3.14, 12], %) |> startProfileAt([3.14, 12], %)
|> xLine(5, %) // lin`) }) |> xLine(5, %) // lin`)
}) })
test('Can undo a click and point extrude with ctrl+z', async ({ page, context, homePage }) => { const u = await getUtils(page) })
test('Can undo a click and point extrude with ctrl+z', async ({
page,
context,
homePage,
}) => {
const u = await getUtils(page)
await context.addInitScript(async () => { await context.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -792,9 +859,14 @@ test.describe('Editor tests', () => {
|> startProfileAt([4.61, -14.01], %) |> startProfileAt([4.61, -14.01], %)
|> line([12.73, -0.09], %) |> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -5.38], %) |> tangentialArcTo([24.95, -5.38], %)
|> close(%)`) }) |> close(%)`)
})
test('Can undo a sketch modification with ctrl+z', async ({ page, homePage }) => { const u = await getUtils(page) test('Can undo a sketch modification with ctrl+z', async ({
page,
homePage,
}) => {
const u = await getUtils(page)
await page.addInitScript(async () => { await page.addInitScript(async () => {
localStorage.setItem( localStorage.setItem(
'persistCode', 'persistCode',
@ -872,7 +944,6 @@ test.describe('Editor tests', () => {
await expect(page.locator('.cm-content')).not.toHaveText(prevContent) await expect(page.locator('.cm-content')).not.toHaveText(prevContent)
prevContent = await page.locator('.cm-content').innerText() prevContent = await page.locator('.cm-content').innerText()
// we wait so it saves the code // we wait so it saves the code
await page.waitForTimeout(800) await page.waitForTimeout(800)
@ -937,7 +1008,8 @@ test.describe('Editor tests', () => {
|> line([12.73, -0.09], %) |> line([12.73, -0.09], %)
|> tangentialArcTo([24.95, -0.38], %) |> tangentialArcTo([24.95, -0.38], %)
|> close(%) |> close(%)
|> extrude(5, %)`) }) |> extrude(5, %)`)
})
test.fixme( test.fixme(
`Can use the import stdlib function on a local OBJ file`, `Can use the import stdlib function on a local OBJ file`,

View File

@ -1,11 +1,7 @@
import { test, expect } from './zoo-test' import { test, expect } from './zoo-test'
import * as fsp from 'fs/promises' import * as fsp from 'fs/promises'
import * as fs from 'fs' import * as fs from 'fs'
import { import { createProject, executorInputPath, getUtils } from './test-utils'
createProject,
executorInputPath,
getUtils,
} from './test-utils'
import { join } from 'path' import { join } from 'path'
import { FILE_EXT } from 'lib/constants' import { FILE_EXT } from 'lib/constants'
@ -127,9 +123,7 @@ test.describe('when using the file tree to', () => {
const settingsOpenButton = page.getByRole('link', { const settingsOpenButton = page.getByRole('link', {
name: 'settings Settings', name: 'settings Settings',
}) })
const settingsCloseButton = page.getByTestId( const settingsCloseButton = page.getByTestId('settings-close-button')
'settings-close-button'
)
await settingsOpenButton.click() await settingsOpenButton.click()
await settingsCloseButton.click() await settingsCloseButton.click()
}) })
@ -168,10 +162,7 @@ test.describe('when using the file tree to', () => {
test( test(
'create a new file with the same name as an existing file cancels the operation', 'create a new file with the same name as an existing file cancels the operation',
{ tag: '@electron' }, { tag: '@electron' },
async ( async ({ context, page, homePage, scene, editor, toolbar }, testInfo) => {
{ context, page, homePage, scene, editor, toolbar },
testInfo
) => {
const projectName = 'cube' const projectName = 'cube'
const mainFile = 'main.kcl' const mainFile = 'main.kcl'
const secondFile = 'cylinder.kcl' const secondFile = 'cylinder.kcl'
@ -578,9 +569,7 @@ test.describe('Renaming in the file tree', () => {
await page.keyboard.press('Enter') await page.keyboard.press('Enter')
}) })
await test.step( await test.step('Verify the folder is renamed, and no navigation occurred', async () => {
'Verify the folder is renamed, and no navigation occurred',
async () => {
const url = page.url() const url = page.url()
expect(url).toContain('main.kcl') expect(url).toContain('main.kcl')
expect(url).not.toContain('folderToRename') expect(url).not.toContain('folderToRename')
@ -590,8 +579,7 @@ test.describe('Renaming in the file tree', () => {
await expect(folderToRename).not.toBeAttached() await expect(folderToRename).not.toBeAttached()
expect(checkUnRenamedFolderFS()).toBeFalsy() expect(checkUnRenamedFolderFS()).toBeFalsy()
expect(checkRenamedFolderFS()).toBeTruthy() expect(checkRenamedFolderFS()).toBeTruthy()
} })
)
} }
) )
@ -676,9 +664,7 @@ test.describe('Renaming in the file tree', () => {
await page.keyboard.press('Enter') await page.keyboard.press('Enter')
}) })
await test.step( await test.step('Verify the folder is renamed, and navigated to new path', async () => {
'Verify the folder is renamed, and navigated to new path',
async () => {
const urlSnippet = encodeURIComponent( const urlSnippet = encodeURIComponent(
join(newFolderName, 'someFileWithin.kcl') join(newFolderName, 'someFileWithin.kcl')
) )
@ -694,8 +680,7 @@ test.describe('Renaming in the file tree', () => {
expect(url).toContain('someFileWithin.kcl') expect(url).toContain('someFileWithin.kcl')
expect(checkUnRenamedFolderFS()).toBeFalsy() expect(checkUnRenamedFolderFS()).toBeFalsy()
expect(checkRenamedFolderFS()).toBeTruthy() expect(checkRenamedFolderFS()).toBeTruthy()
} })
)
} }
) )
}) })
@ -730,9 +715,7 @@ test.describe('Deleting items from the file pane', () => {
const deleteMenuItem = page.getByRole('button', { name: 'Delete' }) const deleteMenuItem = page.getByRole('button', { name: 'Delete' })
const deleteConfirmation = page.getByTestId('delete-confirmation') const deleteConfirmation = page.getByTestId('delete-confirmation')
await test.step( await test.step('Open project and navigate to fileToDelete.kcl', async () => {
'Open project and navigate to fileToDelete.kcl',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
await u.openFilePanel() await u.openFilePanel()
@ -742,8 +725,7 @@ test.describe('Deleting items from the file pane', () => {
await u.openKclCodePanel() await u.openKclCodePanel()
await expect(u.codeLocator).toContainText('getOppositeEdge(thing)') await expect(u.codeLocator).toContainText('getOppositeEdge(thing)')
await u.closeKclCodePanel() await u.closeKclCodePanel()
} })
)
await test.step('Delete fileToDelete.kcl', async () => { await test.step('Delete fileToDelete.kcl', async () => {
await fileToDelete.click({ button: 'right' }) await fileToDelete.click({ button: 'right' })
@ -857,9 +839,7 @@ test.describe('Deleting items from the file pane', () => {
const deleteMenuItem = page.getByRole('button', { name: 'Delete' }) const deleteMenuItem = page.getByRole('button', { name: 'Delete' })
const deleteConfirmation = page.getByTestId('delete-confirmation') const deleteConfirmation = page.getByTestId('delete-confirmation')
await test.step( await test.step('Open project and navigate into folderToDelete', async () => {
'Open project and navigate into folderToDelete',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
await expect(projectMenuButton).toContainText('main.kcl') await expect(projectMenuButton).toContainText('main.kcl')
@ -870,8 +850,7 @@ test.describe('Deleting items from the file pane', () => {
await expect(fileWithinFolder).toBeVisible() await expect(fileWithinFolder).toBeVisible()
await fileWithinFolder.click() await fileWithinFolder.click()
await expect(projectMenuButton).toContainText('someFileWithin.kcl') await expect(projectMenuButton).toContainText('someFileWithin.kcl')
} })
)
await test.step('Delete folderToDelete', async () => { await test.step('Delete folderToDelete', async () => {
await folderToDelete.click({ button: 'right' }) await folderToDelete.click({ button: 'right' })
@ -881,21 +860,15 @@ test.describe('Deleting items from the file pane', () => {
await deleteConfirmation.click() await deleteConfirmation.click()
}) })
await test.step( await test.step('Check deletion and navigation to main.kcl', async () => {
'Check deletion and navigation to main.kcl',
async () => {
await expect(folderToDelete).not.toBeAttached() await expect(folderToDelete).not.toBeAttached()
await expect(fileWithinFolder).not.toBeAttached() await expect(fileWithinFolder).not.toBeAttached()
await expect(projectMenuButton).toContainText('main.kcl') await expect(projectMenuButton).toContainText('main.kcl')
} })
)
} }
) )
test.fixme( test.fixme('TODO - delete folder we are in, with no main.kcl', async () => {})
'TODO - delete folder we are in, with no main.kcl',
async () => {}
)
// Copied from tests above. // Copied from tests above.
test( test(
@ -903,7 +876,8 @@ test.describe('Deleting items from the file pane', () => {
{ tag: '@electron' }, { tag: '@electron' },
async ({ context, page }, testInfo) => { async ({ context, page }, testInfo) => {
const TEST_PROJECT_NAME = 'Test Project' const TEST_PROJECT_NAME = 'Test Project'
const { dir: projectsDirName } = await context.folderSetupFn(async (dir) => { const { dir: projectsDirName } = await context.folderSetupFn(
async (dir) => {
await fsp.mkdir(join(dir, TEST_PROJECT_NAME), { recursive: true }) await fsp.mkdir(join(dir, TEST_PROJECT_NAME), { recursive: true })
await fsp.mkdir(join(dir, TEST_PROJECT_NAME, 'folderToDelete'), { await fsp.mkdir(join(dir, TEST_PROJECT_NAME, 'folderToDelete'), {
recursive: true, recursive: true,
@ -916,7 +890,8 @@ test.describe('Deleting items from the file pane', () => {
executorInputPath('cylinder.kcl'), executorInputPath('cylinder.kcl'),
join(dir, TEST_PROJECT_NAME, 'folderToDelete', 'someFileWithin.kcl') join(dir, TEST_PROJECT_NAME, 'folderToDelete', 'someFileWithin.kcl')
) )
}) }
)
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setViewportSize({ width: 1200, height: 500 })
@ -930,9 +905,7 @@ test.describe('Deleting items from the file pane', () => {
has: page.getByRole('button', { name: 'someFileWithin.kcl' }), has: page.getByRole('button', { name: 'someFileWithin.kcl' }),
}) })
await test.step( await test.step('Open project and navigate into folderToDelete', async () => {
'Open project and navigate into folderToDelete',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
await expect(projectMenuButton).toContainText('main.kcl') await expect(projectMenuButton).toContainText('main.kcl')
@ -943,20 +916,16 @@ test.describe('Deleting items from the file pane', () => {
await expect(fileWithinFolder).toBeVisible() await expect(fileWithinFolder).toBeVisible()
await fileWithinFolder.click() await fileWithinFolder.click()
await expect(projectMenuButton).toContainText('someFileWithin.kcl') await expect(projectMenuButton).toContainText('someFileWithin.kcl')
} })
)
// Point of divergence. Delete the project folder and see if it goes back // Point of divergence. Delete the project folder and see if it goes back
// to the home view. // to the home view.
await test.step( await test.step('Delete projectsDirName/<project-name> externally', async () => {
'Delete projectsDirName/<project-name> externally',
async () => {
await fsp.rm(join(projectsDirName, TEST_PROJECT_NAME), { await fsp.rm(join(projectsDirName, TEST_PROJECT_NAME), {
recursive: true, recursive: true,
force: true, force: true,
}) })
} })
)
await test.step('Check the app is back on the home view', async () => { await test.step('Check the app is back on the home view', async () => {
const projectsDirLink = page.getByText('Loaded from') const projectsDirLink = page.getByText('Loaded from')
@ -971,7 +940,8 @@ test.describe('Deleting items from the file pane', () => {
{ tag: '@electron' }, { tag: '@electron' },
async ({ context, page }, testInfo) => { async ({ context, page }, testInfo) => {
const TEST_PROJECT_NAME = 'Test Project' const TEST_PROJECT_NAME = 'Test Project'
const { dir: projectsDirName } = await context.folderSetupFn(async (dir) => { const { dir: projectsDirName } = await context.folderSetupFn(
async (dir) => {
await fsp.mkdir(join(dir, TEST_PROJECT_NAME), { recursive: true }) await fsp.mkdir(join(dir, TEST_PROJECT_NAME), { recursive: true })
await fsp.mkdir(join(dir, TEST_PROJECT_NAME, 'folderToDelete'), { await fsp.mkdir(join(dir, TEST_PROJECT_NAME, 'folderToDelete'), {
recursive: true, recursive: true,
@ -984,7 +954,8 @@ test.describe('Deleting items from the file pane', () => {
executorInputPath('cylinder.kcl'), executorInputPath('cylinder.kcl'),
join(dir, TEST_PROJECT_NAME, 'folderToDelete', 'someFileWithin.kcl') join(dir, TEST_PROJECT_NAME, 'folderToDelete', 'someFileWithin.kcl')
) )
}) }
)
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setViewportSize({ width: 1200, height: 500 })
@ -998,9 +969,7 @@ test.describe('Deleting items from the file pane', () => {
has: page.getByRole('button', { name: 'someFileWithin.kcl' }), has: page.getByRole('button', { name: 'someFileWithin.kcl' }),
}) })
await test.step( await test.step('Open project and navigate into folderToDelete', async () => {
'Open project and navigate into folderToDelete',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
await expect(projectMenuButton).toContainText('main.kcl') await expect(projectMenuButton).toContainText('main.kcl')
@ -1011,12 +980,9 @@ test.describe('Deleting items from the file pane', () => {
await expect(fileWithinFolder).toBeVisible() await expect(fileWithinFolder).toBeVisible()
await fileWithinFolder.click() await fileWithinFolder.click()
await expect(projectMenuButton).toContainText('someFileWithin.kcl') await expect(projectMenuButton).toContainText('someFileWithin.kcl')
} })
)
await test.step( await test.step('Delete projectsDirName/<project-name> externally', async () => {
'Delete projectsDirName/<project-name> externally',
async () => {
await fsp.rm( await fsp.rm(
join( join(
projectsDirName, projectsDirName,
@ -1025,8 +991,7 @@ test.describe('Deleting items from the file pane', () => {
'someFileWithin.kcl' 'someFileWithin.kcl'
) )
) )
} })
)
await test.step('Check the file is gone in the file tree', async () => { await test.step('Check the file is gone in the file tree', async () => {
await expect( await expect(
@ -1034,22 +999,17 @@ test.describe('Deleting items from the file pane', () => {
).not.toContainText('someFileWithin.kcl') ).not.toContainText('someFileWithin.kcl')
}) })
await test.step( await test.step('Check the file is back in the file tree after typing in code editor', async () => {
'Check the file is back in the file tree after typing in code editor',
async () => {
await u.pasteCodeInEditor('hello = 1') await u.pasteCodeInEditor('hello = 1')
await expect( await expect(
page.getByTestId('file-pane-scroll-container') page.getByTestId('file-pane-scroll-container')
).toContainText('someFileWithin.kcl') ).toContainText('someFileWithin.kcl')
} })
)
} }
) )
}) })
test.describe( test.describe('Undo and redo do not keep history when navigating between files', () => {
'Undo and redo do not keep history when navigating between files',
() => {
test( test(
`open a file, change something, open a different file, hitting undo should do nothing`, `open a file, change something, open a different file, hitting undo should do nothing`,
{ tag: '@electron' }, { tag: '@electron' },
@ -1076,9 +1036,7 @@ test.describe(
.getByRole('listitem') .getByRole('listitem')
.filter({ has: page.getByRole('button', { name: 'other.kcl' }) }) .filter({ has: page.getByRole('button', { name: 'other.kcl' }) })
await test.step( await test.step('Open project and make a change to the file', async () => {
'Open project and make a change to the file',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
@ -1094,8 +1052,7 @@ test.describe(
const newContent = await u.codeLocator.innerText() const newContent = await u.codeLocator.innerText()
expect(originalText !== newContent) expect(originalText !== newContent)
} })
)
await test.step('navigate to other.kcl', async () => { await test.step('navigate to other.kcl', async () => {
await u.openFilePanel() await u.openFilePanel()
@ -1148,9 +1105,7 @@ test.describe(
.filter({ has: page.getByRole('button', { name: 'other.kcl' }) }) .filter({ has: page.getByRole('button', { name: 'other.kcl' }) })
const badContent = 'this shit' const badContent = 'this shit'
await test.step( await test.step('Open project and make a change to the file', async () => {
'Open project and make a change to the file',
async () => {
await projectCard.click() await projectCard.click()
await u.waitForPageLoad() await u.waitForPageLoad()
@ -1194,8 +1149,7 @@ test.describe(
await page.waitForTimeout(100) await page.waitForTimeout(100)
await expect(u.codeLocator).toContainText(originalText) await expect(u.codeLocator).toContainText(originalText)
await expect(u.codeLocator).not.toContainText(badContent) await expect(u.codeLocator).not.toContainText(badContent)
} })
)
await test.step('navigate to other.kcl', async () => { await test.step('navigate to other.kcl', async () => {
await u.openFilePanel() await u.openFilePanel()
@ -1223,5 +1177,4 @@ test.describe(
}) })
} }
) )
} })
)

View File

@ -1,14 +1,7 @@
import { test, expect } from '@playwright/test' import { test, expect } from './zoo-test'
import { join } from 'path' import { join } from 'path'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { import { getUtils, executorInputPath, createProject } from './test-utils'
getUtils,
setup,
setupElectron,
tearDown,
executorInputPath,
createProject,
} from './test-utils'
import { bracket } from 'lib/exampleKcl' import { bracket } from 'lib/exampleKcl'
import { onboardingPaths } from 'routes/Onboarding/paths' import { onboardingPaths } from 'routes/Onboarding/paths'
import { import {
@ -20,60 +13,54 @@ import {
} from './storageStates' } from './storageStates'
import * as TOML from '@iarna/toml' import * as TOML from '@iarna/toml'
test.beforeEach(async ({ context, page }, testInfo) => { // Because onboarding relies on an app setting we need to set it as incompletel
if (testInfo.tags.includes('@electron')) { // for all these tests.
return
}
await setup(context, page)
})
test.afterEach(async ({ page }, testInfo) => {
await tearDown(page, testInfo)
})
test.describe('Onboarding tests', () => { test.describe('Onboarding tests', () => {
test('Onboarding code is shown in the editor', async ({ page }) => {
const u = await getUtils(page)
// Override beforeEach test setup
await page.addInitScript(
async ({ settingsKey }) => {
// Give no initial code, so that the onboarding start is shown immediately
localStorage.removeItem('persistCode')
localStorage.removeItem(settingsKey)
},
{ settingsKey: TEST_SETTINGS_KEY }
)
await page.setViewportSize({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart()
// Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible()
// *and* that the code is shown in the editor
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket')
})
test( test(
'Desktop: fresh onboarding executes and loads', 'Onboarding code is shown in the editor',
{ tag: '@electron' }, {
async ({ browserName: _ }, testInfo) => {
const { electronApp, page } = await setupElectron({
testInfo,
appSettings: { appSettings: {
app: { app: {
onboardingStatus: 'incomplete', onboardingStatus: 'incomplete',
}, },
}, },
cleanProjectDir: true, cleanProjectDir: true,
}) },
async ({ context, page, homePage }) => {
const u = await getUtils(page)
await page.setBodyDimensions({ width: 1200, height: 500 })
await homePage.goToModelingScene()
// Test that the onboarding pane loaded
await expect(
page.getByText('Welcome to Modeling App! This')
).toBeVisible()
// *and* that the code is shown in the editor
await expect(page.locator('.cm-content')).toContainText(
'// Shelf Bracket'
)
}
)
test(
'Desktop: fresh onboarding executes and loads',
{
tag: '@electron',
appSettings: {
app: {
onboardingStatus: 'incomplete',
},
},
cleanProjectDir: true,
},
async ({ page, homePage }, testInfo) => {
const u = await getUtils(page) const u = await getUtils(page)
const viewportSize = { width: 1200, height: 500 } const viewportSize = { width: 1200, height: 500 }
await page.setViewportSize(viewportSize) await page.setBodyDimensions(viewportSize)
await test.step(`Create a project and open to the onboarding`, async () => { await test.step(`Create a project and open to the onboarding`, async () => {
await createProject({ name: 'project-link', page }) await createProject({ name: 'project-link', page })
@ -93,60 +80,76 @@ test.describe('Onboarding tests', () => {
'// Shelf Bracket' '// Shelf Bracket'
) )
}) })
await electronApp.close()
} }
) )
test('Code resets after confirmation', async ({ page }) => { test(
'Code resets after confirmation',
{
appSettings: {
app: {
onboardingStatus: 'incomplete',
},
},
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
const initialCode = `sketch001 = startSketchOn('XZ')` const initialCode = `sketch001 = startSketchOn('XZ')`
// Load the page up with some code so we see the confirmation warning // Load the page up with some code so we see the confirmation warning
// when we go to replay onboarding // when we go to replay onboarding
await page.addInitScript((code) => { await context.addInitScript((code) => {
localStorage.setItem('persistCode', code) localStorage.setItem('persistCode', code)
}, initialCode) }, initialCode)
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
// Replay the onboarding // Replay the onboarding
await page.getByRole('link', { name: 'Settings' }).last().click() await page.getByRole('link', { name: 'Settings' }).last().click()
const replayButton = page.getByRole('button', { name: 'Replay onboarding' }) const replayButton = page.getByRole('button', {
name: 'Replay onboarding',
})
await expect(replayButton).toBeVisible() await expect(replayButton).toBeVisible()
await replayButton.click() await replayButton.click()
// Ensure we see the warning, and that the code has not yet updated // Ensure we see the warning, and that the code has not yet updated
await expect( await expect(
page.getByText('Replaying onboarding resets your code') page.getByText('Would you like to create')
).toBeVisible() ).toBeVisible()
await expect(page.locator('.cm-content')).toHaveText(initialCode) await expect(page.locator('.cm-content')).toHaveText(initialCode)
const nextButton = page.getByTestId('onboarding-next') const nextButton = page.getByTestId('onboarding-next')
await expect(nextButton).toBeVisible() await nextButton.hover()
await nextButton.click() await nextButton.click()
// Ensure we see the introduction and that the code has been reset // Ensure we see the introduction and that the code has been reset
await expect(page.getByText('Welcome to Modeling App!')).toBeVisible() await expect(page.getByText('Welcome to Modeling App!')).toBeVisible()
await expect(page.locator('.cm-content')).toContainText('// Shelf Bracket') await expect(page.locator('.cm-content')).toContainText(
'// Shelf Bracket'
)
// Ensure we persisted the code to local storage. // There used to be old code here that checked if we stored the reset
// Playwright's addInitScript method unfortunately will reset // code into localStorage but that isnt the case on desktop. It gets
// this code if we try reloading the page as a test, // saved to the file system, which we have other tests for.
// so this is our best way to test persistence afaik. }
expect( )
await page.evaluate(() => {
return localStorage.getItem('persistCode')
})
).toContain('// Shelf Bracket')
})
test('Click through each onboarding step', async ({ page }) => { test(
'Click through each onboarding step',
{
appSettings: {
app: {
onboardingStatus: 'incomplete',
},
},
},
async ({ context, page, homePage }) => {
const u = await getUtils(page) const u = await getUtils(page)
// Override beforeEach test setup // Override beforeEach test setup
await page.addInitScript( await context.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
// Give no initial code, so that the onboarding start is shown immediately // Give no initial code, so that the onboarding start is shown immediately
localStorage.setItem('persistCode', '') localStorage.setItem('persistCode', '')
@ -154,107 +157,113 @@ test.describe('Onboarding tests', () => {
}, },
{ {
settingsKey: TEST_SETTINGS_KEY, settingsKey: TEST_SETTINGS_KEY,
settings: TOML.stringify({ settings: TEST_SETTINGS_ONBOARDING_START }), settings: TOML.stringify({
settings: TEST_SETTINGS_ONBOARDING_START,
}),
} }
) )
await page.setViewportSize({ width: 1200, height: 1080 }) await page.setBodyDimensions({ width: 1200, height: 1080 })
await homePage.goToModelingScene()
await u.waitForAuthSkipAppStart()
// Test that the onboarding pane loaded // Test that the onboarding pane loaded
await expect(page.getByText('Welcome to Modeling App! This')).toBeVisible() await expect(
page.getByText('Welcome to Modeling App! This')
).toBeVisible()
const nextButton = page.getByTestId('onboarding-next') const nextButton = page.getByTestId('onboarding-next')
while ((await nextButton.innerText()) !== 'Finish') { while ((await nextButton.innerText()) !== 'Finish') {
await expect(nextButton).toBeVisible() await nextButton.hover()
await nextButton.click() await nextButton.click()
} }
// Finish the onboarding // Finish the onboarding
await expect(nextButton).toBeVisible() await nextButton.hover()
await nextButton.click() await nextButton.click()
// Test that the onboarding pane is gone // Test that the onboarding pane is gone
await expect(page.getByTestId('onboarding-content')).not.toBeVisible() await expect(page.getByTestId('onboarding-content')).not.toBeVisible()
await expect(page.url()).not.toContain('onboarding') await expect.poll(() => page.url()).not.toContain('/onboarding')
})
test('Onboarding redirects and code updating', async ({ page }) => {
const u = await getUtils(page)
// Override beforeEach test setup
await page.addInitScript(
async ({ settingsKey, settings }) => {
// Give some initial code, so we can test that it's cleared
localStorage.setItem('persistCode', 'sigmaAllow = 15000')
localStorage.setItem(settingsKey, settings)
},
{
settingsKey: TEST_SETTINGS_KEY,
settings: TOML.stringify({ settings: TEST_SETTINGS_ONBOARDING_EXPORT }),
} }
) )
await page.setViewportSize({ width: 1200, height: 500 }) test(
'Onboarding redirects and code updating',
await u.waitForAuthSkipAppStart() {
appSettings: {
// Test that the redirect happened app: {
await expect(page.url().split(':3000').slice(-1)[0]).toBe( onboardingStatus: '/export',
`/file/%2Fbrowser%2Fmain.kcl/onboarding/export` },
) },
cleanProjectDir: true,
// Test that you come back to this page when you refresh },
await page.reload() async ({ context, page, homePage }) => {
await expect(page.url().split(':3000').slice(-1)[0]).toBe(
`/file/%2Fbrowser%2Fmain.kcl/onboarding/export`
)
// Test that the onboarding pane loaded
const title = page.locator('[data-testid="onboarding-content"]')
await expect(title).toBeAttached()
// Test that the code changes when you advance to the next step
await page.locator('[data-testid="onboarding-next"]').click()
await expect(page.locator('.cm-content')).toHaveText('')
// Test that the code is not empty when you click on the next step
await page.locator('[data-testid="onboarding-next"]').click()
await expect(page.locator('.cm-content')).toHaveText(/.+/)
})
test('Onboarding code gets reset to demo on Interactive Numbers step', async ({
page,
}) => {
test.skip(
process.platform === 'darwin',
"Skip on macOS, because Playwright isn't behaving the same as the actual browser"
)
const u = await getUtils(page) const u = await getUtils(page)
const badCode = `// This is bad code we shouldn't see`
const originalCode = 'sigmaAllow = 15000'
// Override beforeEach test setup // Override beforeEach test setup
await page.addInitScript( await context.addInitScript(
async ({ settingsKey, settings, badCode }) => { async ({ settingsKey, settings }) => {
localStorage.setItem('persistCode', badCode) // Give some initial code, so we can test that it's cleared
localStorage.setItem('persistCode', originalCode)
localStorage.setItem(settingsKey, settings) localStorage.setItem(settingsKey, settings)
}, },
{ {
settingsKey: TEST_SETTINGS_KEY, settingsKey: TEST_SETTINGS_KEY,
settings: TOML.stringify({ settings: TOML.stringify({
settings: TEST_SETTINGS_ONBOARDING_PARAMETRIC_MODELING, settings: TEST_SETTINGS_ONBOARDING_EXPORT,
}), }),
badCode,
} }
) )
await page.setViewportSize({ width: 1200, height: 1080 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await page.waitForURL('**' + onboardingPaths.PARAMETRIC_MODELING, { // Test that the redirect happened
waitUntil: 'domcontentloaded', await expect.poll(() => page.url()).toContain('/onboarding/export')
})
// Test that you come back to this page when you refresh
await page.reload()
await expect.poll(() => page.url()).toContain('/onboarding/export')
// Test that the code changes when you advance to the next step
await page.getByTestId('onboarding-next').hover()
await page.getByTestId('onboarding-next').click()
// Test that the onboarding pane loaded
const title = page.locator('[data-testid="onboarding-content"]')
await expect(title).toBeAttached()
await expect(page.locator('.cm-content')).not.toHaveText(originalCode)
// Test that the code is not empty when you click on the next step
await page.locator('[data-testid="onboarding-next"]').hover()
await page.locator('[data-testid="onboarding-next"]').click()
await expect(page.locator('.cm-content')).toHaveText(/.+/)
}
)
test(
'Onboarding code gets reset to demo on Interactive Numbers step',
{
appSettings: {
app: {
onboardingStatus: '/parametric-modeling',
},
},
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
const u = await getUtils(page)
const badCode = `// This is bad code we shouldn't see`
await page.setBodyDimensions({ width: 1200, height: 1080 })
await homePage.goToModelingScene()
await expect.poll(() => page.url()).toContain(onboardingPaths.PARAMETRIC_MODELING)
const bracketNoNewLines = bracket.replace(/\n/g, '') const bracketNoNewLines = bracket.replace(/\n/g, '')
@ -270,6 +279,7 @@ test.describe('Onboarding tests', () => {
await expect(u.codeLocator).toHaveText(badCode) await expect(u.codeLocator).toHaveText(badCode)
// Click to the next step // Click to the next step
await page.locator('[data-testid="onboarding-next"]').hover()
await page.locator('[data-testid="onboarding-next"]').click() await page.locator('[data-testid="onboarding-next"]').click()
await page.waitForURL('**' + onboardingPaths.INTERACTIVE_NUMBERS, { await page.waitForURL('**' + onboardingPaths.INTERACTIVE_NUMBERS, {
waitUntil: 'domcontentloaded', waitUntil: 'domcontentloaded',
@ -277,13 +287,25 @@ test.describe('Onboarding tests', () => {
// Check that the code has been reset // Check that the code has been reset
await expect(u.codeLocator).toHaveText(bracketNoNewLines) await expect(u.codeLocator).toHaveText(bracketNoNewLines)
}) }
)
test('Avatar text updates depending on image load success', async ({ // (lee) The two avatar tests are weird because even on main, we don't have
page, // anything to do with the avatar inside the onboarding test. Due to the
}) => { // low impact of an avatar not showing I'm changing this to fixme.
test.fixme(
'Avatar text updates depending on image load success',
{
appSettings: {
app: {
onboardingStatus: 'incomplete',
},
},
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
// Override beforeEach test setup // Override beforeEach test setup
await page.addInitScript( await context.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
localStorage.setItem(settingsKey, settings) localStorage.setItem(settingsKey, settings)
}, },
@ -296,10 +318,8 @@ test.describe('Onboarding tests', () => {
) )
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' })
// Test that the text in this step is correct // Test that the text in this step is correct
const avatarLocator = await page const avatarLocator = await page
@ -327,13 +347,16 @@ test.describe('Onboarding tests', () => {
}) })
// 404 the CI avatar image // 404 the CI avatar image
await page.route('https://lh3.googleusercontent.com/**', async (route) => { await page.route(
'https://lh3.googleusercontent.com/**',
async (route) => {
await route.fulfill({ await route.fulfill({
status: 404, status: 404,
contentType: 'text/plain', contentType: 'text/plain',
body: 'Not Found!', body: 'Not Found!',
}) })
}) }
)
await page.reload({ waitUntil: 'domcontentloaded' }) await page.reload({ waitUntil: 'domcontentloaded' })
@ -341,13 +364,22 @@ test.describe('Onboarding tests', () => {
await expect(avatarLocator).not.toBeVisible() await expect(avatarLocator).not.toBeVisible()
await expect(onboardingOverlayLocator).toBeVisible() await expect(onboardingOverlayLocator).toBeVisible()
await expect(onboardingOverlayLocator).toContainText('the menu button') await expect(onboardingOverlayLocator).toContainText('the menu button')
}) }
)
test("Avatar text doesn't mention avatar when no avatar", async ({ test.fixme(
page, "Avatar text doesn't mention avatar when no avatar",
}) => { {
appSettings: {
app: {
onboardingStatus: 'incomplete',
},
},
cleanProjectDir: true,
},
async ({ context, page, homePage }) => {
// Override beforeEach test setup // Override beforeEach test setup
await page.addInitScript( await context.addInitScript(
async ({ settingsKey, settings }) => { async ({ settingsKey, settings }) => {
localStorage.setItem(settingsKey, settings) localStorage.setItem(settingsKey, settings)
localStorage.setItem('FORCE_NO_IMAGE', 'FORCE_NO_IMAGE') localStorage.setItem('FORCE_NO_IMAGE', 'FORCE_NO_IMAGE')
@ -361,10 +393,8 @@ test.describe('Onboarding tests', () => {
) )
const u = await getUtils(page) const u = await getUtils(page)
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
await u.waitForAuthSkipAppStart() await homePage.goToModelingScene()
await page.waitForURL('**/file/**', { waitUntil: 'domcontentloaded' })
// Test that the text in this step is correct // Test that the text in this step is correct
const sidebar = page.getByTestId('user-sidebar-toggle') const sidebar = page.getByTestId('user-sidebar-toggle')
@ -390,23 +420,28 @@ test.describe('Onboarding tests', () => {
for (const feature of userMenuFeatures) { for (const feature of userMenuFeatures) {
await expect(onboardingOverlayLocator).toContainText(feature) await expect(onboardingOverlayLocator).toContainText(feature)
} }
}) }
)
}) })
test( test(
'Restarting onboarding on desktop takes one attempt', 'Restarting onboarding on desktop takes one attempt',
{ tag: '@electron' }, {
async ({ browser: _ }, testInfo) => { appSettings: {
const { electronApp, page } = await setupElectron({ app: {
testInfo, onboardingStatus: 'dismissed',
folderSetupFn: async (dir) => { },
},
cleanProjectDir: true,
},
async ({ context, page, homePage }, testInfo) => {
await context.folderSetupFn(async (dir) => {
const routerTemplateDir = join(dir, 'router-template-slate') const routerTemplateDir = join(dir, 'router-template-slate')
await fsp.mkdir(routerTemplateDir, { recursive: true }) await fsp.mkdir(routerTemplateDir, { recursive: true })
await fsp.copyFile( await fsp.copyFile(
executorInputPath('router-template-slate.kcl'), executorInputPath('router-template-slate.kcl'),
join(routerTemplateDir, 'main.kcl') join(routerTemplateDir, 'main.kcl')
) )
},
}) })
// Our constants // Our constants
@ -418,9 +453,8 @@ test(
const restartOnboardingButton = page.getByRole('button', { const restartOnboardingButton = page.getByRole('button', {
name: 'Reset onboarding', name: 'Reset onboarding',
}) })
const restartConfirmationButton = page.getByRole('button', { const nextButton = page.getByTestId('onboarding-next')
name: 'Make a new project',
})
const tutorialProjectIndicator = page const tutorialProjectIndicator = page
.getByTestId('project-sidebar-toggle') .getByTestId('project-sidebar-toggle')
.filter({ hasText: 'Tutorial Project 00' }) .filter({ hasText: 'Tutorial Project 00' })
@ -439,7 +473,7 @@ test(
}) })
await test.step('Navigate into project', async () => { await test.step('Navigate into project', async () => {
await page.setViewportSize({ width: 1200, height: 500 }) await page.setBodyDimensions({ width: 1200, height: 500 })
page.on('console', console.log) page.on('console', console.log)
@ -455,8 +489,8 @@ test(
await helpMenuButton.click() await helpMenuButton.click()
await restartOnboardingButton.click() await restartOnboardingButton.click()
await expect(restartConfirmationButton).toBeVisible() await nextButton.hover()
await restartConfirmationButton.click() await nextButton.click()
}) })
await test.step('Confirm that the onboarding has restarted', async () => { await test.step('Confirm that the onboarding has restarted', async () => {
@ -480,11 +514,9 @@ test(
await restartOnboardingSettingsButton.click() await restartOnboardingSettingsButton.click()
// Since the code is empty, we should not see the confirmation dialog // Since the code is empty, we should not see the confirmation dialog
await expect(restartConfirmationButton).not.toBeVisible() await expect(nextButton).not.toBeVisible()
await expect(tutorialProjectIndicator).toBeVisible() await expect(tutorialProjectIndicator).toBeVisible()
await expect(tutorialModalText).toBeVisible() await expect(tutorialModalText).toBeVisible()
}) })
await electronApp.close()
} }
) )

View File

@ -696,10 +696,7 @@ export const makeTemplate: (
const PLAYWRIGHT_DOWNLOAD_DIR = 'downloads-during-playwright' const PLAYWRIGHT_DOWNLOAD_DIR = 'downloads-during-playwright'
export const getPlaywrightDownloadDir = (page: Page) => { export const getPlaywrightDownloadDir = (page: Page) => {
return path.resolve( return path.resolve(page.TEST_SETTINGS_FILE_KEY, PLAYWRIGHT_DOWNLOAD_DIR)
page.TEST_SETTINGS_FILE_KEY,
PLAYWRIGHT_DOWNLOAD_DIR
)
} }
const moveDownloadedFileTo = async (page: Page, toLocation: string) => { const moveDownloadedFileTo = async (page: Page, toLocation: string) => {

View File

@ -28,7 +28,12 @@ export function test(desc, objOrFn, fnMaybe) {
const tronApp = new AuthenticatedTronApp(context, page, testInfo) const tronApp = new AuthenticatedTronApp(context, page, testInfo)
const fixtures: Fixtures = { cmdBar, editor, toolbar, scene, homePage } const fixtures: Fixtures = { cmdBar, editor, toolbar, scene, homePage }
await tronApp.initialise({ fixtures }) const options = {
fixtures,
appSettings: objOrFn?.appSettings,
cleanProjectDir: objOrFn?.cleanProjectDir,
}
await tronApp.initialise(options)
// We need to patch this because addInitScript will bind too late in our // We need to patch this because addInitScript will bind too late in our
// electron tests, never running. We need to call reload() after each call // electron tests, never running. We need to call reload() after each call