Set a default initial directory, handle an existing settings file with no project directory (#3734)
* Fix the project directory setting assignment from file * Fix default project directory value initialization * Add a couple tests for loading the app without project directory settings * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * trigger CI * Object merging logic was bad, blew away other app settings if they existed * Update silly little export file size expectation numbers * Make rename timeout in test way shorter * Fix silly little test issues --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
This commit is contained in:
		@ -852,10 +852,12 @@ export async function setupElectron({
 | 
			
		||||
  testInfo,
 | 
			
		||||
  folderSetupFn,
 | 
			
		||||
  cleanProjectDir = true,
 | 
			
		||||
  appSettings,
 | 
			
		||||
}: {
 | 
			
		||||
  testInfo: TestInfo
 | 
			
		||||
  folderSetupFn?: (projectDirName: string) => Promise<void>
 | 
			
		||||
  cleanProjectDir?: boolean
 | 
			
		||||
  appSettings?: Partial<SaveSettingsPayload>
 | 
			
		||||
}) {
 | 
			
		||||
  // create or otherwise clear the folder
 | 
			
		||||
  const projectDirName = testInfo.outputPath('electron-test-projects-dir')
 | 
			
		||||
@ -889,15 +891,19 @@ export async function setupElectron({
 | 
			
		||||
 | 
			
		||||
  if (cleanProjectDir) {
 | 
			
		||||
    const tempSettingsFilePath = join(projectDirName, SETTINGS_FILE_NAME)
 | 
			
		||||
    const settingsOverrides = TOML.stringify({
 | 
			
		||||
      ...TEST_SETTINGS,
 | 
			
		||||
      settings: {
 | 
			
		||||
        app: {
 | 
			
		||||
          ...TEST_SETTINGS.app,
 | 
			
		||||
          projectDirectory: projectDirName,
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
    const settingsOverrides = TOML.stringify(
 | 
			
		||||
      appSettings
 | 
			
		||||
        ? { settings: appSettings }
 | 
			
		||||
        : {
 | 
			
		||||
            ...TEST_SETTINGS,
 | 
			
		||||
            settings: {
 | 
			
		||||
              app: {
 | 
			
		||||
                ...TEST_SETTINGS.app,
 | 
			
		||||
                projectDirectory: projectDirName,
 | 
			
		||||
              },
 | 
			
		||||
            },
 | 
			
		||||
          }
 | 
			
		||||
    )
 | 
			
		||||
    await fsp.writeFile(tempSettingsFilePath, settingsOverrides)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user