add from to notification model (#14102)

This commit is contained in:
Pedro Guzman
2025-11-24 09:24:38 +01:00
committed by GitHub
parent 0cb12021ef
commit f67bfb9f92
9 changed files with 83 additions and 15 deletions

View File

@@ -1,4 +1,7 @@
import { INotificationModuleService } from "@medusajs/framework/types"
import {
CreateNotificationDTO,
INotificationModuleService,
} from "@medusajs/framework/types"
import {
CommonEvents,
composeMessage,
@@ -74,19 +77,27 @@ moduleIntegrationTestRunner<INotificationModuleService>({
it("should send a notification and stores it in the database", async () => {
const notification = {
to: "admin@medusa.com",
from: "sender@verified.com",
template: "some-template",
channel: "email",
data: {},
}
} as CreateNotificationDTO
const result = await service.createNotifications(notification)
expect(result).toEqual(
expect.objectContaining({
provider_id: "test-provider",
external_id: "external_id",
status: NotificationStatus.SUCCESS,
})
)
const retrieved = await service.retrieveNotification(result.id)
const expected = {
to: "admin@medusa.com",
from: "sender@verified.com",
template: "some-template",
channel: "email",
data: {},
provider_id: "test-provider",
external_id: "external_id",
status: NotificationStatus.SUCCESS,
}
expect(result).toEqual(expect.objectContaining(expected))
expect(retrieved).toEqual(expect.objectContaining(expected))
})
it("should send a notification and don't store the content in the database", async () => {

View File

@@ -14,6 +14,7 @@ const successMedusaCloudEmailResponse = {
const testNotification = {
to: "customer@test.com",
from: "sender@verified.com",
template: "some-template",
channel: "email",
data: {
@@ -50,6 +51,13 @@ moduleIntegrationTestRunner<INotificationModuleService>({
const result = await service.createNotifications(testNotification)
expect(result).toEqual(
expect.objectContaining({
to: "customer@test.com",
from: "sender@verified.com",
template: "some-template",
channel: "email",
data: {
link: "https://test.com",
},
provider_id: "cloud",
external_id: "external_id_1",
status: NotificationStatus.SUCCESS,
@@ -66,6 +74,7 @@ moduleIntegrationTestRunner<INotificationModuleService>({
)
expect(JSON.parse(request.body)).toEqual({
to: "customer@test.com",
from: "sender@verified.com",
template: "some-template",
data: {
link: "https://test.com",