1- import { describe , expect , it } from "vitest" ;
1+ import { beforeEach , describe , expect , it , vi } from "vitest" ;
22import {
33 resolveDoctorHealthContributions ,
44 shouldSkipLegacyUpdateDoctorConfigWrite ,
55} from "./doctor-health-contributions.js" ;
66
7+ const mocks = vi . hoisted ( ( ) => ( {
8+ maybeRunConfiguredPluginInstallReleaseStep : vi . fn ( ) ,
9+ note : vi . fn ( ) ,
10+ } ) ) ;
11+
12+ vi . mock ( "../commands/doctor/shared/release-configured-plugin-installs.js" , ( ) => ( {
13+ maybeRunConfiguredPluginInstallReleaseStep : mocks . maybeRunConfiguredPluginInstallReleaseStep ,
14+ } ) ) ;
15+
16+ vi . mock ( "../terminal/note.js" , ( ) => ( {
17+ note : mocks . note ,
18+ } ) ) ;
19+
20+ vi . mock ( "../version.js" , ( ) => ( {
21+ VERSION : "2026.5.2-test" ,
22+ } ) ) ;
23+
724describe ( "doctor health contributions" , ( ) => {
25+ beforeEach ( ( ) => {
26+ mocks . maybeRunConfiguredPluginInstallReleaseStep . mockReset ( ) ;
27+ mocks . note . mockReset ( ) ;
28+ } ) ;
29+
830 it ( "runs release configured plugin install repair before plugin registry and final config writes" , ( ) => {
931 const ids = resolveDoctorHealthContributions ( ) . map ( ( entry ) => entry . id ) ;
1032
@@ -15,6 +37,58 @@ describe("doctor health contributions", () => {
1537 ) ;
1638 expect ( ids . indexOf ( "doctor:plugin-registry" ) ) . toBeLessThan ( ids . indexOf ( "doctor:write-config" ) ) ;
1739 } ) ;
40+
41+ it ( "keeps release configured plugin installs repair-only" , async ( ) => {
42+ const contribution = resolveDoctorHealthContributions ( ) . find (
43+ ( entry ) => entry . id === "doctor:release-configured-plugin-installs" ,
44+ ) ;
45+ expect ( contribution ) . toBeDefined ( ) ;
46+ const ctx = {
47+ cfg : { } ,
48+ configResult : { cfg : { } , sourceLastTouchedVersion : "2026.4.29" } ,
49+ sourceConfigValid : true ,
50+ prompter : { shouldRepair : false } ,
51+ env : { } ,
52+ } as Parameters < NonNullable < typeof contribution > [ "run" ] > [ 0 ] ;
53+
54+ await contribution ?. run ( ctx ) ;
55+
56+ expect ( mocks . maybeRunConfiguredPluginInstallReleaseStep ) . not . toHaveBeenCalled ( ) ;
57+ expect ( mocks . note ) . not . toHaveBeenCalled ( ) ;
58+ } ) ;
59+
60+ it ( "stamps release configured plugin installs after repair changes" , async ( ) => {
61+ mocks . maybeRunConfiguredPluginInstallReleaseStep . mockResolvedValue ( {
62+ changes : [ "Installed configured plugin matrix." ] ,
63+ warnings : [ ] ,
64+ touchedConfig : true ,
65+ } ) ;
66+ const contribution = resolveDoctorHealthContributions ( ) . find (
67+ ( entry ) => entry . id === "doctor:release-configured-plugin-installs" ,
68+ ) ;
69+ expect ( contribution ) . toBeDefined ( ) ;
70+ const ctx = {
71+ cfg : { } ,
72+ configResult : { cfg : { } , sourceLastTouchedVersion : "2026.4.29" } ,
73+ sourceConfigValid : true ,
74+ prompter : { shouldRepair : true } ,
75+ env : { } ,
76+ } as Parameters < NonNullable < typeof contribution > [ "run" ] > [ 0 ] ;
77+
78+ await contribution ?. run ( ctx ) ;
79+
80+ expect ( mocks . maybeRunConfiguredPluginInstallReleaseStep ) . toHaveBeenCalledWith ( {
81+ cfg : { } ,
82+ env : { } ,
83+ touchedVersion : "2026.4.29" ,
84+ } ) ;
85+ expect ( mocks . note ) . toHaveBeenCalledWith (
86+ "Installed configured plugin matrix." ,
87+ "Doctor changes" ,
88+ ) ;
89+ expect ( ctx . cfg . meta ?. lastTouchedVersion ) . toBe ( "2026.5.2-test" ) ;
90+ } ) ;
91+
1892 it ( "checks command owner configuration before final config writes" , ( ) => {
1993 const ids = resolveDoctorHealthContributions ( ) . map ( ( entry ) => entry . id ) ;
2094
0 commit comments