@@ -50,9 +50,11 @@ vi.mock('@/composables/auth/useCurrentUser', () => ({
5050} ) )
5151
5252// Mock the useFirebaseAuthActions composable
53+ const mockLogout = vi . fn ( )
5354vi . mock ( '@/composables/auth/useFirebaseAuthActions' , ( ) => ( {
5455 useFirebaseAuthActions : vi . fn ( ( ) => ( {
55- fetchBalance : vi . fn ( ) . mockResolvedValue ( undefined )
56+ fetchBalance : vi . fn ( ) . mockResolvedValue ( undefined ) ,
57+ logout : mockLogout
5658 } ) )
5759} ) )
5860
@@ -100,8 +102,7 @@ describe('CurrentUserPopover', () => {
100102 global : {
101103 plugins : [ i18n ] ,
102104 stubs : {
103- Divider : true ,
104- Button : true
105+ Divider : true
105106 }
106107 }
107108 } )
@@ -114,6 +115,18 @@ describe('CurrentUserPopover', () => {
114115 expect ( wrapper . text ( ) ) . toContain ( '[email protected] ' ) 115116 } )
116117
118+ it ( 'renders logout button with correct props' , ( ) => {
119+ const wrapper = mountComponent ( )
120+
121+ // Find all buttons and get the logout button (second one)
122+ const buttons = wrapper . findAllComponents ( Button )
123+ const logoutButton = buttons [ 1 ]
124+
125+ // Check that logout button has correct props
126+ expect ( logoutButton . props ( 'label' ) ) . toBe ( 'Log Out' )
127+ expect ( logoutButton . props ( 'icon' ) ) . toBe ( 'pi pi-sign-out' )
128+ } )
129+
117130 it ( 'opens user settings and emits close event when settings button is clicked' , async ( ) => {
118131 const wrapper = mountComponent ( )
119132
@@ -132,12 +145,30 @@ describe('CurrentUserPopover', () => {
132145 expect ( wrapper . emitted ( 'close' ) ! . length ) . toBe ( 1 )
133146 } )
134147
148+ it ( 'calls logout function and emits close event when logout button is clicked' , async ( ) => {
149+ const wrapper = mountComponent ( )
150+
151+ // Find all buttons and get the logout button (second one)
152+ const buttons = wrapper . findAllComponents ( Button )
153+ const logoutButton = buttons [ 1 ]
154+
155+ // Click the logout button
156+ await logoutButton . trigger ( 'click' )
157+
158+ // Verify logout was called
159+ expect ( mockLogout ) . toHaveBeenCalled ( )
160+
161+ // Verify close event was emitted
162+ expect ( wrapper . emitted ( 'close' ) ) . toBeTruthy ( )
163+ expect ( wrapper . emitted ( 'close' ) ! . length ) . toBe ( 1 )
164+ } )
165+
135166 it ( 'opens API pricing docs and emits close event when API pricing button is clicked' , async ( ) => {
136167 const wrapper = mountComponent ( )
137168
138- // Find all buttons and get the API pricing button (second one)
169+ // Find all buttons and get the API pricing button (third one now )
139170 const buttons = wrapper . findAllComponents ( Button )
140- const apiPricingButton = buttons [ 1 ]
171+ const apiPricingButton = buttons [ 2 ]
141172
142173 // Click the API pricing button
143174 await apiPricingButton . trigger ( 'click' )
0 commit comments