eletrotupi / tcc/ commit / a0a4482

api: s/orbit/nexo on mail test and password reset

Pedro Lucas Porcellis porcellis@eletrotupi.com 29 days ago a0a4482072edfe23736af02ec22bbbf6e2c8d3b9
Parents: 5307cc7
2 file(s) changed
  • api/src/services/mail/sendPasswordReset.ts +1 -1
  • api/tests/jobs/mail.test.ts +2 -2
api/src/services/mail/sendPasswordReset.ts
1 1
import { findUserById } from '@app/services/user.service';
2 2
import { sendEmail }  from '@app/lib/mail';
3 3

4 4
const email = (firstName: string, token: string) => {
5 5
  return (`
▸ 12 unchanged lines
18 18

19 19
  console.log("Email/passwdReset: ", user);
20 20

21 21
  const { data, error } = await sendEmail({
22 22
    to: user!.email,
23 -
    subject: "Esqueceu a senha do orbit?",
23 +
    subject: "Esqueceu a senha do nexo?",
24 24
    text: email(user!.firstName, token)
25 25
  });
26 26

27 27
  if (error) {
28 28
    console.error("Error sending email: ", error);
29 29
  }
30 30

31 31
  console.log("Email sent successfully!");
32 32
  console.log("Email ID:", data?.id);
33 33
}
api/tests/jobs/mail.test.ts
1 1
import { describe, it, expect, afterAll, beforeEach, vi } from 'vitest'
2 2
import { sendWelcomeEmail } from '@app/services/mail/welcome'
3 3
import { sendActivateAccountEmail } from '@app/services/mail/sendActivateAccountEmail'
4 4
import { sendResetPasswordEmail } from '@app/services/mail/sendPasswordReset'
5 5
import { mailProcessor } from '@app/lib/queue/processors/mail'
▸ 30 unchanged lines
36 36

37 37
    expect(mockedSendEmail).toHaveBeenCalledOnce()
38 38
    expect(mockedSendEmail).toHaveBeenCalledWith(
39 39
      expect.objectContaining({
40 40
        to: 'welcome@example.com',
41 -
        subject: expect.stringContaining('orbit'),
41 +
        subject: expect.stringContaining('nexo'),
42 42
        text: expect.stringContaining('Maria'),
43 43
      })
44 44
    )
45 45

46 46
    // The code itself is in the body so the user knows what to enter
▸ 34 unchanged lines
81 81

82 82
    expect(mockedSendEmail).toHaveBeenCalledOnce()
83 83
    expect(mockedSendEmail).toHaveBeenCalledWith(
84 84
      expect.objectContaining({
85 85
        to: 'reset@example.com',
86 -
        subject: expect.stringContaining('orbit'),
86 +
        subject: expect.stringContaining('nexo'),
87 87
        text: expect.stringContaining('token-abc-xyz'),
88 88
      })
89 89
    )
90 90
  })
91 91
})
▸ 20 unchanged lines
112 112
    await expect(
113 113
      mailProcessor({ name: 'mail:unknown', data: {} } as any)
114 114
    ).rejects.toThrow('Unknown mail job')
115 115
  })
116 116
})