Try something

This commit is contained in:
lee-at-zoo-corp
2025-04-04 11:28:20 -04:00
parent e06f76a6bb
commit 49fcbdddba
3 changed files with 39 additions and 45 deletions

View File

@ -14,11 +14,11 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const newProject = const newProject =
app.applicationMenu.getMenuItemById('File.New project') app.applicationMenu.getMenuItemById('File.New project')
if (!newProject) test.fail() if (!newProject) fail()
newProject.click() newProject.click()
}) })
// Check that the command bar is opened // Check that the command bar is opened
@ -35,11 +35,11 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const openProject = const openProject =
app.applicationMenu.getMenuItemById('File.Open project') app.applicationMenu.getMenuItemById('File.Open project')
if (!openProject) { if (!openProject) {
test.fail() fail()
} }
openProject.click() openProject.click()
}) })
@ -57,17 +57,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
cmdBar, cmdBar,
page, page,
}) => { }) => {
if (!tronApp) test.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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const userSettings = app.applicationMenu.getMenuItemById( const userSettings = app.applicationMenu.getMenuItemById(
'File.Preferences.User settings' 'File.Preferences.User settings'
) )
if (!userSettings) test.fail() if (!userSettings) fail()
userSettings.click() userSettings.click()
}) })
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
@ -84,17 +84,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
page, page,
}) => { }) => {
if (!tronApp) { if (!tronApp) {
test.fail() 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const keybindings = app.applicationMenu.getMenuItemById( const keybindings = app.applicationMenu.getMenuItemById(
'File.Preferences.Keybindings' 'File.Preferences.Keybindings'
) )
if (!keybindings) { if (!keybindings) {
test.fail() fail()
} }
keybindings.click() keybindings.click()
}) })
@ -109,17 +109,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
cmdBar, cmdBar,
page, page,
}) => { }) => {
if (!tronApp) test.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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.User default units' 'File.Preferences.User default units'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
@ -132,12 +132,12 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.Theme' 'File.Preferences.Theme'
) )
if (!menu) { if (!menu) {
test.fail() fail()
} }
menu.click() menu.click()
}) })
@ -155,17 +155,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
cmdBar, cmdBar,
page, page,
}) => { }) => {
if (!tronApp) test.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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'File.Preferences.Theme color' 'File.Preferences.Theme color'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
@ -182,10 +182,10 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById('File.Sign out') const menu = app.applicationMenu.getMenuItemById('File.Sign out')
if (!menu) { if (!menu) {
test.fail() fail()
} }
// FIXME: Add back when you can actually sign out // FIXME: Add back when you can actually sign out
// menu.click() // menu.click()
@ -204,12 +204,12 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Edit.Rename project' 'Edit.Rename project'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
// Check the placeholder project name exists // Check the placeholder project name exists
@ -224,12 +224,12 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Edit.Delete project' 'Edit.Delete project'
) )
if (!menu) { if (!menu) {
test.fail() fail()
} }
menu.click() menu.click()
}) })
@ -244,17 +244,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
cmdBar, cmdBar,
page, page,
}) => { }) => {
if (!tronApp) test.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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Edit.Change project directory' 'Edit.Change project directory'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
const settings = page.getByTestId('settings-dialog-panel') const settings = page.getByTestId('settings-dialog-panel')
@ -273,12 +273,12 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'View.Command Palette...' 'View.Command Palette...'
) )
if (!menu) { if (!menu) {
test.fail() fail()
} }
menu.click() menu.click()
}) })
@ -294,12 +294,12 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Help.Show all commands' 'Help.Show all commands'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
// Check the placeholder project name exists // Check the placeholder project name exists
@ -311,12 +311,12 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Help.KCL code samples' 'Help.KCL code samples'
) )
if (!menu) { if (!menu) {
test.fail() fail()
} }
}) })
}) })
@ -325,17 +325,17 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
cmdBar, cmdBar,
page, page,
}) => { }) => {
if (!tronApp) test.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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) { if (!app || !app.applicationMenu) {
test.fail() fail()
} }
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Help.Refresh and report a bug' 'Help.Refresh and report a bug'
) )
if (!menu) test.fail() if (!menu) fail()
menu.click() menu.click()
}) })
// Core dump and refresh magic number timeout // Core dump and refresh magic number timeout
@ -350,12 +350,12 @@ 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 tronApp.electron.evaluate(async ({ app }) => {
if (!app || !app.applicationMenu) test.fail() if (!app || !app.applicationMenu) fail()
const menu = app.applicationMenu.getMenuItemById( const menu = app.applicationMenu.getMenuItemById(
'Help.Reset onboarding' 'Help.Reset onboarding'
) )
if (!menu) { if (!menu) {
test.fail() fail()
} }
menu.click() menu.click()
}) })

View File

@ -71,13 +71,6 @@ export const FileMachineProvider = ({
} }
}, []) }, [])
// Only create the native file menus on desktop
useEffect(() => {
if (isDesktop()) {
window.electron.createModelingPageMenu().catch(reportRejection)
}
}, [])
useEffect(() => { useEffect(() => {
const { const {
createNamedViewCommand, createNamedViewCommand,

View File

@ -103,6 +103,7 @@ const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
if (reuse) { if (reuse) {
newWindow = mainWindow newWindow = mainWindow
Menu.setApplicationMenu(null)
} }
if (!newWindow) { if (!newWindow) {
const primaryDisplay = screen.getPrimaryDisplay() const primaryDisplay = screen.getPrimaryDisplay()