@@ -40,6 +40,7 @@ public function fetchNewMessages(
4040 new GmailMessage ('m2 ' , 't2 ' , 'Subj 2 ' , 'sender2@example.com ' , "Hello 2 " ),
4141 ],
4242 'next_history_id ' => '123 ' ,
43+ 'warnings ' => [],
4344 ];
4445 }
4546 };
@@ -54,6 +55,7 @@ public function fetchNewMessages(
5455
5556 $ this ->assertSame (2 , $ res ['ingested ' ]);
5657 $ this ->assertSame (1 , $ res ['duplicates ' ]);
58+ $ this ->assertSame ([], $ res ['warnings ' ]);
5759
5860 $ cursor = SupportGmailCursor::query ()->where ('mailbox ' , 'me ' )->where ('label ' , 'Support-AI ' )->first ();
5961 $ this ->assertNotNull ($ cursor );
@@ -89,9 +91,50 @@ public function fetchNewMessages(
8991 );
9092
9193 $ res = $ svc ->pollAndIngest (25 );
92- $ this ->assertSame (['ingested ' => 0 , 'duplicates ' => 0 , 'cursor_updated ' => false ], $ res );
94+ $ this ->assertSame (['ingested ' => 0 , 'duplicates ' => 0 , 'cursor_updated ' => false , ' warnings ' => [] ], $ res );
9395
9496 $ lock ->release ();
9597 }
98+
99+ public function test_poll_passes_through_connector_warnings (): void
100+ {
101+ config ()->set ('support_gmail.enabled ' , true );
102+ config ()->set ('support_gmail.lock.name ' , 'test:support:gmail:poll:warnings ' );
103+ config ()->set ('support_gmail.lock.ttl_seconds ' , 30 );
104+ config ()->set ('support_gmail.user ' , 'me ' );
105+ config ()->set ('support_gmail.label ' , 'Missing-Label ' );
106+ config ()->set ('support_gmail.query ' , 'newer_than:7d ' );
107+
108+ $ fakeConnector = new class implements GmailConnector {
109+ public function fetchNewMessages (
110+ string $ mailbox ,
111+ ?string $ label ,
112+ string $ query ,
113+ ?string $ sinceHistoryId ,
114+ int $ max = 25 ,
115+ ): array {
116+ return [
117+ 'messages ' => [],
118+ 'next_history_id ' => null ,
119+ 'warnings ' => [
120+ 'Configured Gmail label "Missing-Label" was not found; polling without label filter. ' ,
121+ ],
122+ ];
123+ }
124+ };
125+
126+ $ svc = new GmailIngestService (
127+ connector: $ fakeConnector ,
128+ intake: app (CaseIntakeService::class),
129+ logger: app (SupportActionLogger::class),
130+ );
131+
132+ $ res = $ svc ->pollAndIngest (25 );
133+
134+ $ this ->assertSame (
135+ ['Configured Gmail label "Missing-Label" was not found; polling without label filter. ' ],
136+ $ res ['warnings ' ],
137+ );
138+ }
96139}
97140
0 commit comments