@@ -10,6 +10,22 @@ beforeEach(() => {
1010 mockInvoke . mockReset ( ) ;
1111 mockInvoke . mockImplementation ( ( cmd : string ) => {
1212 switch ( cmd ) {
13+ case 'fetch_all_state' :
14+ return Promise . resolve ( {
15+ monitors : [
16+ {
17+ id : 'builtin-0' ,
18+ uid : 'builtin-0::Built-in Display' ,
19+ name : 'Built-in Display' ,
20+ originalName : 'Built-in Display' ,
21+ brightness : 50 ,
22+ supportsBrightness : true ,
23+ isBuiltIn : true ,
24+ } ,
25+ ] ,
26+ isDark : false ,
27+ volume : 50 ,
28+ } ) ;
1329 case 'get_monitors' :
1430 return Promise . resolve ( [
1531 {
@@ -92,9 +108,9 @@ describe('App smoke test', () => {
92108 it ( 'fetches initial data on mount' , async ( ) => {
93109 render ( < App /> ) ;
94110 await waitFor ( ( ) => {
95- expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_monitors ' ) ;
96- expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_dark_mode ' ) ;
97- expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_volume ' ) ;
111+ expect ( mockInvoke ) . toHaveBeenCalledWith ( 'fetch_all_state ' ) ;
112+ expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_preferences ' ) ;
113+ expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_keep_awake ' ) ;
98114 expect ( mockInvoke ) . toHaveBeenCalledWith ( 'get_app_version' ) ;
99115 } ) ;
100116 } ) ;
@@ -187,38 +203,45 @@ describe('App smoke test', () => {
187203
188204 it ( 'renders with multiple monitors without JS errors' , async ( ) => {
189205 const errorSpy = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
206+ const multiMonitors = [
207+ {
208+ id : 'builtin-0' ,
209+ uid : 'builtin-0::Built-in Display' ,
210+ name : 'Built-in Display' ,
211+ originalName : 'Built-in Display' ,
212+ brightness : 100 ,
213+ supportsBrightness : true ,
214+ isBuiltIn : true ,
215+ } ,
216+ {
217+ id : '1' ,
218+ uid : '1::Dell U2723QE' ,
219+ name : 'Dell U2723QE' ,
220+ originalName : 'Dell U2723QE' ,
221+ brightness : 80 ,
222+ supportsBrightness : true ,
223+ isBuiltIn : false ,
224+ } ,
225+ {
226+ id : '2' ,
227+ uid : '2::LG 27UK850' ,
228+ name : '' ,
229+ originalName : 'LG 27UK850' ,
230+ brightness : 60 ,
231+ supportsBrightness : true ,
232+ isBuiltIn : false ,
233+ } ,
234+ ] ;
190235 mockInvoke . mockImplementation ( ( cmd : string ) => {
191236 switch ( cmd ) {
237+ case 'fetch_all_state' :
238+ return Promise . resolve ( {
239+ monitors : multiMonitors ,
240+ isDark : true ,
241+ volume : 75 ,
242+ } ) ;
192243 case 'get_monitors' :
193- return Promise . resolve ( [
194- {
195- id : 'builtin-0' ,
196- uid : 'builtin-0::Built-in Display' ,
197- name : 'Built-in Display' ,
198- originalName : 'Built-in Display' ,
199- brightness : 100 ,
200- supportsBrightness : true ,
201- isBuiltIn : true ,
202- } ,
203- {
204- id : '1' ,
205- uid : '1::Dell U2723QE' ,
206- name : 'Dell U2723QE' ,
207- originalName : 'Dell U2723QE' ,
208- brightness : 80 ,
209- supportsBrightness : true ,
210- isBuiltIn : false ,
211- } ,
212- {
213- id : '2' ,
214- uid : '2::LG 27UK850' ,
215- name : '' ,
216- originalName : 'LG 27UK850' ,
217- brightness : 60 ,
218- supportsBrightness : true ,
219- isBuiltIn : false ,
220- } ,
221- ] ) ;
244+ return Promise . resolve ( multiMonitors ) ;
222245 case 'get_dark_mode' :
223246 return Promise . resolve ( true ) ;
224247 case 'get_volume' :
@@ -279,20 +302,27 @@ describe('App smoke test', () => {
279302 } ) ;
280303
281304 it ( 'calls set_brightness with API id (not uid)' , async ( ) => {
305+ const singleMonitor = [
306+ {
307+ id : '1' ,
308+ uid : '1::Dell U2723QE' ,
309+ name : 'Dell U2723QE' ,
310+ originalName : 'Dell U2723QE' ,
311+ brightness : 50 ,
312+ supportsBrightness : true ,
313+ isBuiltIn : false ,
314+ } ,
315+ ] ;
282316 mockInvoke . mockImplementation ( ( cmd : string ) => {
283317 switch ( cmd ) {
318+ case 'fetch_all_state' :
319+ return Promise . resolve ( {
320+ monitors : singleMonitor ,
321+ isDark : false ,
322+ volume : 50 ,
323+ } ) ;
284324 case 'get_monitors' :
285- return Promise . resolve ( [
286- {
287- id : '1' ,
288- uid : '1::Dell U2723QE' ,
289- name : 'Dell U2723QE' ,
290- originalName : 'Dell U2723QE' ,
291- brightness : 50 ,
292- supportsBrightness : true ,
293- isBuiltIn : false ,
294- } ,
295- ] ) ;
325+ return Promise . resolve ( singleMonitor ) ;
296326 case 'get_dark_mode' :
297327 return Promise . resolve ( false ) ;
298328 case 'get_volume' :
0 commit comments