Fix native menu tests more

This commit is contained in:
lee-at-zoo-corp
2025-04-04 13:51:44 -04:00
parent 7f18aef49b
commit 0af99af15e
2 changed files with 241 additions and 148 deletions

View File

@ -12,15 +12,21 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const newProject = if (!app || !app.applicationMenu) {
app.applicationMenu.getMenuItemById('File.New project') return false
if (!newProject) fail() }
newProject.click() const newProject =
}) app.applicationMenu.getMenuItemById('File.New project')
if (!newProject) return false
newProject.click()
return true
})
)
.toBe(true)
// Check that the command bar is opened // Check that the command bar is opened
await expect(cmdBar.cmdBarElement).toBeVisible() await expect(cmdBar.cmdBarElement).toBeVisible()
// Check the placeholder project name exists // Check the placeholder project name exists
@ -34,15 +40,21 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const openProject = async () =>
app.applicationMenu.getMenuItemById('File.Open project') await tronApp.electron.evaluate(async ({ app }) => {
if (!openProject) { if (!app || !app.applicationMenu) return false
fail() const openProject =
} app.applicationMenu.getMenuItemById('File.Open project')
openProject.click() if (!openProject) {
}) return false
}
openProject.click()
return true
})
)
.toBe(true)
// Check that the command bar is opened // Check that the command bar is opened
await expect(cmdBar.cmdBarElement).toBeVisible() await expect(cmdBar.cmdBarElement).toBeVisible()
// Check the placeholder project name exists // Check the placeholder project name exists
@ -60,17 +72,23 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
console.log(app) .poll(
if (!app || !app.applicationMenu) { async () =>
fail() await tronApp.electron.evaluate(async ({ app }) => {
} console.log(app)
const userSettings = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'File.Preferences.User settings' return false
}
const userSettings = app.applicationMenu.getMenuItemById(
'File.Preferences.User settings'
)
if (!userSettings) return false
userSettings.click()
return true
})
) )
if (!userSettings) fail() .toBe(true)
userSettings.click()
})
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
await expect(settings).toBeVisible() await expect(settings).toBeVisible()
// You are viewing the user tab // You are viewing the user tab
@ -89,16 +107,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
} }
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const keybindings = app.applicationMenu.getMenuItemById( async () =>
'File.Preferences.Keybindings' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const keybindings = app.applicationMenu.getMenuItemById(
'File.Preferences.Keybindings'
)
if (!keybindings) {
return false
}
keybindings.click()
return true
})
) )
if (!keybindings) { .toBe(true)
fail()
}
keybindings.click()
})
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
await expect(settings).toBeVisible() await expect(settings).toBeVisible()
// You are viewing the keybindings tab // You are viewing the keybindings tab
@ -113,16 +137,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'File.Preferences.User default units' return false
}
const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.User default units'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
await expect(settings).toBeVisible() await expect(settings).toBeVisible()
const defaultUnit = settings.locator('#defaultUnit') const defaultUnit = settings.locator('#defaultUnit')
@ -132,16 +162,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById( async () =>
'File.Preferences.Theme' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.Theme'
)
if (!menu) {
return false
}
menu.click()
return true
})
) )
if (!menu) { .toBe(true)
fail()
}
menu.click()
})
// Check that the command bar is opened // Check that the command bar is opened
await expect(cmdBar.cmdBarElement).toBeVisible() await expect(cmdBar.cmdBarElement).toBeVisible()
// Check the placeholder project name exists // Check the placeholder project name exists
@ -159,16 +195,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'File.Preferences.Theme color' return false
}
const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.Theme color'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
await expect(settings).toBeVisible() await expect(settings).toBeVisible()
const defaultUnit = settings.locator('#themeColor') const defaultUnit = settings.locator('#themeColor')
@ -182,15 +224,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById('File.Sign out') async () =>
if (!menu) { await tronApp.electron.evaluate(async ({ app }) => {
fail() if (!app || !app.applicationMenu) return false
} const menu =
// FIXME: Add back when you can actually sign out app.applicationMenu.getMenuItemById('File.Sign out')
// menu.click() if (!menu) {
}) return false
}
// FIXME: Add back when you can actually sign out
// menu.click()
// return true
})
)
.toBe(true)
// FIXME: When signing out during E2E the page is not bound correctly. // FIXME: When signing out during E2E the page is not bound correctly.
// It cannot find the button // It cannot find the button
// const signIn = page.getByTestId('sign-in-button') // const signIn = page.getByTestId('sign-in-button')
@ -203,16 +252,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'Edit.Rename project' return false
}
const menu = app.applicationMenu.getMenuItemById(
'Edit.Rename project'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
// Check the placeholder project name exists // Check the placeholder project name exists
const actual = await cmdBar.cmdBarElement const actual = await cmdBar.cmdBarElement
.getByTestId('command-name') .getByTestId('command-name')
@ -224,16 +279,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById( async () =>
'Edit.Delete project' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const menu = app.applicationMenu.getMenuItemById(
'Edit.Delete project'
)
if (!menu) {
return false
}
menu.click()
return true
})
) )
if (!menu) { .toBe(true)
fail()
}
menu.click()
})
// Check the placeholder project name exists // Check the placeholder project name exists
const actual = async () => const actual = async () =>
cmdBar.cmdBarElement.getByTestId('command-name').textContent() cmdBar.cmdBarElement.getByTestId('command-name').textContent()
@ -248,16 +309,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'Edit.Change project directory' return false
}
const menu = app.applicationMenu.getMenuItemById(
'Edit.Change project directory'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
await expect(settings).toBeVisible() await expect(settings).toBeVisible()
const projectDirectory = settings.locator('#projectDirectory') const projectDirectory = settings.locator('#projectDirectory')
@ -273,16 +340,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById( async () =>
'View.Command Palette...' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const menu = app.applicationMenu.getMenuItemById(
'View.Command Palette...'
)
if (!menu) {
return false
}
menu.click()
return true
})
) )
if (!menu) { .toBe(true)
fail()
}
menu.click()
})
// Check the placeholder project name exists // Check the placeholder project name exists
const actual = cmdBar.cmdBarElement.getByTestId('cmd-bar-search') const actual = cmdBar.cmdBarElement.getByTestId('cmd-bar-search')
await expect(actual).toBeVisible() await expect(actual).toBeVisible()
@ -293,16 +366,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'Help.Show all commands' return false
}
const menu = app.applicationMenu.getMenuItemById(
'Help.Show all commands'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
// Check the placeholder project name exists // Check the placeholder project name exists
const actual = cmdBar.cmdBarElement.getByTestId('cmd-bar-search') const actual = cmdBar.cmdBarElement.getByTestId('cmd-bar-search')
await expect(actual).toBeVisible() await expect(actual).toBeVisible()
@ -311,15 +390,21 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById( async () =>
'Help.KCL code samples' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const menu = app.applicationMenu.getMenuItemById(
'Help.KCL code samples'
)
if (!menu) {
return false
}
return true
})
) )
if (!menu) { .toBe(true)
fail()
}
})
}) })
test('Home.Help.Refresh and report a bug', async ({ test('Home.Help.Refresh and report a bug', async ({
tronApp, tronApp,
@ -329,16 +414,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) { .poll(
fail() async () =>
} await tronApp.electron.evaluate(async ({ app }) => {
const menu = app.applicationMenu.getMenuItemById( if (!app || !app.applicationMenu) {
'Help.Refresh and report a bug' return false
}
const menu = app.applicationMenu.getMenuItemById(
'Help.Refresh and report a bug'
)
if (!menu) return false
menu.click()
return true
})
) )
if (!menu) fail() .toBe(true)
menu.click()
})
// Core dump and refresh magic number timeout // Core dump and refresh magic number timeout
await page.waitForTimeout(7000) await page.waitForTimeout(7000)
const actual = page.getByText( const actual = page.getByText(
@ -350,16 +441,22 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
if (!tronApp) fail() if (!tronApp) fail()
// Run electron snippet to find the Menu! // Run electron snippet to find the Menu!
await page.waitForTimeout(100) // wait for createModelingPageMenu() to run await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
await tronApp.electron.evaluate(async ({ app }) => { await expect
if (!app || !app.applicationMenu) fail() .poll(
const menu = app.applicationMenu.getMenuItemById( async () =>
'Help.Reset onboarding' await tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) return false
const menu = app.applicationMenu.getMenuItemById(
'Help.Reset onboarding'
)
if (!menu) {
return false
}
menu.click()
return true
})
) )
if (!menu) { .toBe(true)
fail()
}
menu.click()
})
const actual = page.getByText( const actual = page.getByText(
`This is a hardware design tool that lets you edit visually, with code, or both. It's powered by the KittyCAD Design API, the first API created for anyone to build hardware design tools.` `This is a hardware design tool that lets you edit visually, with code, or both. It's powered by the KittyCAD Design API, the first API created for anyone to build hardware design tools.`

View File

@ -419,7 +419,6 @@ test(
const PUR = 400 / 37.5 //pixeltoUnitRatio const PUR = 400 / 37.5 //pixeltoUnitRatio
await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
const startXPx = 600 const startXPx = 600
const [endOfTangentClk, endOfTangentMv] = scene.makeMouseHelpers( const [endOfTangentClk, endOfTangentMv] = scene.makeMouseHelpers(
startXPx + PUR * 30, startXPx + PUR * 30,
@ -548,7 +547,6 @@ test(
await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
// click on "Start Sketch" button // click on "Start Sketch" button
await u.doAndWaitForImageDiff( await u.doAndWaitForImageDiff(
() => page.getByRole('button', { name: 'Start Sketch' }).click(), () => page.getByRole('button', { name: 'Start Sketch' }).click(),
@ -594,7 +592,6 @@ test(
await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
await u.doAndWaitForImageDiff( await u.doAndWaitForImageDiff(
() => page.getByRole('button', { name: 'Start Sketch' }).click(), () => page.getByRole('button', { name: 'Start Sketch' }).click(),
200 200
@ -645,7 +642,6 @@ test.describe(
await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
await u.doAndWaitForImageDiff( await u.doAndWaitForImageDiff(
() => page.getByRole('button', { name: 'Start Sketch' }).click(), () => page.getByRole('button', { name: 'Start Sketch' }).click(),
200 200