Types on test settings (#5643)

* type check the test settings

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fix another

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jess Frazelle
2025-03-05 18:03:49 -08:00
committed by GitHub
parent 00ff6371ed
commit 8aa46099a8
11 changed files with 122 additions and 86 deletions

View File

@ -28,6 +28,9 @@ import { SETTINGS_FILE_NAME } from 'lib/constants'
import { isErrorWhitelisted } from './lib/console-error-whitelist'
import { isArray } from 'lib/utils'
import { reportRejection } from 'lib/trap'
import { DeepPartial } from 'lib/types'
import { Configuration } from 'lang/wasm'
import { Settings } from '@rust/kcl-lib/bindings/Settings'
const toNormalizedCode = (text: string) => {
return text.replace(/\s+/g, '')
@ -894,19 +897,19 @@ export async function setup(
{
token: secrets.token,
settingsKey: TEST_SETTINGS_KEY,
settings: TOML.stringify({
settings: settingsToToml({
settings: {
...TEST_SETTINGS,
app: {
...TEST_SETTINGS.projects,
projectDirectory: TEST_SETTINGS.app.projectDirectory,
onboardingStatus: 'dismissed',
...TEST_SETTINGS.project,
project_directory: TEST_SETTINGS.app?.project_directory,
onboarding_status: 'dismissed',
theme: 'dark',
},
} as Partial<SaveSettingsPayload>,
},
}),
IS_PLAYWRIGHT_KEY,
PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.app.projectDirectory,
PLAYWRIGHT_TEST_DIR: TEST_SETTINGS.app?.project_directory || '',
PERSIST_MODELING_CONTEXT,
}
)
@ -942,7 +945,7 @@ export async function setupElectron({
testInfo: TestInfo
folderSetupFn?: (projectDirName: string) => Promise<void>
cleanProjectDir?: boolean
appSettings?: Partial<SaveSettingsPayload>
appSettings?: DeepPartial<Settings>
viewport: {
width: number
height: number
@ -1001,7 +1004,7 @@ export async function setupElectron({
if (cleanProjectDir) {
const tempSettingsFilePath = path.join(projectDirName, SETTINGS_FILE_NAME)
const settingsOverrides = TOML.stringify(
const settingsOverrides = settingsToToml(
appSettings
? {
settings: {
@ -1009,7 +1012,7 @@ export async function setupElectron({
...appSettings,
app: {
...TEST_SETTINGS.app,
projectDirectory: projectDirName,
project_directory: projectDirName,
...appSettings.app,
},
},
@ -1019,7 +1022,7 @@ export async function setupElectron({
...TEST_SETTINGS,
app: {
...TEST_SETTINGS.app,
projectDirectory: projectDirName,
project_directory: projectDirName,
},
},
}
@ -1213,3 +1216,11 @@ export async function pollEditorLinesSelectedLength(page: Page, lines: number) {
})
.toBe(lines)
}
export function settingsToToml(settings: DeepPartial<Configuration>) {
return TOML.stringify(settings as any)
}
export function tomlToSettings(toml: string): DeepPartial<Configuration> {
return TOML.parse(toml)
}