Skip to content

Commit 117d576

Browse files
committed
test(sync): strip CI env from --force e2e helpers
GitHub Actions and GitLab CI set CI=true, which the sync --force guard in register-sync-root.ts checks before the TTY branch. Two tests were inheriting CI=true via {...process.env, ...} and hitting the CI-guard exit (6) instead of the branch they were written to cover: - cli-sync.e2e.test.ts "should retranslate with --force" runSyncAll('--force') -> execSync threw Command failed. Fix in the shared buildEnv() so every CI-neutral invocation in this file is unaffected by the runner's CI flag. - cli-sync-force-guard.e2e.test.ts "proceeds without prompting when stdin is not a TTY" Explicitly asserts status !== 6 for the piped-stdin / no-yes branch; CI-guard fired first. Strip CI only in that one case; the sibling "CI=true --force without --yes" test still sets CI=true explicitly.
1 parent be5473d commit 117d576

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

tests/e2e/cli-sync-force-guard.e2e.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ describe('deepl sync --force billing defense', () => {
168168

169169
describe('non-TTY stdin (piped) without --yes', () => {
170170
it('proceeds without prompting when stdin is not a TTY', () => {
171-
// spawnSync with input= sets stdin to a pipe, so isTTY is false
171+
// spawnSync with input= sets stdin to a pipe, so isTTY is false.
172+
// CI is stripped so the CI-guard branch does not pre-empt the TTY branch
173+
// this test is designed to exercise (GitHub Actions / GitLab CI set CI=true).
174+
const { CI: _ci, ...baseEnv } = process.env;
172175
const result = run(['--force', '--dry-run'], {
173176
cwd: tmpDir,
174-
env: { ...process.env, DEEPL_CONFIG_DIR: path.join(tmpDir, 'config'), NO_COLOR: '1' },
177+
env: { ...baseEnv, DEEPL_CONFIG_DIR: path.join(tmpDir, 'config'), NO_COLOR: '1' },
175178
input: 'y\n',
176179
});
177180

tests/e2e/cli-sync.e2e.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ describe('CLI Sync E2E', () => {
9595
}
9696

9797
function buildEnv(): Record<string, string | undefined> {
98+
// Strip CI so the --force billing guard (register-sync-root.ts) does not
99+
// fire its CI-without-yes branch when these tests run under GitHub Actions
100+
// / GitLab CI. Individual tests that exercise CI semantics set CI=true
101+
// explicitly.
102+
const { CI: _ci, ...rest } = process.env;
98103
return {
99-
...process.env,
104+
...rest,
100105
DEEPL_CONFIG_DIR: testConfig.path,
101106
NO_COLOR: '1',
102107
};

0 commit comments

Comments
 (0)