diff --git a/ui/src/app/base/reducers/machine/machine.js b/ui/src/app/base/reducers/machine/machine.js index bf4758dbe3..755f567b17 100644 --- a/ui/src/app/base/reducers/machine/machine.js +++ b/ui/src/app/base/reducers/machine/machine.js @@ -151,6 +151,7 @@ const machine = createNextState( break; case "CREATE_MACHINE_NOTIFY": draft.items.push(action.payload); + draft.statuses[action.payload.system_id] = DEFAULT_STATUSES; break; case "DELETE_MACHINE_NOTIFY": draft.items = draft.items.filter( diff --git a/ui/src/app/base/reducers/machine/machine.test.js b/ui/src/app/base/reducers/machine/machine.test.js index deb477e4e7..859aac8409 100644 --- a/ui/src/app/base/reducers/machine/machine.test.js +++ b/ui/src/app/base/reducers/machine/machine.test.js @@ -1,5 +1,28 @@ import machine from "./machine"; +const STATUSES = { + aborting: false, + acquiring: false, + checkingPower: false, + commissioning: false, + deleting: false, + deploying: false, + enteringRescueMode: false, + exitingRescueMode: false, + locking: false, + markingBroken: false, + markingFixed: false, + overridingFailedTesting: false, + releasing: false, + settingPool: false, + settingZone: false, + tagging: false, + testing: false, + turningOff: false, + turningOn: false, + unlocking: false, +}; + describe("machine reducer", () => { it("should return the initial state", () => { expect(machine(undefined, {})).toEqual({ @@ -32,28 +55,6 @@ describe("machine reducer", () => { }); it("should correctly reduce FETCH_MACHINE_SUCCESS", () => { - const statuses = { - aborting: false, - acquiring: false, - checkingPower: false, - commissioning: false, - deleting: false, - deploying: false, - enteringRescueMode: false, - exitingRescueMode: false, - locking: false, - markingBroken: false, - markingFixed: false, - overridingFailedTesting: false, - releasing: false, - settingPool: false, - settingZone: false, - tagging: false, - testing: false, - turningOff: false, - turningOn: false, - unlocking: false, - }; expect( machine( { @@ -65,7 +66,7 @@ describe("machine reducer", () => { saving: false, selected: [], statuses: { - abc: statuses, + abc: STATUSES, }, }, { @@ -88,8 +89,8 @@ describe("machine reducer", () => { saving: false, selected: [], statuses: { - abc: statuses, - def: statuses, + abc: STATUSES, + def: STATUSES, }, }); }); @@ -215,9 +216,10 @@ describe("machine reducer", () => { saved: false, saving: false, selected: [], + statuses: {}, }, { - payload: { id: 2, name: "machine2" }, + payload: { id: 2, name: "machine2", system_id: "abc" }, type: "CREATE_MACHINE_NOTIFY", } ) @@ -225,13 +227,16 @@ describe("machine reducer", () => { errors: {}, items: [ { id: 1, name: "machine1" }, - { id: 2, name: "machine2" }, + { id: 2, name: "machine2", system_id: "abc" }, ], loaded: false, loading: false, saved: false, saving: false, selected: [], + statuses: { + abc: STATUSES, + }, }); });