-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add storage card to machine details overview (#1839)
- Loading branch information
Showing
5 changed files
with
320 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
...achines/views/MachineDetails/MachineSummary/OverviewCard/StorageCard/StorageCard.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { mount } from "enzyme"; | ||
import { Provider } from "react-redux"; | ||
import { MemoryRouter } from "react-router-dom"; | ||
import configureStore from "redux-mock-store"; | ||
import React from "react"; | ||
|
||
import { | ||
machineDetails as machineDetailsFactory, | ||
machineState as machineStateFactory, | ||
rootState as rootStateFactory, | ||
testStatus as testStatusFactory, | ||
} from "testing/factories"; | ||
import StorageCard from "./StorageCard"; | ||
import type { RootState } from "app/store/root/types"; | ||
|
||
const mockStore = configureStore(); | ||
|
||
describe("StorageCard", () => { | ||
let state: RootState; | ||
beforeEach(() => { | ||
state = rootStateFactory({ | ||
machine: machineStateFactory(), | ||
}); | ||
}); | ||
|
||
it("renders a link with a count of passed tests", () => { | ||
const machine = machineDetailsFactory(); | ||
machine.storage_test_status = testStatusFactory({ | ||
passed: 2, | ||
}); | ||
state.machine.items = [machine]; | ||
|
||
const store = mockStore(state); | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter | ||
initialEntries={[{ pathname: "/machine/abc123", key: "testKey" }]} | ||
> | ||
<StorageCard machine={machine} setSelectedAction={jest.fn()} /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect( | ||
wrapper.find("[data-test='tests']").childAt(0).find("Button").text() | ||
).toEqual("2"); | ||
}); | ||
|
||
it("renders a link with a count of pending and running tests", () => { | ||
const machine = machineDetailsFactory(); | ||
machine.storage_test_status = testStatusFactory({ | ||
running: 1, | ||
pending: 2, | ||
}); | ||
state.machine.items = [machine]; | ||
|
||
const store = mockStore(state); | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter | ||
initialEntries={[{ pathname: "/machine/abc123", key: "testKey" }]} | ||
> | ||
<StorageCard machine={machine} setSelectedAction={jest.fn()} /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect( | ||
wrapper.find("[data-test='tests']").childAt(0).find("Button").text() | ||
).toEqual("3"); | ||
}); | ||
|
||
it("renders a link with a count of failed tests", () => { | ||
const machine = machineDetailsFactory(); | ||
machine.storage_test_status = testStatusFactory({ | ||
failed: 5, | ||
}); | ||
state.machine.items = [machine]; | ||
|
||
const store = mockStore(state); | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter | ||
initialEntries={[{ pathname: "/machine/abc123", key: "testKey" }]} | ||
> | ||
<StorageCard machine={machine} setSelectedAction={jest.fn()} /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect( | ||
wrapper.find("[data-test='tests']").childAt(0).find("Button").text() | ||
).toEqual("5"); | ||
}); | ||
|
||
it("renders a results link", () => { | ||
const machine = machineDetailsFactory(); | ||
machine.storage_test_status = testStatusFactory({ | ||
failed: 5, | ||
}); | ||
state.machine.items = [machine]; | ||
|
||
const store = mockStore(state); | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter | ||
initialEntries={[{ pathname: "/machine/abc123", key: "testKey" }]} | ||
> | ||
<StorageCard machine={machine} setSelectedAction={jest.fn()} /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect( | ||
wrapper.find("[data-test='tests']").childAt(1).find("Button").text() | ||
).toContain("View results"); | ||
}); | ||
|
||
it("renders a test storage link if no tests run", () => { | ||
const machine = machineDetailsFactory(); | ||
machine.storage_test_status = testStatusFactory(); | ||
state.machine.items = [machine]; | ||
|
||
const store = mockStore(state); | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<MemoryRouter | ||
initialEntries={[{ pathname: "/machine/abc123", key: "testKey" }]} | ||
> | ||
<StorageCard machine={machine} setSelectedAction={jest.fn()} /> | ||
</MemoryRouter> | ||
</Provider> | ||
); | ||
|
||
expect( | ||
wrapper.find("[data-test='tests']").childAt(0).find("Button").text() | ||
).toContain("Test storage"); | ||
}); | ||
}); |
Oops, something went wrong.