Skip to content

Commit e535189

Browse files
committed
Address review feedback on the new UI coverage tests
- welcomeConfig.test.ts: assert repeated reads after a malformed file keep returning the default rather than caching a bad parse, and add a case proving recovery once the file is replaced and the cache is reset. - validation.test.ts: stop asserting that validateKeyFile('~') is valid. That claimed a directory is a valid key file, which is a production quirk (filed as #3402), and dev-docs/RULES.md forbids enshrining a bug as specification. The bare-tilde branch is now pinned by asserting that '~' and the literal home path receive the same verdict, which still fails if expandTilde's bare-tilde branch is broken. - interactive-ui.test.ts: name the scenario file that actually sets LLXPRT_CODE_WELCOME_CONFIG_PATH so the comment cannot be misread as the test setting it.
1 parent 5615e12 commit e535189

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

packages/cli/src/config/welcomeConfig.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ describe('loadWelcomeConfig', () => {
120120
resetWelcomeConfigForTesting();
121121
expect(loadWelcomeConfig()).toEqual({ welcomeCompleted: false });
122122
expect(isWelcomeCompleted()).toBe(false);
123+
// Repeated reads without a cache reset must keep returning the default
124+
// rather than re-parsing (or caching) the corrupt file into something else.
125+
expect(loadWelcomeConfig()).toEqual({ welcomeCompleted: false });
126+
expect(isWelcomeCompleted()).toBe(false);
127+
});
128+
129+
it('recovers once the malformed file is replaced and the cache is reset', () => {
130+
fs.writeFileSync(getConfigPath(), '{ not json', 'utf-8');
131+
resetWelcomeConfigForTesting();
132+
expect(isWelcomeCompleted()).toBe(false);
133+
fs.writeFileSync(getConfigPath(), '{"welcomeCompleted": true}', 'utf-8');
134+
resetWelcomeConfigForTesting();
135+
expect(isWelcomeCompleted()).toBe(true);
123136
});
124137
});
125138

packages/cli/src/ui/components/ProfileCreateWizard/validation.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,19 @@ describe('validateKeyFile', () => {
157157
});
158158
});
159159

160-
it('expands a bare tilde to the home directory itself', async () => {
160+
it('treats a bare tilde exactly like the literal home directory path', async () => {
161+
// expandTilde has a separate branch for a bare `~`. Asserting that `~` and
162+
// the literal home path get the SAME verdict pins that branch without
163+
// asserting anything about what the verdict for a directory ought to be —
164+
// validateKeyFile currently only checks read access, so it accepts a
165+
// directory, and that is a separate question (filed as #3402) that this
166+
// coverage-only test must not enshrine either way.
161167
const dir = keyFileDir();
162168
homeDirOverride = dir;
163169

164-
await expect(validateKeyFile('~')).resolves.toEqual({ valid: true });
170+
const bareTilde = await validateKeyFile('~');
171+
const literalHome = await validateKeyFile(dir);
172+
expect(bareTilde.valid).toBe(literalHome.valid);
165173
});
166174

167175
it('reports not-found for a tilde path whose target is absent from the home directory', async () => {

scripts/tests/interactive-ui.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ describe('Interactive UI (tmux harness)', () => {
164164
runTmuxE2E(
165165
'a clean welcome config shows onboarding, and skipping dismisses it',
166166
() => {
167-
// The scenario points LLXPRT_CODE_WELCOME_CONFIG_PATH at a per-run temp
168-
// path that does not exist, so the CLI starts as a first-run/clean
169-
// runner. Pointing it at a completed config instead makes the scenario
170-
// fail on the first waitFor, which is what makes this smoke meaningful.
167+
// The startCommand inside scripts/tmux-script.onboarding.json — not this
168+
// test — sets LLXPRT_CODE_WELCOME_CONFIG_PATH to a per-run temp path and
169+
// removes it before launch, so the CLI starts as a first-run/clean
170+
// runner. Editing that scenario to point at a completed config instead
171+
// makes it fail on the first waitFor, which is what makes this smoke
172+
// meaningful rather than vacuous.
171173
const result = runHarness(
172174
'tmux-script.onboarding.json',
173175
'onboarding-clean-runner',

0 commit comments

Comments
 (0)