Fix a couple issues with settings reset on web & electron (#3564)
* Fix a couple issues with settings reset on web & electron * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jess Frazelle <jessfraz@users.noreply.github.com>
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 71 KiB |
@ -115,8 +115,7 @@ test.describe('Testing settings', () => {
|
|||||||
).not.toBeChecked()
|
).not.toBeChecked()
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO fixme reset doesn't seem to work for color setting
|
test('Project and user settings can be reset', async ({ page }) => {
|
||||||
test.fixme('Project and user settings can be reset', async ({ page }) => {
|
|
||||||
const u = await getUtils(page)
|
const u = await getUtils(page)
|
||||||
await page.setViewportSize({ width: 1200, height: 500 })
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
await u.waitForAuthSkipAppStart()
|
await u.waitForAuthSkipAppStart()
|
||||||
@ -161,6 +160,11 @@ test.describe('Testing settings', () => {
|
|||||||
// Click the reset settings button.
|
// Click the reset settings button.
|
||||||
await resetButton.click()
|
await resetButton.click()
|
||||||
|
|
||||||
|
await expect(page.getByText('Settings restored to default')).toBeVisible()
|
||||||
|
await expect(
|
||||||
|
page.getByText('Settings restored to default')
|
||||||
|
).not.toBeVisible()
|
||||||
|
|
||||||
// Verify it is now set to the inherited user value
|
// Verify it is now set to the inherited user value
|
||||||
await expect(themeColorSetting).toHaveValue(settingValues.default)
|
await expect(themeColorSetting).toHaveValue(settingValues.default)
|
||||||
|
|
||||||
|
|||||||
@ -407,6 +407,9 @@ const getProjectSettingsFilePath = async (projectPath: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getInitialDefaultDir = async () => {
|
export const getInitialDefaultDir = async () => {
|
||||||
|
if (!window.electron) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
const dir = await window.electron.getPath('documents')
|
const dir = await window.electron.getPath('documents')
|
||||||
return window.electron.path.join(dir, PROJECT_FOLDER)
|
return window.electron.path.join(dir, PROJECT_FOLDER)
|
||||||
}
|
}
|
||||||
@ -447,6 +450,12 @@ export const readAppSettingsFile = async () => {
|
|||||||
}
|
}
|
||||||
const configToml = await window.electron.readFile(settingsPath)
|
const configToml = await window.electron.readFile(settingsPath)
|
||||||
const configObj = parseAppSettings(configToml)
|
const configObj = parseAppSettings(configToml)
|
||||||
|
if (!configObj.app) {
|
||||||
|
return Promise.reject(new Error('config.app is falsey'))
|
||||||
|
}
|
||||||
|
if (!configObj.app.projectDirectory) {
|
||||||
|
configObj.app.projectDirectory = await getInitialDefaultDir()
|
||||||
|
}
|
||||||
return configObj
|
return configObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||