fix test references after removal of addMockSystemToRepository

This commit is contained in:
2025-04-07 12:07:32 -07:00
parent dbb56f207d
commit 9c414be8ce
9 changed files with 73 additions and 102 deletions

View File

@@ -3,7 +3,6 @@ import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/ap
import {
addMockShuttleToRepository,
addMockStopToRepository,
addMockSystemToRepository
} from "../testHelpers/repositorySetupHelpers";
import assert = require("node:assert");
import { NotificationInput } from "../../src/generated/graphql";
@@ -44,14 +43,14 @@ describe("MutationResolvers", () => {
const notificationResponse = response.body.singleResult.data?.scheduleNotification as any;
expect(notificationResponse.success).toBe(false);
expect(await context.notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
expect(await context.systems[0].notificationRepository.isNotificationScheduled(notificationInput)).toBe(false);
}
it("adds a notification to the notification service", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -72,13 +71,13 @@ describe("MutationResolvers", () => {
expect(notificationResponse?.success).toBe(true);
expect(notificationResponse?.data).toEqual(expectedNotificationData);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(expectedNotificationData)).toBe(240);
expect(await context.systems[0].notificationRepository.getSecondsThresholdForNotificationIfExists(expectedNotificationData)).toBe(240);
});
it("adds a notification with the default seconds threshold if none is provided", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -93,12 +92,12 @@ describe("MutationResolvers", () => {
const notificationResponse = response.body.singleResult.data?.scheduleNotification as any;
expect(notificationResponse?.success).toBe(true);
expect(await context.notificationRepository.getSecondsThresholdForNotificationIfExists(notificationInput)).toBe(180);
expect(await context.systems[0].notificationRepository.getSecondsThresholdForNotificationIfExists(notificationInput)).toBe(180);
});
it("fails if the shuttle ID doesn't exist", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -110,8 +109,8 @@ describe("MutationResolvers", () => {
});
it("fails if the stop ID doesn't exist", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput = {
deviceId: "1",
@@ -140,9 +139,9 @@ describe("MutationResolvers", () => {
`
it("removes the notification from the notification service", async () => {
const system = await addMockSystemToRepository(context.shuttleRepository);
const shuttle = await addMockShuttleToRepository(context.shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.shuttleRepository, system.id);
const system = context.systems[0];
const shuttle = await addMockShuttleToRepository(context.systems[0].shuttleRepository, system.id);
const stop = await addMockStopToRepository(context.systems[0].shuttleRepository, system.id);
const notificationInput: any = {
deviceId: "1",
@@ -150,7 +149,7 @@ describe("MutationResolvers", () => {
stopId: stop.id,
secondsThreshold: 180,
}
await context.notificationRepository.addOrUpdateNotification(notificationInput);
await context.systems[0].notificationRepository.addOrUpdateNotification(notificationInput);
const notificationLookup = {
...notificationInput
@@ -166,7 +165,7 @@ describe("MutationResolvers", () => {
expect(notificationResponse.success).toBe(true);
expect(notificationResponse.data).toEqual(notificationLookup);
expect(await context.notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
expect(await context.systems[0].notificationRepository.isNotificationScheduled(notificationLookup)).toBe(false);
});
it("fails if the notification doesn't exist", async () => {