diff --git a/e2e/playwright/electron-setup.spec.ts b/e2e/playwright/electron-setup.spec.ts index 52e2883f1..f703a6c80 100644 --- a/e2e/playwright/electron-setup.spec.ts +++ b/e2e/playwright/electron-setup.spec.ts @@ -38,9 +38,11 @@ test('Electron setup', { tag: '@electron' }, async () => { }, { settingsKey: TEST_SETTINGS_KEY, - settings: TOML.stringify({ settings: { - app: { projectDirectory: fullPath }, - } }), + settings: TOML.stringify({ + settings: { + app: { projectDirectory: fullPath }, + }, + }), } ) }) diff --git a/e2e/playwright/projects.spec.ts b/e2e/playwright/projects.spec.ts index 981055da7..bb7636952 100644 --- a/e2e/playwright/projects.spec.ts +++ b/e2e/playwright/projects.spec.ts @@ -1,9 +1,7 @@ import { _electron as electron, test, expect } from '@playwright/test' import { getUtils, setup, tearDown } from './test-utils' import fs from 'fs/promises' -import { secrets } from './secrets' import { join } from 'path' -import { tomlStringify } from 'lang/wasm' test.afterEach(async ({ page }, testInfo) => { await tearDown(page, testInfo) @@ -16,7 +14,7 @@ test( // create or otherwise clear the folder ./electron-test-projects-dir const settingsFileName = `./${testInfo.title .replace(/\s/gi, '-') - .replace(/\W/gi, '')}` + .replace(/![\w-]/gi, '')}` const projectDirName = settingsFileName + '-dir' try { await fs.rm(projectDirName, { recursive: true }) @@ -35,21 +33,15 @@ test( const context = electronApp.context() const page = await electronApp.firstWindow() + await page.goto('http://localhost:3000/') const electronTempDirectory = await page.evaluate(async () => { - return await window.electron.getPath( - 'temp' - ) + return await window.electron.getPath('temp') }) const tempSettingsFilePath = join(electronTempDirectory, settingsFileName) - const settingsOverrides = tomlStringify({ - app: { - projectDirectory: fullProjectPath, - }, - }) + const settingsOverrides = `[settings.project] +directory = "/Users/frankjohnson/Documents/zoo-modeling-app-projects-2" +` - if (settingsOverrides instanceof Error) { - throw settingsOverrides - } await fs.writeFile(tempSettingsFilePath + '.toml', settingsOverrides) console.log('from within test setup', { diff --git a/e2e/playwright/test-utils.ts b/e2e/playwright/test-utils.ts index e1a4498cf..a910f6ea3 100644 --- a/e2e/playwright/test-utils.ts +++ b/e2e/playwright/test-utils.ts @@ -609,7 +609,11 @@ export async function tearDown(page: Page, testInfo: TestInfo) { // settingsOverrides may need to be augmented to take more generic items, // but we'll be strict for now -export async function setup(context: BrowserContext, page: Page, overrideDirectory?: string) { +export async function setup( + context: BrowserContext, + page: Page, + overrideDirectory?: string +) { // wait for Vite preview server to be up await waitOn({ resources: ['tcp:3000'], @@ -630,7 +634,8 @@ export async function setup(context: BrowserContext, page: Page, overrideDirecto ...TEST_SETTINGS, app: { ...TEST_SETTINGS.app, - projectDirectory: overrideDirectory || TEST_SETTINGS.app.projectDirectory, + projectDirectory: + overrideDirectory || TEST_SETTINGS.app.projectDirectory, }, }), } diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 310af6b72..867598cef 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -56,4 +56,4 @@ export const KCL_DEFAULT_CONSTANT_PREFIXES = { /** The default KCL length expression */ export const KCL_DEFAULT_LENGTH = `5` /** localStorage key for the playwright test-specific app settings file */ -export const TEST_SETTINGS_FILE_KEY = 'playwright-test-settings' \ No newline at end of file +export const TEST_SETTINGS_FILE_KEY = 'playwright-test-settings' diff --git a/src/lib/desktop.ts b/src/lib/desktop.ts index 75bdbb571..9cf488a85 100644 --- a/src/lib/desktop.ts +++ b/src/lib/desktop.ts @@ -377,7 +377,8 @@ export async function writeProjectSettingsFile( const getAppSettingsFilePath = async () => { const isPlaywright = window.localStorage.getItem('playwright') === 'true' - const testDirectoryName = window.localStorage.getItem(TEST_SETTINGS_FILE_KEY) ?? '' + const testDirectoryName = + window.localStorage.getItem(TEST_SETTINGS_FILE_KEY) ?? '' const appConfig = await window.electron.getPath( isPlaywright ? 'temp' : 'appData' )