Skip to content

Commit

Permalink
Development (#123)
Browse files Browse the repository at this point in the history
Docketeer 8.0 pull request
  • Loading branch information
DrewManley authored Dec 15, 2022
2 parents 653ed06 + 50fa8cf commit 9dd4b20
Show file tree
Hide file tree
Showing 102 changed files with 4,002 additions and 2,588 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ src/components/display/.StoppedContainers.js.icloud
src/database/docketeerdb
.env
yarn.lock
coverage
coverage

.history
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workbench.localHistory.enabled": true
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ npm run test
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.

### Authors
- Sarah Moosa [@Sbethm](https://github.com/Sbethm) | [LinkedIn](https://www.linkedin.com/in/sarah-moosa-4b05721b6/)
- Cedar Cooper [@CedarCooper](https://github.com/CedarCooper) | [LinkedIn](https://www.linkedin.com/in/cedar-cooper/)
- Tiffany Chau [@tiffanynchau](https://github.com/tiffanynchau/) | [LinkedIn](https://www.linkedin.com/in/tiffanynchau/)
- Jack Yuan [@jackyuan1](https://github.com/jackyuan1) | [LinkedIn](https://www.linkedin.com/in/jack-yuan-298244247/)
- Drew Manley [@DrewManley](https://github.com/DrewManley) | [LinkedIn](https://www.linkedin.com/in/andrewmanley13/)
- Abigail Gerig [@4estgirl](https://github.com/4estgirl) | [Linkedin](https://www.linkedin.com/in/abigail-gerig/)
- Trine Medina [@TrineMedina](https://github.com/TrineMedina) | [Linkedin](https://www.linkedin.com/in/trinemedina/)
- Christian Looff [@cmlooff](https://github.com/cmlooff) | [LinkedIn](https://www.linkedin.com/in/christian-looff/)
Expand Down
202 changes: 71 additions & 131 deletions __tests__/ContainersTab.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { Component } from 'react';
import React from 'react';
import Containers from '../src/components/tabs/Containers';

// Started to migrate to React-Testing-Library...
import { create } from 'react-test-renderer';
import {describe, beforeEach, expect, test, jest} from '@jest/globals';
import '@testing-library/jest-dom';
import ToggleDisplay from '../src/components/display/ToggleDisplay';
import { fireEvent, render, screen } from '@testing-library/react';
import * as actions from '@testing-library/jest-dom';

const props = {
runningList: [
Expand All @@ -22,136 +21,77 @@ const props = {
stoppedList: [
{
Names: 'zealous',
ID: 'c902ec744095',
Img: '84c5f6e03bf0',
Created: '2 days ago',
name: 'zealous_pare'
ID: 'c902ec744095',
Image: '84c5f6e03bf0',
RunningFor: '2 days ago',
}
]
],
container: {MemUsage:1},
stop: jest.fn(),
remove: jest.fn(),
runStopped: jest.fn()
};
/** Docketeer 7.0
* This was the previous groups code, we left commented just incase it became useful down the road.
*/

// Debug test
// describe('Containers', () => {
// test('Renders the Container Component', () => {
// render(<Containers {...props} />);
// // Screening the component
// screen.debug();
// });
// });

// function shallowSetup() {
// const props = {
// runningList: [
// {
// block: '0B/0B',
// ID: 'a802306eeac3',
// CPUPerc: '0.17%',
// MemPerc: '0.11%',
// MemUsage: '2.195MiB/1.944GiB',
// Name: 'blissful_matsumoto',
// NetIO: '796B/0B',
// PIDs: '5'
// }
// ],
// stoppedList: [
// {
// Name: 'zealous',
// ID: 'c902ec744095',
// Img: '84c5f6e03bf0',
// Created: '2 days ago',
// name: 'zealous_pare'
// }
// ]
// };
// const reactWrapper = create(<Containers {...props} />);

// return {
// props,
// reactWrapper
// };
// }

// describe('Running containers are being rendered', () => {
// test('Should render <div> tag that has title renderContainers in Running', () => {
// // Testing for if there is a container with the title of renderContainer
// render(<Containers {...props} />);

// const renderContainer = screen.getByTitle('renderContainers');
// expect(renderContainer).toHaveClass('renderContainers');
// });

// test('Should render the correct number of containers', () => {
// const { container } = render(<Containers {...props} />);
// const containers = container.getElementsByClassName('containers');
// expect(containers.length).toBe(1);
// });
// });

// describe('It should render the exited containers', () => {
// test('Should have a className run-btn in Stopped component', () => {
// render(<Containers {...props} />);

// const runBtnRender = screen.getByTestId('run-btn');

// expect(runBtnRender).toHaveClass('run-btn');
// });

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

//! NEED TO FIGURE OUT HOW TO ADD ONCLICK TEST
// test('ClassName run-btn in stopped component have onClick function', () => {
// const handleOnClick = jest.fn();

// render(<Containers {...props} runStopped={handleOnClick} />);

// const runBtnRender = screen.queryByText('RUN');
// // screen.queryByText('RUN');

// fireEvent.click(runBtnRender);

// expect(runBtnRender).toHaveBeenCalledTimes(1);
// });
// });

// describe('It should render the exited containers', () => {
// const { reactWrapper } = shallowSetup();
//! test('Should render <div> tag in Stopped', () => {
//! expect(reactWrapper.type()).toEqual('div');
//! });

//* test('Should have className run-btn in Stopped component', () => {
//* expect(
//* reactWrapper.find('.stopped-button').props().children[0].props.className
//* ).toEqual('run-btn');
//* });

// test('ClassName run-btn in Stopped component have onClick function', () => {
// expect(
// reactWrapper.find('.stopped-button').props().children[0].props.onClick
// ).toBeDefined();
// });

// test('Should have className stop-btn in Stopped component', () => {
// expect(
// reactWrapper.find('.stopped-button').props().children[1].props.className
// ).toEqual('stop-btn');
// });
describe('Containers', () => {

beforeEach(()=>{
render(<Containers {...props} />);
});

// test('ClassName stop-btn in Stopped component have onClick function', () => {
// expect(
// reactWrapper.find('.stopped-button').props().children[1].props.onClick
// ).toBeDefined();
// });
// });
describe('Running List containers', () => {

test('Should have render correct amount of running containers', () => {
const runningContainers = screen.getByText('Running Containers', {exact:false});
const text = runningContainers.innerHTML;
expect(text).toEqual(`Running Containers: ${props.runningList.length}`);
});

test('Name of container should properly display', ()=>{
const h3 = screen.getAllByRole('heading', { level: 3 });
const name = h3[0].innerHTML;
expect(name).toEqual('Name: blissful_matsumoto');
});

test('Stop button is called', async () => {
const stopButton = document.querySelector('.stop-btn');
await fireEvent.click(stopButton);
});

test('Toggle Display button works', () => {
render(<ToggleDisplay {...props}/>);
const button = screen.getAllByRole('button');
expect(button[4]).toHaveTextContent('Show Details');
fireEvent.click(button[4]);
expect(button[4]).toHaveTextContent('Hide Details');

});
});

//* Dummy Test
describe('dummy test', () => {
test('dummy test', () => {
expect(2 + 2).toBe(4);
describe('Stopped List Containers', () => {

test('Should have render correct amount of containers', () => {
const exitedContainers = screen.getByText('Exited Containers', {exact:false});
const text = exitedContainers.innerHTML;
expect(text).toEqual(`Exited Containers: ${props.stoppedList.length}`);
});

test('Name of container should properly display', () => {
const name = screen.getAllByText('zealous');
expect(name).toHaveLength(2);
});

test('Run and remove button should fire', async () => {
const buttons = screen.getAllByRole('button');
const runButton = buttons[2];
const removeButton = buttons[3];
await fireEvent.click(runButton);
await fireEvent.click(removeButton);
expect(runButton).toBeCalled;
expect(removeButton).toBeCalled;

});

});
});
});

145 changes: 76 additions & 69 deletions __tests__/ImageTab.test.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,81 @@
/** Docketeer 7.0
* These tests do not work as enzyme is highly depricated and does not communicate with React 18
*/
import React from 'react';
import { describe, beforeEach, expect, test, jest } from '@jest/globals';
import Images from '../src/components/tabs/Images';
import {
fireEvent,
render,
screen,
} from '@testing-library/react';

// import React from 'react';
// import { configure, shallow } from "enzyme";
// import Adapter from "enzyme-adapter-react-16";
// import Images from '../src/components/tabs/Images';
const props = {
imagesList: [
{
imgid: '2718634043dc',
size: '111 MB',
reps: 'Redis',
tag: 16.4,
},
],
runIm: jest.fn(),
removeIm: jest.fn(),
onClick: jest.fn(),
};

// configure({ adapter: new Adapter() });
// function shallowSetup() {
// const props = {
// imagesList: [
// {
// resp: "node-php-something",
// tag: "latest",
// imgid: "fc266a46f885",
// created: "toady",
// size: "234mb",
// },
// ],
// };
// const enzymeWrapper = shallow(<Images {...props} />);
// return {
// props,
// enzymeWrapper,
// };
// }
// describe("Shallow all of the properties of the Images", () => {
// const { enzymeWrapper, props } = shallowSetup();
// it("Should render <div> tag in Images", () => {
// expect(enzymeWrapper.type()).toEqual("div");
// expect(
// enzymeWrapper.find("div.renderContainers").find("div").length
// ).toEqual(8);
// });
// it("Should render <h1> tag in Images with a title Images", () => {
// expect(enzymeWrapper.containsMatchingElement(<h1>Images</h1>)).toBe(
// true
// );
// expect(enzymeWrapper.find(".tabTitle").text()).toEqual("Images");
// });
// it("Should render a div tag called runByImage and display all of the properties", () => {
// expect(enzymeWrapper.find("div.runByButton").find("button").length).toEqual(
// 1
// );
// expect(enzymeWrapper.find("div.runByButton").find("label").length).toEqual(
// 1
// );
// expect(enzymeWrapper.find("div.runByButton").find("span").length).toEqual(
// 1
// );
// expect(enzymeWrapper.find("div.runByButton").find("input").length).toEqual(
// 1
// );
// });
// it(`render a div with a class name "containers" and all of it properties`, () => {
// expect(enzymeWrapper.find("div.containers"));
// expect(enzymeWrapper.find("div.box").find("div").length).toEqual(4);
// expect(enzymeWrapper.find("div.box-label").find("h3").length).toEqual(1);
// expect(enzymeWrapper.find("div.box-label").find("p").length).toEqual(1);
// expect(enzymeWrapper.find("div.stopped-info").find("li").length).toEqual(2);
// expect(
// enzymeWrapper.find("div.stopped-button").find("button").length
// ).toEqual(2);
// });
// });
describe('Images', () => {

//* Dummy Test
describe('dummy test', () => {
test('dummy test', () => {
expect(2 + 2).toBe(4);
beforeEach(() => {
render(<Images {...props} />);
screen.debug();
});

/* ----- search bar ----- */
describe('Seach bar testing', () => {
test('Search accepts input', async () => {
const search = screen.getByRole('textbox');
await fireEvent.change(search, { target: { value: 'search' } });
expect(search.value).toBe('search');
});
});

/* ----- button testing ------ */

describe('Run button on click', () => {
test('Fires run button functionality', async () => {
const runButton = screen.getByRole('button', { name: 'RUN' });
await fireEvent.click(runButton);
expect(runButton).toBeCalled;
});
});


describe('Remove button on click', () => {
test('Fires remove button functionality', async () => {
const removeButton = screen.getByRole('button', { name: 'REMOVE' });
await fireEvent.click(removeButton);
expect(removeButton).toBeCalled;
});
});

// currently gets stuck at window.runExec method --> reads undefined
// describe('pull button on click', () => {
// test('fires pull button functionality', () => {
// const { container } = render(<Images {...props} />);
// const pullButton = screen.getByRole('button', { name: 'Pull' });
// fireEvent.click(pullButton);
// expect(pullButton).toBeCalled;
// });
// });

describe('Images', () => {
test('Renders an image if one is found', () => {
const name = screen.getByText('Redis');
const id = screen.getByText('2718634043dc');
const size = screen.getByText('111 MB');
const tag = screen.getByText(16.4);
expect(name).toBeDefined;
expect(id).toBeDefined;
expect(size).toBeDefined;
expect(tag).toBeDefined;
});
});
});
Loading

0 comments on commit 9dd4b20

Please sign in to comment.