Skip to content

Commit

Permalink
✨ feat(products): add order receipt emails (#569)
Browse files Browse the repository at this point in the history
* chore: add order receipt handler and tests

* chore: update tests

* chore: fix flaky test

* chore: use tz in test to avoid flakiness

* chore: fix flaky tests

* chore: add more test cases
  • Loading branch information
larwaa authored Mar 22, 2024
1 parent f4ea2a7 commit 549d2bf
Show file tree
Hide file tree
Showing 16 changed files with 655 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/__tests__/dependencies-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export function makeTestServices(overrides?: Partial<Services>): Services & {
vippsFactory: mockDeep<typeof Client>(),
paymentProcessingQueue: mockDeep<PaymentProcessingQueueType>(),
productRepository,
mailService,
config: {
useTestMode: true,
returnUrl: env.SERVER_URL,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/bullmq/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export async function initWorkers(): Promise<{
vippsFactory: Client,
paymentProcessingQueue: instance.queues?.[PaymentProcessingQueueName],
productRepository,
mailService,
config: { useTestMode: env.VIPPS_TEST_MODE, returnUrl: env.SERVER_URL },
});

Expand Down Expand Up @@ -304,6 +305,7 @@ export async function initWorkers(): Promise<{
eventService,
cabinService,
fileService,
productService,
logger: instance.log,
}),
);
Expand Down
1 change: 1 addition & 0 deletions src/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ async function registerServices(
vippsFactory: Client,
paymentProcessingQueue: serverInstance.queues[PaymentProcessingQueueName],
productRepository,
mailService,
config: {
useTestMode: configuration?.VIPPS_TEST_MODE,
returnUrl: env.SERVER_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe("productRepository", () => {
const toUpdate = await productRepository.createMerchant({
clientId: faker.string.uuid(),
clientSecret: faker.string.uuid(),
name: faker.company.name(),
name: faker.string.uuid(),
serialNumber: faker.string.uuid(),
subscriptionKey: faker.string.uuid(),
});
Expand All @@ -76,7 +76,7 @@ describe("productRepository", () => {
id: toUpdate.merchant.id,
clientId: existing.clientId,
clientSecret: faker.string.uuid(),
name: faker.company.name(),
name: faker.string.uuid(),
serialNumber: faker.string.uuid(),
subscriptionKey: faker.string.uuid(),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function makeServices() {
const vipps = MockVippsClientFactory();
const productService = ProductService({
productRepository,
mailService,
paymentProcessingQueue: mockDeep<PaymentProcessingQueueType>(),
vippsFactory: vipps.factory,
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe("EventService", () => {
userService,
mailService,
cabinService: mockDeep<CabinService>(),
productService: mock(),
fileService: mock(),
logger: mock(),
});
Expand Down Expand Up @@ -277,8 +278,8 @@ describe("EventService", () => {
event: expect.objectContaining({
name: event.name,
startAt: expect.any(String),
url: `${env.CLIENT_URL}/events/${event.id}`,
}),
actionUrl: `${env.CLIENT_URL}/events/${event.id}`,
}),
}),
);
Expand Down Expand Up @@ -468,8 +469,8 @@ describe("EventService", () => {
event: expect.objectContaining({
name: event.name,
startAt: expect.any(String),
url: `${env.CLIENT_URL}/events/${event.id}`,
}),
actionUrl: `${env.CLIENT_URL}/events/${event.id}`,
}),
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/services/events/__tests__/unit/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ describe("EventsService", () => {
updateEventParams: {
event: {
id: faker.string.uuid(),
endAt: faker.date.between({ from: startAt, to: endAt }),
startAt: faker.date.soon({ refDate: endAt, days: 2 }),
endAt: DateTime.now().plus({ days: 1 }).toJSDate(),
startAt: DateTime.now().plus({ days: 2 }).toJSDate(),
},
},
},
Expand Down
Loading

0 comments on commit 549d2bf

Please sign in to comment.