refactor(doctor): extract flow finalization#52067
Conversation
Greptile SummaryThis PR extracts the final "confirm/write" step of the doctor config flow into a dedicated
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/commands/doctor/finalize-config-flow.test.ts
Line: 46-61
Comment:
**Repair-mode test doesn't distinguish `cfg` from `candidate`**
In this test `cfg` and `candidate` are set to identical values, so the assertion passes regardless of whether the implementation returns `params.cfg` or `params.candidate`. In repair mode the intent is to return the already-repaired `cfg` (updated upstream by `runDoctorRepairSequence`), but a future refactor that accidentally returned `params.candidate` here would go undetected.
Consider using distinct objects so the test pins the exact returned value:
```suggestion
it("writes automatically in repair mode when changes exist", async () => {
const result = await finalizeDoctorConfigFlow({
cfg: { channels: { signal: { enabled: true } } },
candidate: { channels: { signal: { enabled: false } } }, // deliberately different
pendingChanges: true,
shouldRepair: true,
fixHints: [],
confirm: async () => true,
note: vi.fn(),
});
expect(result).toEqual({
cfg: { channels: { signal: { enabled: true } } }, // cfg, not candidate
shouldWriteConfig: true,
});
});
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "refactor(doctor): ex..." |
| it("writes automatically in repair mode when changes exist", async () => { | ||
| const result = await finalizeDoctorConfigFlow({ | ||
| cfg: { channels: { signal: { enabled: true } } }, | ||
| candidate: { channels: { signal: { enabled: true } } }, | ||
| pendingChanges: true, | ||
| shouldRepair: true, | ||
| fixHints: [], | ||
| confirm: async () => true, | ||
| note: vi.fn(), | ||
| }); | ||
|
|
||
| expect(result).toEqual({ | ||
| cfg: { channels: { signal: { enabled: true } } }, | ||
| shouldWriteConfig: true, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Repair-mode test doesn't distinguish
cfg from candidate
In this test cfg and candidate are set to identical values, so the assertion passes regardless of whether the implementation returns params.cfg or params.candidate. In repair mode the intent is to return the already-repaired cfg (updated upstream by runDoctorRepairSequence), but a future refactor that accidentally returned params.candidate here would go undetected.
Consider using distinct objects so the test pins the exact returned value:
| it("writes automatically in repair mode when changes exist", async () => { | |
| const result = await finalizeDoctorConfigFlow({ | |
| cfg: { channels: { signal: { enabled: true } } }, | |
| candidate: { channels: { signal: { enabled: true } } }, | |
| pendingChanges: true, | |
| shouldRepair: true, | |
| fixHints: [], | |
| confirm: async () => true, | |
| note: vi.fn(), | |
| }); | |
| expect(result).toEqual({ | |
| cfg: { channels: { signal: { enabled: true } } }, | |
| shouldWriteConfig: true, | |
| }); | |
| }); | |
| it("writes automatically in repair mode when changes exist", async () => { | |
| const result = await finalizeDoctorConfigFlow({ | |
| cfg: { channels: { signal: { enabled: true } } }, | |
| candidate: { channels: { signal: { enabled: false } } }, // deliberately different | |
| pendingChanges: true, | |
| shouldRepair: true, | |
| fixHints: [], | |
| confirm: async () => true, | |
| note: vi.fn(), | |
| }); | |
| expect(result).toEqual({ | |
| cfg: { channels: { signal: { enabled: true } } }, // cfg, not candidate | |
| shouldWriteConfig: true, | |
| }); | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/commands/doctor/finalize-config-flow.test.ts
Line: 46-61
Comment:
**Repair-mode test doesn't distinguish `cfg` from `candidate`**
In this test `cfg` and `candidate` are set to identical values, so the assertion passes regardless of whether the implementation returns `params.cfg` or `params.candidate`. In repair mode the intent is to return the already-repaired `cfg` (updated upstream by `runDoctorRepairSequence`), but a future refactor that accidentally returned `params.candidate` here would go undetected.
Consider using distinct objects so the test pins the exact returned value:
```suggestion
it("writes automatically in repair mode when changes exist", async () => {
const result = await finalizeDoctorConfigFlow({
cfg: { channels: { signal: { enabled: true } } },
candidate: { channels: { signal: { enabled: false } } }, // deliberately different
pendingChanges: true,
shouldRepair: true,
fixHints: [],
confirm: async () => true,
note: vi.fn(),
});
expect(result).toEqual({
cfg: { channels: { signal: { enabled: true } } }, // cfg, not candidate
shouldWriteConfig: true,
});
});
```
How can I resolve this? If you propose a fix, please make it concise.* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
The doctor config-flow refactor series (PRs openclaw#51753–openclaw#52067) extracted shared modules into src/commands/doctor/shared/ with companion test files. default-account-warnings.ts was the only substantive module (157 lines, two public functions) without direct test coverage. Adds 16 tests covering both exported functions: - collectMissingDefaultAccountBindingWarnings: wildcard bindings, partial coverage, no bindings, multi-channel isolation - collectMissingExplicitDefaultAccountWarnings: single vs multi account, matching/mismatched defaultAccount, missing defaultAccount Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg (cherry picked from commit ec59974)
* refactor(doctor): extract flow finalization * test(doctor): pin repair finalization to cfg (cherry picked from commit ec59974)
Summary
Testing
Thanks @vincentkoc