@@ -5,6 +5,7 @@ import { render, screen, fireEvent } from '../../helpers/ui/render'
55import { CopilotPreferences } from '../../../src/ui/preferences/copilot'
66import {
77 DefaultCopilotModel ,
8+ DisabledCopilotModel ,
89 type CopilotFeature ,
910} from '../../../src/lib/stores/copilot-store'
1011import type { ModelInfo } from '@github/copilot-sdk'
@@ -103,8 +104,50 @@ describe('CopilotPreferences', () => {
103104 assert . strictEqual ( optgroups [ 0 ] . label , 'GitHub Copilot' )
104105
105106 const options = view . container . querySelectorAll ( 'option' )
106- assert . strictEqual ( options [ 0 ] . textContent , 'GPT-5 mini (default)' )
107- assert . strictEqual ( options [ 1 ] . textContent , 'Claude Sonnet' )
107+ assert . strictEqual ( options [ 0 ] . textContent , 'None (hide Copilot button)' )
108+ assert . strictEqual ( options [ 1 ] . textContent , 'GPT-5 mini (default)' )
109+ assert . strictEqual ( options [ 2 ] . textContent , 'Claude Sonnet' )
110+ } )
111+
112+ it ( 'offers a "None" option to disable commit message generation' , ( ) => {
113+ const view = render ( < CopilotPreferences { ...defaults ( ) } /> )
114+ const options = Array . from ( view . container . querySelectorAll ( 'option' ) )
115+ const none = options . find ( o => o . value === DisabledCopilotModel )
116+ assert . ok ( none )
117+ assert . strictEqual ( none ! . textContent , 'None (hide Copilot button)' )
118+ } )
119+
120+ it ( 'selects the None option when generation is disabled' , ( ) => {
121+ const view = render (
122+ < CopilotPreferences
123+ { ...defaults ( ) }
124+ selectedCopilotModels = { {
125+ 'commit-message-generation' : DisabledCopilotModel ,
126+ } }
127+ />
128+ )
129+ const select = view . container . querySelector ( 'select' ) as HTMLSelectElement
130+ assert . strictEqual ( select . value , DisabledCopilotModel )
131+ } )
132+
133+ it ( 'emits the None value when generation is disabled' , ( ) => {
134+ const changed : Array < { feature : CopilotFeature ; model : string | null } > = [ ]
135+ const view = render (
136+ < CopilotPreferences
137+ { ...defaults ( ) }
138+ onSelectedCopilotModelChanged = { ( f , m ) =>
139+ changed . push ( { feature : f , model : m } )
140+ }
141+ />
142+ )
143+ const select = view . container . querySelector ( 'select' ) as HTMLSelectElement
144+ fireEvent . change ( select , { target : { value : DisabledCopilotModel } } )
145+ assert . deepStrictEqual ( changed , [
146+ {
147+ feature : 'commit-message-generation' ,
148+ model : DisabledCopilotModel ,
149+ } ,
150+ ] )
108151 } )
109152
110153 it ( 'renders a BYOK optgroup per provider' , ( ) => {
0 commit comments