Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/components/topbar/CurrentUserPopover.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ afterAll(() => {
})

// Mock the useCurrentUser composable
const mockHandleSignOut = vi.fn()
vi.mock('@/composables/auth/useCurrentUser', () => ({
useCurrentUser: vi.fn(() => ({
userPhotoUrl: 'https://example.com/avatar.jpg',
userDisplayName: 'Test User',
userEmail: 'test@example.com'
userEmail: 'test@example.com',
handleSignOut: mockHandleSignOut
}))
}))

Expand Down Expand Up @@ -155,8 +157,8 @@ describe('CurrentUserPopover', () => {
// Click the logout button
await logoutButton.trigger('click')

// Verify logout was called
expect(mockLogout).toHaveBeenCalled()
// Verify handleSignOut was called
expect(mockHandleSignOut).toHaveBeenCalled()

// Verify close event was emitted
expect(wrapper.emitted('close')).toBeTruthy()
Expand Down
5 changes: 3 additions & 2 deletions src/components/topbar/CurrentUserPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const emit = defineEmits<{
close: []
}>()

const { userDisplayName, userEmail, userPhotoUrl } = useCurrentUser()
const { userDisplayName, userEmail, userPhotoUrl, handleSignOut } =
useCurrentUser()
const authActions = useFirebaseAuthActions()
const dialogService = useDialogService()

Expand All @@ -103,7 +104,7 @@ const handleTopUp = () => {
}

const handleLogout = async () => {
await authActions.logout()
await handleSignOut()
emit('close')
}

Expand Down