@@ -56,7 +56,7 @@ func TestSendSMS_Encrypted(t *testing.T) {
5656 assert .NotEqual (t , plaintext , outstanding ["content" ])
5757
5858 fireEvent (ctx , t , phone .PhoneAPIKey , messageID , "SENT" )
59- time . Sleep ( 200 * time .Millisecond )
59+ pollMessageStatus ( ctx , t , messageID , "sent" , 15 * time .Second )
6060 fireEvent (ctx , t , phone .PhoneAPIKey , messageID , "DELIVERED" )
6161
6262 msg := pollMessageStatus (ctx , t , messageID , "delivered" , 30 * time .Second )
@@ -200,8 +200,10 @@ func TestSendSMS_RateLimit(t *testing.T) {
200200 assert .GreaterOrEqual (t , gapMs , int64 (5500 ), "rate limit gap should be >= 5500ms (6s minus timing tolerance), got %dms" , gapMs )
201201
202202 fireEvent (ctx , t , phone .PhoneAPIKey , msgID1 , "SENT" )
203- fireEvent (ctx , t , phone . PhoneAPIKey , msgID1 , "DELIVERED" )
203+ pollMessageStatus (ctx , t , msgID1 , "sent" , 15 * time . Second )
204204 fireEvent (ctx , t , phone .PhoneAPIKey , msgID2 , "SENT" )
205+ pollMessageStatus (ctx , t , msgID2 , "sent" , 15 * time .Second )
206+ fireEvent (ctx , t , phone .PhoneAPIKey , msgID1 , "DELIVERED" )
205207 fireEvent (ctx , t , phone .PhoneAPIKey , msgID2 , "DELIVERED" )
206208
207209 msg1 := pollMessageStatus (ctx , t , msgID1 , "delivered" , 15 * time .Second )
@@ -335,7 +337,7 @@ func TestSendSMS_OutstandingFlow(t *testing.T) {
335337 assert .Equal (t , contactNumber , outstanding ["contact" ])
336338
337339 fireEvent (ctx , t , phone .PhoneAPIKey , messageID , "SENT" )
338- time . Sleep ( 200 * time .Millisecond )
340+ pollMessageStatus ( ctx , t , messageID , "sent" , 15 * time .Second )
339341 fireEvent (ctx , t , phone .PhoneAPIKey , messageID , "DELIVERED" )
340342
341343 msg := pollMessageStatus (ctx , t , messageID , "delivered" , 30 * time .Second )
@@ -538,7 +540,7 @@ func TestBulkSMS_Excel(t *testing.T) {
538540
539541 // Fire SENT then DELIVERED on message 1, leave message 2 pending
540542 fireEvent (ctx , t , phone .PhoneAPIKey , msgID1 , "SENT" )
541- time . Sleep ( 200 * time .Millisecond )
543+ pollMessageStatus ( ctx , t , msgID1 , "sent" , 15 * time .Second )
542544 fireEvent (ctx , t , phone .PhoneAPIKey , msgID1 , "DELIVERED" )
543545
544546 // Poll until message 1 reaches "delivered"
0 commit comments