Skip to content

Commit 9dd4b20

Browse files
authored
Development (#123)
Docketeer 8.0 pull request
2 parents 653ed06 + 50fa8cf commit 9dd4b20

File tree

102 files changed

+4002
-2588
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4002
-2588
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ src/components/display/.StoppedContainers.js.icloud
2727
src/database/docketeerdb
2828
.env
2929
yarn.lock
30-
coverage
30+
coverage
31+
32+
.history

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"workbench.localHistory.enabled": true
3+
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ npm run test
174174
Read our [contributing guide](https://github.com/open-source-labs/Docketeer/blob/master/CONTRIBUTING.md) for more information on how to purpose bugfixes and improvements to Docketeer.
175175

176176
### Authors
177+
- Sarah Moosa [@Sbethm](https://github.com/Sbethm) | [LinkedIn](https://www.linkedin.com/in/sarah-moosa-4b05721b6/)
178+
- Cedar Cooper [@CedarCooper](https://github.com/CedarCooper) | [LinkedIn](https://www.linkedin.com/in/cedar-cooper/)
179+
- Tiffany Chau [@tiffanynchau](https://github.com/tiffanynchau/) | [LinkedIn](https://www.linkedin.com/in/tiffanynchau/)
180+
- Jack Yuan [@jackyuan1](https://github.com/jackyuan1) | [LinkedIn](https://www.linkedin.com/in/jack-yuan-298244247/)
181+
- Drew Manley [@DrewManley](https://github.com/DrewManley) | [LinkedIn](https://www.linkedin.com/in/andrewmanley13/)
177182
- Abigail Gerig [@4estgirl](https://github.com/4estgirl) | [Linkedin](https://www.linkedin.com/in/abigail-gerig/)
178183
- Trine Medina [@TrineMedina](https://github.com/TrineMedina) | [Linkedin](https://www.linkedin.com/in/trinemedina/)
179184
- Christian Looff [@cmlooff](https://github.com/cmlooff) | [LinkedIn](https://www.linkedin.com/in/christian-looff/)

__tests__/ContainersTab.test.js

Lines changed: 71 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React, { Component } from 'react';
1+
import React from 'react';
22
import Containers from '../src/components/tabs/Containers';
3-
4-
// Started to migrate to React-Testing-Library...
5-
import { create } from 'react-test-renderer';
3+
import {describe, beforeEach, expect, test, jest} from '@jest/globals';
4+
import '@testing-library/jest-dom';
5+
import ToggleDisplay from '../src/components/display/ToggleDisplay';
66
import { fireEvent, render, screen } from '@testing-library/react';
7-
import * as actions from '@testing-library/jest-dom';
87

98
const props = {
109
runningList: [
@@ -22,136 +21,77 @@ const props = {
2221
stoppedList: [
2322
{
2423
Names: 'zealous',
25-
ID: 'c902ec744095',
26-
Img: '84c5f6e03bf0',
27-
Created: '2 days ago',
28-
name: 'zealous_pare'
24+
ID: 'c902ec744095',
25+
Image: '84c5f6e03bf0',
26+
RunningFor: '2 days ago',
2927
}
30-
]
28+
],
29+
container: {MemUsage:1},
30+
stop: jest.fn(),
31+
remove: jest.fn(),
32+
runStopped: jest.fn()
3133
};
32-
/** Docketeer 7.0
33-
* This was the previous groups code, we left commented just incase it became useful down the road.
34-
*/
35-
36-
// Debug test
37-
// describe('Containers', () => {
38-
// test('Renders the Container Component', () => {
39-
// render(<Containers {...props} />);
40-
// // Screening the component
41-
// screen.debug();
42-
// });
43-
// });
44-
45-
// function shallowSetup() {
46-
// const props = {
47-
// runningList: [
48-
// {
49-
// block: '0B/0B',
50-
// ID: 'a802306eeac3',
51-
// CPUPerc: '0.17%',
52-
// MemPerc: '0.11%',
53-
// MemUsage: '2.195MiB/1.944GiB',
54-
// Name: 'blissful_matsumoto',
55-
// NetIO: '796B/0B',
56-
// PIDs: '5'
57-
// }
58-
// ],
59-
// stoppedList: [
60-
// {
61-
// Name: 'zealous',
62-
// ID: 'c902ec744095',
63-
// Img: '84c5f6e03bf0',
64-
// Created: '2 days ago',
65-
// name: 'zealous_pare'
66-
// }
67-
// ]
68-
// };
69-
// const reactWrapper = create(<Containers {...props} />);
70-
71-
// return {
72-
// props,
73-
// reactWrapper
74-
// };
75-
// }
76-
77-
// describe('Running containers are being rendered', () => {
78-
// test('Should render <div> tag that has title renderContainers in Running', () => {
79-
// // Testing for if there is a container with the title of renderContainer
80-
// render(<Containers {...props} />);
81-
82-
// const renderContainer = screen.getByTitle('renderContainers');
83-
// expect(renderContainer).toHaveClass('renderContainers');
84-
// });
85-
86-
// test('Should render the correct number of containers', () => {
87-
// const { container } = render(<Containers {...props} />);
88-
// const containers = container.getElementsByClassName('containers');
89-
// expect(containers.length).toBe(1);
90-
// });
91-
// });
92-
93-
// describe('It should render the exited containers', () => {
94-
// test('Should have a className run-btn in Stopped component', () => {
95-
// render(<Containers {...props} />);
96-
97-
// const runBtnRender = screen.getByTestId('run-btn');
98-
99-
// expect(runBtnRender).toHaveClass('run-btn');
100-
// });
10134

102-
/** Docketeer 7.0
103-
* These are all preliminary tests that were not veted out. Could be useful as a starting point.
104-
*/
10535

106-
//! NEED TO FIGURE OUT HOW TO ADD ONCLICK TEST
107-
// test('ClassName run-btn in stopped component have onClick function', () => {
108-
// const handleOnClick = jest.fn();
109-
110-
// render(<Containers {...props} runStopped={handleOnClick} />);
111-
112-
// const runBtnRender = screen.queryByText('RUN');
113-
// // screen.queryByText('RUN');
114-
115-
// fireEvent.click(runBtnRender);
116-
117-
// expect(runBtnRender).toHaveBeenCalledTimes(1);
118-
// });
119-
// });
120-
121-
// describe('It should render the exited containers', () => {
122-
// const { reactWrapper } = shallowSetup();
123-
//! test('Should render <div> tag in Stopped', () => {
124-
//! expect(reactWrapper.type()).toEqual('div');
125-
//! });
126-
127-
//* test('Should have className run-btn in Stopped component', () => {
128-
//* expect(
129-
//* reactWrapper.find('.stopped-button').props().children[0].props.className
130-
//* ).toEqual('run-btn');
131-
//* });
132-
133-
// test('ClassName run-btn in Stopped component have onClick function', () => {
134-
// expect(
135-
// reactWrapper.find('.stopped-button').props().children[0].props.onClick
136-
// ).toBeDefined();
137-
// });
138-
139-
// test('Should have className stop-btn in Stopped component', () => {
140-
// expect(
141-
// reactWrapper.find('.stopped-button').props().children[1].props.className
142-
// ).toEqual('stop-btn');
143-
// });
36+
describe('Containers', () => {
37+
38+
beforeEach(()=>{
39+
render(<Containers {...props} />);
40+
});
14441

145-
// test('ClassName stop-btn in Stopped component have onClick function', () => {
146-
// expect(
147-
// reactWrapper.find('.stopped-button').props().children[1].props.onClick
148-
// ).toBeDefined();
149-
// });
150-
// });
42+
describe('Running List containers', () => {
43+
44+
test('Should have render correct amount of running containers', () => {
45+
const runningContainers = screen.getByText('Running Containers', {exact:false});
46+
const text = runningContainers.innerHTML;
47+
expect(text).toEqual(`Running Containers: ${props.runningList.length}`);
48+
});
49+
50+
test('Name of container should properly display', ()=>{
51+
const h3 = screen.getAllByRole('heading', { level: 3 });
52+
const name = h3[0].innerHTML;
53+
expect(name).toEqual('Name: blissful_matsumoto');
54+
});
55+
56+
test('Stop button is called', async () => {
57+
const stopButton = document.querySelector('.stop-btn');
58+
await fireEvent.click(stopButton);
59+
});
60+
61+
test('Toggle Display button works', () => {
62+
render(<ToggleDisplay {...props}/>);
63+
const button = screen.getAllByRole('button');
64+
expect(button[4]).toHaveTextContent('Show Details');
65+
fireEvent.click(button[4]);
66+
expect(button[4]).toHaveTextContent('Hide Details');
67+
68+
});
69+
});
15170

152-
//* Dummy Test
153-
describe('dummy test', () => {
154-
test('dummy test', () => {
155-
expect(2 + 2).toBe(4);
71+
describe('Stopped List Containers', () => {
72+
73+
test('Should have render correct amount of containers', () => {
74+
const exitedContainers = screen.getByText('Exited Containers', {exact:false});
75+
const text = exitedContainers.innerHTML;
76+
expect(text).toEqual(`Exited Containers: ${props.stoppedList.length}`);
77+
});
78+
79+
test('Name of container should properly display', () => {
80+
const name = screen.getAllByText('zealous');
81+
expect(name).toHaveLength(2);
82+
});
83+
84+
test('Run and remove button should fire', async () => {
85+
const buttons = screen.getAllByRole('button');
86+
const runButton = buttons[2];
87+
const removeButton = buttons[3];
88+
await fireEvent.click(runButton);
89+
await fireEvent.click(removeButton);
90+
expect(runButton).toBeCalled;
91+
expect(removeButton).toBeCalled;
92+
93+
});
94+
15695
});
157-
});
96+
});
97+

__tests__/ImageTab.test.js

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,81 @@
1-
/** Docketeer 7.0
2-
* These tests do not work as enzyme is highly depricated and does not communicate with React 18
3-
*/
1+
import React from 'react';
2+
import { describe, beforeEach, expect, test, jest } from '@jest/globals';
3+
import Images from '../src/components/tabs/Images';
4+
import {
5+
fireEvent,
6+
render,
7+
screen,
8+
} from '@testing-library/react';
49

5-
// import React from 'react';
6-
// import { configure, shallow } from "enzyme";
7-
// import Adapter from "enzyme-adapter-react-16";
8-
// import Images from '../src/components/tabs/Images';
10+
const props = {
11+
imagesList: [
12+
{
13+
imgid: '2718634043dc',
14+
size: '111 MB',
15+
reps: 'Redis',
16+
tag: 16.4,
17+
},
18+
],
19+
runIm: jest.fn(),
20+
removeIm: jest.fn(),
21+
onClick: jest.fn(),
22+
};
923

10-
// configure({ adapter: new Adapter() });
11-
// function shallowSetup() {
12-
// const props = {
13-
// imagesList: [
14-
// {
15-
// resp: "node-php-something",
16-
// tag: "latest",
17-
// imgid: "fc266a46f885",
18-
// created: "toady",
19-
// size: "234mb",
20-
// },
21-
// ],
22-
// };
23-
// const enzymeWrapper = shallow(<Images {...props} />);
24-
// return {
25-
// props,
26-
// enzymeWrapper,
27-
// };
28-
// }
29-
// describe("Shallow all of the properties of the Images", () => {
30-
// const { enzymeWrapper, props } = shallowSetup();
31-
// it("Should render <div> tag in Images", () => {
32-
// expect(enzymeWrapper.type()).toEqual("div");
33-
// expect(
34-
// enzymeWrapper.find("div.renderContainers").find("div").length
35-
// ).toEqual(8);
36-
// });
37-
// it("Should render <h1> tag in Images with a title Images", () => {
38-
// expect(enzymeWrapper.containsMatchingElement(<h1>Images</h1>)).toBe(
39-
// true
40-
// );
41-
// expect(enzymeWrapper.find(".tabTitle").text()).toEqual("Images");
42-
// });
43-
// it("Should render a div tag called runByImage and display all of the properties", () => {
44-
// expect(enzymeWrapper.find("div.runByButton").find("button").length).toEqual(
45-
// 1
46-
// );
47-
// expect(enzymeWrapper.find("div.runByButton").find("label").length).toEqual(
48-
// 1
49-
// );
50-
// expect(enzymeWrapper.find("div.runByButton").find("span").length).toEqual(
51-
// 1
52-
// );
53-
// expect(enzymeWrapper.find("div.runByButton").find("input").length).toEqual(
54-
// 1
55-
// );
56-
// });
57-
// it(`render a div with a class name "containers" and all of it properties`, () => {
58-
// expect(enzymeWrapper.find("div.containers"));
59-
// expect(enzymeWrapper.find("div.box").find("div").length).toEqual(4);
60-
// expect(enzymeWrapper.find("div.box-label").find("h3").length).toEqual(1);
61-
// expect(enzymeWrapper.find("div.box-label").find("p").length).toEqual(1);
62-
// expect(enzymeWrapper.find("div.stopped-info").find("li").length).toEqual(2);
63-
// expect(
64-
// enzymeWrapper.find("div.stopped-button").find("button").length
65-
// ).toEqual(2);
66-
// });
67-
// });
24+
describe('Images', () => {
6825

69-
//* Dummy Test
70-
describe('dummy test', () => {
71-
test('dummy test', () => {
72-
expect(2 + 2).toBe(4);
26+
beforeEach(() => {
27+
render(<Images {...props} />);
28+
screen.debug();
29+
});
30+
31+
/* ----- search bar ----- */
32+
describe('Seach bar testing', () => {
33+
test('Search accepts input', async () => {
34+
const search = screen.getByRole('textbox');
35+
await fireEvent.change(search, { target: { value: 'search' } });
36+
expect(search.value).toBe('search');
37+
});
38+
});
39+
40+
/* ----- button testing ------ */
41+
42+
describe('Run button on click', () => {
43+
test('Fires run button functionality', async () => {
44+
const runButton = screen.getByRole('button', { name: 'RUN' });
45+
await fireEvent.click(runButton);
46+
expect(runButton).toBeCalled;
47+
});
48+
});
49+
50+
51+
describe('Remove button on click', () => {
52+
test('Fires remove button functionality', async () => {
53+
const removeButton = screen.getByRole('button', { name: 'REMOVE' });
54+
await fireEvent.click(removeButton);
55+
expect(removeButton).toBeCalled;
56+
});
57+
});
58+
59+
// currently gets stuck at window.runExec method --> reads undefined
60+
// describe('pull button on click', () => {
61+
// test('fires pull button functionality', () => {
62+
// const { container } = render(<Images {...props} />);
63+
// const pullButton = screen.getByRole('button', { name: 'Pull' });
64+
// fireEvent.click(pullButton);
65+
// expect(pullButton).toBeCalled;
66+
// });
67+
// });
68+
69+
describe('Images', () => {
70+
test('Renders an image if one is found', () => {
71+
const name = screen.getByText('Redis');
72+
const id = screen.getByText('2718634043dc');
73+
const size = screen.getByText('111 MB');
74+
const tag = screen.getByText(16.4);
75+
expect(name).toBeDefined;
76+
expect(id).toBeDefined;
77+
expect(size).toBeDefined;
78+
expect(tag).toBeDefined;
79+
});
7380
});
7481
});

0 commit comments

Comments
 (0)