Skip to content

Commit 33aee21

Browse files
author
Douwe Osinga
committed
fix: resolve .env from repo root, strip quotes, extend flaky test timeout
- loadDotenv() now resolves .env from the repository root via __dirname instead of process.cwd(), matching the old shell script behavior when run from ui/desktop - Strip surrounding quotes from dotenv values so KEY="value" works - Give flaky tests a 120s timeout so the try/catch handler runs before vitest kills the test Signed-off-by: Douwe Osinga <douwe@squareup.com>
1 parent 6179927 commit 33aee21

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

ui/desktop/tests/integration/test_providers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ if (flaky.length > 0) {
9595
} catch (err) {
9696
console.warn(`Flaky test ${tc.provider}/${tc.model} failed (allowed): ${err}`);
9797
}
98-
});
98+
}, 120_000);
9999
}
100100

101101
if (skipped.length > 0) {

ui/desktop/tests/integration/test_providers_code_exec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (flaky.length > 0) {
6767
} catch (err) {
6868
console.warn(`Flaky test ${tc.provider}/${tc.model} failed (allowed): ${err}`);
6969
}
70-
});
70+
}, 120_000);
7171
}
7272

7373
if (skipped.length > 0) {

ui/desktop/tests/integration/test_providers_lib.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,17 @@ function getProviders(): ProviderConfig[] {
182182
// Helpers
183183
// ---------------------------------------------------------------------------
184184

185+
function stripQuotes(s: string): string {
186+
if (s.length >= 2 && ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'")))) {
187+
return s.slice(1, -1);
188+
}
189+
return s;
190+
}
191+
185192
function loadDotenv(): void {
186-
const envPath = path.resolve(process.cwd(), '.env');
193+
// Resolve .env from the repository root (two levels up from ui/desktop).
194+
const repoRoot = path.resolve(__dirname, '..', '..', '..', '..');
195+
const envPath = path.join(repoRoot, '.env');
187196
if (!fs.existsSync(envPath)) return;
188197
const lines = fs.readFileSync(envPath, 'utf-8').split('\n');
189198
for (const line of lines) {
@@ -192,7 +201,7 @@ function loadDotenv(): void {
192201
const eqIdx = trimmed.indexOf('=');
193202
if (eqIdx === -1) continue;
194203
const key = trimmed.slice(0, eqIdx);
195-
const value = trimmed.slice(eqIdx + 1);
204+
const value = stripQuotes(trimmed.slice(eqIdx + 1));
196205
if (!(key in process.env)) {
197206
process.env[key] = value;
198207
}

0 commit comments

Comments
 (0)