@@ -243,6 +243,39 @@ describe("domain-service", () => {
243243 expect ( mockSendMail ) . not . toHaveBeenCalled ( ) ;
244244 } ) ;
245245
246+ it ( "does not send status email on first refresh when status is unchanged" , async ( ) => {
247+ const domain = createDomain ( {
248+ status : DomainStatus . SUCCESS ,
249+ dkimStatus : DomainStatus . SUCCESS ,
250+ spfDetails : DomainStatus . SUCCESS ,
251+ isVerifying : false ,
252+ } ) ;
253+ mockRedis . mget . mockResolvedValue ( [ null , null , null ] ) ;
254+ mockGetDomainIdentity . mockResolvedValue ( {
255+ DkimAttributes : { Status : DomainStatus . SUCCESS } ,
256+ MailFromAttributes : { MailFromDomainStatus : DomainStatus . SUCCESS } ,
257+ VerificationInfo : {
258+ ErrorType : null ,
259+ LastCheckedTimestamp : new Date ( "2026-03-09T12:00:00.000Z" ) ,
260+ } ,
261+ VerificationStatus : DomainStatus . SUCCESS ,
262+ } ) ;
263+ mockDb . domain . update . mockResolvedValue (
264+ createDomain ( {
265+ status : DomainStatus . SUCCESS ,
266+ dkimStatus : DomainStatus . SUCCESS ,
267+ spfDetails : DomainStatus . SUCCESS ,
268+ dmarcAdded : true ,
269+ isVerifying : false ,
270+ } ) ,
271+ ) ;
272+
273+ await refreshDomainVerification ( domain ) ;
274+
275+ expect ( mockSendMail ) . not . toHaveBeenCalled ( ) ;
276+ expect ( wasLastNotifiedStatusStored ( ) ) . toBe ( false ) ;
277+ } ) ;
278+
246279 it ( "reserves the notification so concurrent refreshes do not double-send" , async ( ) => {
247280 const domain = createDomain ( ) ;
248281 mockRedis . mget . mockResolvedValue ( [ null , null , null ] ) ;
0 commit comments