diff --git a/app/components/InstrumentsDisplay.test.ts b/app/components/InstrumentsDisplay.test.ts index fd1e1e2..4a93beb 100644 --- a/app/components/InstrumentsDisplay.test.ts +++ b/app/components/InstrumentsDisplay.test.ts @@ -42,3 +42,25 @@ test("createInstrumentGroups ignores instrument without any groups", () => { [instrument1].sort(), ); }); + +test("createInstrumentGroups ignores instrument which is a support machine", () => { + const instrument1Name = "INST1"; + const commonScienceGroup = "MOLSPEC"; + const instrument1 = { + name: instrument1Name, + scienceGroups: [commonScienceGroup], + }; + const instrument2 = { + name: "someinstrumentwithnogroups", + scienceGroups: ["SUPPORT"], + }; + const targetStations: Array = [ + { targetStation: "TS0", instruments: [instrument1] }, + { targetStation: "TS3", instruments: [instrument2] }, + ]; + const result = createInstrumentGroups(targetStations); + + expect(result.get(commonScienceGroup)!.sort()).toStrictEqual( + [instrument1].sort(), + ); +}); diff --git a/app/components/InstrumentsDisplay.tsx b/app/components/InstrumentsDisplay.tsx index 258909b..d30af51 100644 --- a/app/components/InstrumentsDisplay.tsx +++ b/app/components/InstrumentsDisplay.tsx @@ -16,6 +16,9 @@ import { import TargetStation from "@/app/components/TargetStation"; import ScienceGroup from "@/app/components/ScienceGroup"; +// Ignore support machines for the instruments page. +const instrumentsExcludeList = ["SUPPORT"]; + export function createInstrumentGroups( targetStations: Array, ): Map> { @@ -24,11 +27,13 @@ export function createInstrumentGroups( for (const inst of targetStation.instruments) { if (inst.scienceGroups) { for (const group of inst.scienceGroups) { - if (!newInstrumentGroups.has(group)) { - // This is a new science group so create a new entry - newInstrumentGroups.set(group, []); + if (!instrumentsExcludeList.includes(group)) { + if (!newInstrumentGroups.has(group)) { + // This is a new science group so create a new entry + newInstrumentGroups.set(group, []); + } + newInstrumentGroups.get(group)!.push(inst); } - newInstrumentGroups.get(group)!.push(inst); } } } @@ -36,6 +41,7 @@ export function createInstrumentGroups( return newInstrumentGroups; } +/* c8 ignore start */ export default function InstrumentsDisplay({ sortByGroups = false, }: { @@ -198,3 +204,4 @@ export default function InstrumentsDisplay({ ); } +/* c8 ignore end */ diff --git a/jest.config.ts b/jest.config.ts index ed0e553..b544bb9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -19,7 +19,6 @@ const config: Config = { "!app/components/JenkinsJobsIframe.tsx", // relies on an external image "!app/components/ShowHideBeamInfo.tsx", // relies on an external image "!app/components/InstrumentData.tsx", // relies on websocket - "!app/components/InstrumentsDisplay.tsx", // relies on websocket ], };