Skip to content

Commit

Permalink
Add status for new synced machines.
Browse files Browse the repository at this point in the history
  • Loading branch information
huwshimi committed Apr 24, 2020
1 parent 369800f commit 10ad1e2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
1 change: 1 addition & 0 deletions ui/src/app/base/reducers/machine/machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
59 changes: 32 additions & 27 deletions ui/src/app/base/reducers/machine/machine.test.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -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(
{
Expand All @@ -65,7 +66,7 @@ describe("machine reducer", () => {
saving: false,
selected: [],
statuses: {
abc: statuses,
abc: STATUSES,
},
},
{
Expand All @@ -88,8 +89,8 @@ describe("machine reducer", () => {
saving: false,
selected: [],
statuses: {
abc: statuses,
def: statuses,
abc: STATUSES,
def: STATUSES,
},
});
});
Expand Down Expand Up @@ -215,23 +216,27 @@ 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",
}
)
).toEqual({
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,
},
});
});

Expand Down

0 comments on commit 10ad1e2

Please sign in to comment.