@@ -317,6 +317,46 @@ describe('Geocoder Module', () => {
317317
318318 expect ( results . activities [ 0 ] ?. latitude ) . toBeCloseTo ( 48.8 , 1 )
319319 expect ( results . activities [ 0 ] ?. placeLookupSource ) . toBe ( 'places_api' )
320+ expect ( results . activities [ 0 ] ?. matchedPlaceName ) . toBe ( 'Eiffel Tower' )
321+ } )
322+
323+ it ( 'preserves the matched Google place name for venue lookups' , async ( ) => {
324+ mockFetch . mockResolvedValue ( {
325+ ok : true ,
326+ json : async ( ) =>
327+ createPlacesResponse (
328+ - 36.8734 ,
329+ 174.7606 ,
330+ '193 Symonds Street, Eden Terrace, Auckland 1010, New Zealand' ,
331+ 'Kazuya'
332+ )
333+ } )
334+
335+ const activity = createTestActivity ( {
336+ activity : 'Dinner at Kazuya' ,
337+ category : 'food' ,
338+ score : 0.9 ,
339+ placeQuery : 'Kazuya' ,
340+ city : 'Auckland' ,
341+ messages : [
342+ {
343+ id : 1 ,
344+ sender : 'Test User' ,
345+ timestamp : new Date ( '2025-01-15T10:30:00Z' ) ,
346+ message : 'Dinner at Kazuya'
347+ }
348+ ]
349+ } )
350+
351+ const results = await lookupActivityPlaces ( [ activity ] , {
352+ apiKey : 'test-key'
353+ } )
354+
355+ expect ( results . activities [ 0 ] ?. placeLookupSource ) . toBe ( 'places_api' )
356+ expect ( results . activities [ 0 ] ?. matchedPlaceName ) . toBe ( 'Kazuya' )
357+ expect ( results . activities [ 0 ] ?. formattedAddress ) . toBe (
358+ '193 Symonds Street, Eden Terrace, Auckland 1010, New Zealand'
359+ )
320360 } )
321361
322362 it ( 'returns activity without coordinates when all geocoding fails' , async ( ) => {
@@ -337,6 +377,33 @@ describe('Geocoder Module', () => {
337377 expect ( results . activities [ 0 ] ?. longitude ) . toBeUndefined ( )
338378 } )
339379
380+ it ( 'logs provider errors when Google denies the lookup' , async ( ) => {
381+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => undefined )
382+
383+ mockFetch . mockResolvedValue ( {
384+ ok : true ,
385+ json : async ( ) => ( {
386+ status : 'REQUEST_DENIED' ,
387+ results : [ ] ,
388+ error_message : 'Billing disabled'
389+ } )
390+ } )
391+
392+ const activity = createActivity ( 1 , 'Rotoroa Island' , 'Auckland' )
393+
394+ const results = await lookupActivityPlaces ( [ activity ] , {
395+ apiKey : 'test-key'
396+ } )
397+
398+ expect ( results . activities [ 0 ] ?. latitude ) . toBeUndefined ( )
399+ expect ( warnSpy ) . toHaveBeenCalledWith (
400+ '[place-lookup] geocoding failed for "Auckland": Billing disabled'
401+ )
402+ expect ( warnSpy ) . toHaveBeenCalledWith (
403+ '[place-lookup] activity fallback search failed for "Rotoroa Island": Billing disabled'
404+ )
405+ } )
406+
340407 it ( 'handles activities without location' , async ( ) => {
341408 const activity = createActivity ( 1 , 'Some activity' )
342409
0 commit comments