Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions ts/packages/shell/test/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,34 @@ export function getAppPath(): string {
return appPath;
}

/**
* Resolve the config file to pass via --env. Prefers `config.local.yaml`
* (the canonical key-config format) and falls back to a legacy `.env` so
* smoke tests work in both YAML-only and legacy developer environments.
* Throws if neither file is present.
*/
function resolveTestConfigPath(appPath: string): string {
const yamlPath = path.resolve(appPath, "../../config.local.yaml");
if (fs.existsSync(yamlPath)) {
return yamlPath;
}
const dotenvPath = path.resolve(appPath, "../../.env");
if (fs.existsSync(dotenvPath)) {
return dotenvPath;
}
throw new Error(
`No test config file found. Expected either ${yamlPath} or ${dotenvPath}. ` +
`Run 'node tools/scripts/getKeys.mjs --vault <name> --commit' to generate one.`,
);
}

/**
* Get electron launch arguments
* @returns The arguments to pass to the electron application
*/
export function getLaunchArgs(testGreetings: boolean): string[] {
const appPath = getAppPath();
const args = [
appPath,
"--test",
"--env",
path.resolve(appPath, "../../.env"),
];
const args = [appPath, "--test", "--env", resolveTestConfigPath(appPath)];
if (os.platform() === "linux") {
// Ubuntu 24.04+ needs --no-sandbox, see https://github.com/electron/electron/issues/18265
args.push("--no-sandbox");
Expand Down
Loading