save as bw compatible (#6088)
* save as bw compatible Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * js side only for bw compatibility changes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * failure for doing wrong thing Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove from ts side Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,5 +1,4 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
|
||||
import type {
|
||||
BrowserContext,
|
||||
ElectronApplication,
|
||||
@ -9,10 +8,9 @@ import type {
|
||||
|
||||
import { _electron as electron } from '@playwright/test'
|
||||
|
||||
import * as TOML from '@iarna/toml'
|
||||
import { TEST_SETTINGS } from '../storageStates'
|
||||
import { SETTINGS_FILE_NAME } from 'lib/constants'
|
||||
import { getUtils, setup } from '../test-utils'
|
||||
import { getUtils, setup, settingsToToml } from '../test-utils'
|
||||
import fsp from 'fs/promises'
|
||||
import fs from 'node:fs'
|
||||
import path from 'path'
|
||||
@ -287,26 +285,30 @@ export class ElectronZoo {
|
||||
let settingsOverridesToml = ''
|
||||
|
||||
if (appSettings) {
|
||||
settingsOverridesToml = TOML.stringify({
|
||||
// @ts-expect-error
|
||||
settingsOverridesToml = settingsToToml({
|
||||
settings: {
|
||||
...TEST_SETTINGS,
|
||||
...appSettings,
|
||||
app: {
|
||||
...TEST_SETTINGS.app,
|
||||
project_directory: this.projectDirName,
|
||||
...appSettings.app,
|
||||
},
|
||||
project: {
|
||||
...TEST_SETTINGS.project,
|
||||
directory: this.projectDirName,
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
settingsOverridesToml = TOML.stringify({
|
||||
// @ts-expect-error
|
||||
settingsOverridesToml = settingsToToml({
|
||||
settings: {
|
||||
...TEST_SETTINGS,
|
||||
app: {
|
||||
...TEST_SETTINGS.app,
|
||||
project_directory: this.projectDirName,
|
||||
},
|
||||
project: {
|
||||
...TEST_SETTINGS.project,
|
||||
directory: this.projectDirName,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -345,7 +345,9 @@ const extrudeDefaultPlane = async (
|
||||
app: {
|
||||
onboarding_status: 'dismissed',
|
||||
show_debug_panel: true,
|
||||
theme: 'dark',
|
||||
appearance: {
|
||||
theme: 'dark',
|
||||
},
|
||||
},
|
||||
project: {
|
||||
default_project_name: 'project-$nnn',
|
||||
|
||||
@ -9,9 +9,10 @@ export const IS_PLAYWRIGHT_KEY = 'playwright'
|
||||
export const TEST_SETTINGS_KEY = '/settings.toml'
|
||||
export const TEST_SETTINGS: DeepPartial<Settings> = {
|
||||
app: {
|
||||
theme: Themes.Dark,
|
||||
appearance: {
|
||||
theme: Themes.Dark,
|
||||
},
|
||||
onboarding_status: 'dismissed',
|
||||
project_directory: '',
|
||||
show_debug_panel: true,
|
||||
},
|
||||
modeling: {
|
||||
@ -22,6 +23,7 @@ export const TEST_SETTINGS: DeepPartial<Settings> = {
|
||||
},
|
||||
project: {
|
||||
default_project_name: 'project-$nnn',
|
||||
directory: '',
|
||||
},
|
||||
text_editor: {
|
||||
text_wrapping: true,
|
||||
@ -54,7 +56,7 @@ export const TEST_SETTINGS_ONBOARDING_START: DeepPartial<Settings> = {
|
||||
|
||||
export const TEST_SETTINGS_DEFAULT_THEME: DeepPartial<Settings> = {
|
||||
...TEST_SETTINGS,
|
||||
app: { ...TEST_SETTINGS.app, theme: Themes.System },
|
||||
app: { ...TEST_SETTINGS.app, appearance: { theme: Themes.System } },
|
||||
}
|
||||
|
||||
export const TEST_SETTINGS_CORRUPTED = {
|
||||
|
||||
@ -903,15 +903,21 @@ export async function setup(
|
||||
settings: {
|
||||
...TEST_SETTINGS,
|
||||
app: {
|
||||
appearance: {
|
||||
...TEST_SETTINGS.app?.appearance,
|
||||
theme: 'dark',
|
||||
},
|
||||
...TEST_SETTINGS.project,
|
||||
project_directory: TEST_SETTINGS.app?.project_directory,
|
||||
onboarding_status: 'dismissed',
|
||||
theme: 'dark',
|
||||
},
|
||||
project: {
|
||||
...TEST_SETTINGS.project,
|
||||
directory: TEST_SETTINGS.project?.directory,
|
||||
},
|
||||
},
|
||||
}),
|
||||
IS_PLAYWRIGHT_KEY,
|
||||
PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.app?.project_directory || '',
|
||||
PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.project?.directory || '',
|
||||
PERSIST_MODELING_CONTEXT,
|
||||
}
|
||||
)
|
||||
@ -1112,21 +1118,25 @@ export async function pollEditorLinesSelectedLength(page: Page, lines: number) {
|
||||
}
|
||||
|
||||
export function settingsToToml(settings: DeepPartial<Configuration>) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
return TOML.stringify(settings as any)
|
||||
}
|
||||
|
||||
export function tomlToSettings(toml: string): DeepPartial<Configuration> {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
return TOML.parse(toml)
|
||||
}
|
||||
|
||||
export function tomlToPerProjectSettings(
|
||||
toml: string
|
||||
): DeepPartial<ProjectConfiguration> {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
return TOML.parse(toml)
|
||||
}
|
||||
|
||||
export function perProjectsettingsToToml(
|
||||
settings: DeepPartial<ProjectConfiguration>
|
||||
) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
return TOML.stringify(settings as any)
|
||||
}
|
||||
|
||||
@ -45,12 +45,12 @@ test.describe('Testing settings', () => {
|
||||
)
|
||||
)
|
||||
|
||||
expect(storedSettings.settings?.app?.theme).toBe('dark')
|
||||
expect(storedSettings.settings?.app?.appearance?.theme).toBe('dark')
|
||||
|
||||
// Check that the invalid settings were changed to good defaults
|
||||
expect(storedSettings.settings?.modeling?.base_unit).toBe('in')
|
||||
expect(storedSettings.settings?.modeling?.mouse_controls).toBe('zoo')
|
||||
expect(storedSettings.settings?.app?.project_directory).toBe('')
|
||||
expect(storedSettings.settings?.project?.directory).toBe('')
|
||||
expect(storedSettings.settings?.project?.default_project_name).toBe(
|
||||
'project-$nnn'
|
||||
)
|
||||
@ -381,7 +381,9 @@ test.describe('Testing settings', () => {
|
||||
}
|
||||
await tronApp.cleanProjectDir({
|
||||
app: {
|
||||
theme_color: '259',
|
||||
appearance: {
|
||||
color: 259,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -413,9 +415,12 @@ test.describe('Testing settings', () => {
|
||||
|
||||
await tronApp.cleanProjectDir({
|
||||
app: {
|
||||
// Doesn't matter what you set it to. It will
|
||||
// default to 264.5
|
||||
theme_color: '0',
|
||||
appearance: {
|
||||
// Doesn't matter what you set it to. It will
|
||||
// default to 264.5
|
||||
|
||||
color: 0,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user