Skip to content

Commit c32d09d

Browse files
Merge pull request #111 from ISISComputingGroup/use_instlist_target_stations
Use instlist target stations
2 parents 11f7368 + e243711 commit c32d09d

12 files changed

+217
-398
lines changed

app/components/InstrumentWallCard.test.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
import { IfcInstrumentStatus } from "@/app/types";
1+
import { instListEntryWithRunstatePVandValue } from "@/app/types";
22
import { render } from "@testing-library/react";
33
import InstrumentWallCard from "@/app/components/InstrumentWallCard";
44

55
it("renders instrumentwallcard unchanged", () => {
6-
const instrument: IfcInstrumentStatus = {
6+
const instrument: instListEntryWithRunstatePVandValue = {
77
name: "Instrument",
8-
runstate: "RUNNING",
8+
runStateValue: "RUNNING",
9+
pvPrefix: "",
10+
runStatePV: "",
11+
groups: ["EXCITATIONS"],
12+
isScheduled: true,
13+
seci: false,
14+
hostName: "",
15+
targetStation: "TS5",
916
};
1017
const { container } = render(<InstrumentWallCard instrument={instrument} />);
1118
expect(container).toMatchSnapshot();
1219
});
1320

1421
it("renders instrumentwallcard unchanged when runstate is unknown", () => {
15-
const instrument: IfcInstrumentStatus = {
22+
const instrument: instListEntryWithRunstatePVandValue = {
1623
name: "Instrument1",
24+
runStateValue: "",
25+
pvPrefix: "",
26+
runStatePV: "",
27+
groups: ["EXCITATIONS"],
28+
isScheduled: true,
29+
seci: false,
30+
hostName: "",
31+
targetStation: "TS5",
1732
};
1833
const { container } = render(<InstrumentWallCard instrument={instrument} />);
1934
expect(container).toMatchSnapshot();

app/components/InstrumentWallCard.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
import Link from "next/link";
22
import { getForegroundColour, getStatusColour } from "./getRunstateColours";
3-
4-
import { IfcInstrumentStatus } from "@/app/types";
3+
import { instListEntryWithRunstatePVandValue } from "@/app/types";
54

65
export default function InstrumentWallCard({
76
instrument,
87
}: {
9-
instrument: IfcInstrumentStatus;
8+
instrument: instListEntryWithRunstatePVandValue;
109
}) {
1110
return (
1211
<div className={"flex"}>
1312
<Link
1413
href={"/instrument?name=" + instrument.name}
1514
target="_blank"
1615
className={`flex items-center justify-center text-center p-3 w-36 max-h-12 rounded-lg shadow-sm border-2 border-gray-700 dark:border-gray-200 hover:shadow-lg hover:border-black dark:hover:border-gray-700 transition-all duration-200
17-
${getStatusColour(instrument.runstate || "UNKNOWN")} ${getForegroundColour(
18-
instrument.runstate || "UNKNOWN",
16+
${getStatusColour(instrument.runStateValue || "UNKNOWN")} ${getForegroundColour(
17+
instrument.runStateValue || "UNKNOWN",
1918
)}`}
2019
>
2120
<div className="flex flex-col">
2221
<span className="text-sm font-bold line-clamp-1 w-full">
2322
{instrument.name}
2423
</span>
25-
<span className="text-xs ">{instrument.runstate || "UNKNOWN"}</span>
24+
<span className="text-xs ">
25+
{instrument.runStateValue || "UNKNOWN"}
26+
</span>
2627
</div>
2728
</Link>
2829
</div>

app/components/InstrumentsDisplay.test.ts

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
import { createInstrumentGroups } from "@/app/components/InstrumentsDisplay";
2-
import { targetStation } from "@/app/types";
2+
import { instList } from "@/app/types";
33

44
test("createInstrumentGroups adds two instruments from different target stations to the same science group", () => {
55
const instrument1Name = "INST1";
66
const instrument2Name = "INST2";
77
const commonScienceGroup = "MOLSPEC";
88
const instrument1 = {
99
name: instrument1Name,
10-
scienceGroups: [commonScienceGroup],
10+
groups: [commonScienceGroup],
11+
targetStation: "TS0",
12+
hostName: "",
13+
pvPrefix: "",
14+
isScheduled: true,
15+
seci: false,
16+
runStatePV: "",
17+
runStateValue: "",
1118
};
1219
const instrument2 = {
1320
name: instrument2Name,
14-
scienceGroups: [commonScienceGroup],
21+
groups: [commonScienceGroup],
22+
targetStation: "TS0",
23+
hostName: "",
24+
pvPrefix: "",
25+
isScheduled: true,
26+
seci: false,
27+
runStatePV: "",
28+
runStateValue: "",
1529
};
16-
const targetStations: Array<targetStation> = [
17-
{ targetStation: "TS0", instruments: [instrument1] },
18-
{ targetStation: "TS3", instruments: [instrument2] },
19-
];
30+
const targetStations: instList = [instrument1, instrument2];
2031
const result = createInstrumentGroups(targetStations);
2132

2233
expect(result.get(commonScienceGroup)!.sort()).toStrictEqual(
@@ -29,13 +40,27 @@ test("createInstrumentGroups ignores instrument without any groups", () => {
2940
const commonScienceGroup = "MOLSPEC";
3041
const instrument1 = {
3142
name: instrument1Name,
32-
scienceGroups: [commonScienceGroup],
43+
groups: [commonScienceGroup],
44+
targetStation: "TS0",
45+
hostName: "",
46+
pvPrefix: "",
47+
isScheduled: true,
48+
seci: false,
49+
runStatePV: "",
50+
runStateValue: "",
3351
};
34-
const instrument2 = { name: "someinstrumentwithnogroups", scienceGroups: [] };
35-
const targetStations: Array<targetStation> = [
36-
{ targetStation: "TS0", instruments: [instrument1] },
37-
{ targetStation: "TS3", instruments: [instrument2] },
38-
];
52+
const instrument2 = {
53+
name: "someinstrumentwithnogroups",
54+
targetStation: "TS0",
55+
hostName: "",
56+
pvPrefix: "",
57+
isScheduled: true,
58+
seci: false,
59+
runStatePV: "",
60+
runStateValue: "",
61+
groups: [],
62+
};
63+
const targetStations: instList = [instrument1, instrument2];
3964
const result = createInstrumentGroups(targetStations);
4065

4166
expect(result.get(commonScienceGroup)!.sort()).toStrictEqual(
@@ -48,16 +73,27 @@ test("createInstrumentGroups ignores instrument which is a support machine", ()
4873
const commonScienceGroup = "MOLSPEC";
4974
const instrument1 = {
5075
name: instrument1Name,
51-
scienceGroups: [commonScienceGroup],
76+
groups: [commonScienceGroup],
77+
targetStation: "TS0",
78+
hostName: "",
79+
pvPrefix: "",
80+
isScheduled: true,
81+
seci: false,
82+
runStatePV: "",
83+
runStateValue: "",
5284
};
5385
const instrument2 = {
5486
name: "someinstrumentwithnogroups",
55-
scienceGroups: ["SUPPORT"],
87+
groups: ["SUPPORT"],
88+
targetStation: "TS3",
89+
hostName: "",
90+
pvPrefix: "",
91+
isScheduled: true,
92+
seci: false,
93+
runStatePV: "",
94+
runStateValue: "",
5695
};
57-
const targetStations: Array<targetStation> = [
58-
{ targetStation: "TS0", instruments: [instrument1] },
59-
{ targetStation: "TS3", instruments: [instrument2] },
60-
];
96+
const targetStations: instList = [instrument1, instrument2];
6197
const result = createInstrumentGroups(targetStations);
6298

6399
expect(result.get(commonScienceGroup)!.sort()).toStrictEqual(

0 commit comments

Comments
 (0)