Skip to content

Commit

Permalink
Merge pull request #43 from oslabs-beta/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
stephenhyang authored May 16, 2024
2 parents 9be087c + baf31c9 commit ea70be2
Show file tree
Hide file tree
Showing 185 changed files with 7,411 additions and 4,731 deletions.
59 changes: 45 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,37 @@ Chronos is a comprehensive developer tool that monitors the health and web traff

## What's New?

### Chronos 13.0
### Chronos 14.0

<div>

Contributors:
[Michael Tagg](https://github.com/mdtagg),
[Ted Pham](https://github.com/TedPham397),
[Sofia Sarhiri](https://github.com/sarhiri),
[Stephen Yang](https://github.com/stephenhyang),

</div>
Updates:
<li>Implemented a new visualization button (example) to expedite data rendering processes.</li>
<li>Refactored microservices example, switched over to community version of MongoDB for easier URI implementation.</li>
<li>Modularized cluttered components into modular units to improve code readability and reusability.</li>
<li>Optimized startup scripts to reduce application load time and streamline environment configuration.</li>
<li>Upgraded Material-UI from version 4 to version 5, adapting to new API changes and improving UI responsiveness. </li>
<li>Refactored portions of the electron app </li>
<li>Refactored data parsing logic to reduce unnecessary rerenders and improve app performance</li>
<li>Fixed data bottle necks in the local npm packages, data is now able to flow to microservices for data visualization</li>


<a href='link here'>Version 14.0 Medium Article</a>

### **Iteration Log**

<details><summary>Chronos 13.0</summary>
<ul>
<div>


Contributors:
[Elsa Holmgren](https://github.com/ekh88),
[Mckenzie Morris](https://github.com/mckenzie-morris),
Expand All @@ -33,15 +60,18 @@ Contributors:

</div>
Updates:
<li>Created new and improved microservices application with updated syntax to better demonstrate Chronos' capabilities</li>
<li>Dockerized microservices application to demonstrate Chronos within a containerized environment</li>
<li>Added visulization of Chronos' codebase to illustrate overall structure</li>
<li>Simplified installation and startup instructions in the root directory README file</li>
<li>Improved documentation in chronos_npm_package README file for easier on-boarding </li>
<ul>
<li>Created new and improved microservices application with updated syntax to better demonstrate Chronos' capabilities</li>
<li>Dockerized microservices application to demonstrate Chronos within a containerized environment</li>
<li>Added visulization of Chronos' codebase to illustrate overall structure</li>
<li>Simplified installation and startup instructions in the root directory README file</li>
<li>Improved documentation in chronos_npm_package README file for easier on-boarding </li>
</ul>

<a href='https://medium.com/@holmgren.e/crisis-averted-chronos-guards-against-development-disasters-8f3653f3c136'>Version 13.0 Medium Article</a>

### **Iteration Log**
</ul>
</details>

<details><summary>Chronos 12.0</summary>
<ul>
Expand Down Expand Up @@ -186,7 +216,7 @@ Updates:
</ul>
</details>

### With Chronos 13.0
### With Chronos 14.0

<a href="https://chronoslany.com/">
<img src="assets/demo.gif" alt="Chronos" title="Chronos" align="center" height="500" width="auto" />
Expand All @@ -196,7 +226,8 @@ Updates:

## Overview of the CodeBase

- Instead of the typical folders & files view, a visual representation of the code is created. Below, it's showing the same repository, but instead of a directory structure, each file and folder as a circle: the circle’s color is the type of file, and the circle’s size represents the size of the file. See live demo <a href='https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=oslabs-beta%2FChronos'>here</a>.
- If you want to visualize the way the files in the app are connected, we suggest using this data visualizer. Below, it's showing the same repository, but instead of a directory structure, each file and folder as a circle: the circle’s color is the type of file, and the circle’s size represents the size of the file. See live demo
<a href='https://mango-dune-07a8b7110.1.azurestaticapps.net/?repo=oslabs-beta%2FChronos'>here</a>.
<img src="assets/codebase_visulization.png" alt="codebase visulization" align="center" height="500"/>

## Features
Expand Down Expand Up @@ -259,11 +290,11 @@ export DISPLAY="`sed -n 's/nameserver //p' /etc/resolv.conf`:0"
### Running the Chronos desktop app in development mode (WSL Incompatible)

1. From the root directory, run `npm install`
2. Run `npm run build`
3. For Windows users, run `npm audit fix` or `npm audit fix --force` if prompted
4. Open a new terminal and run `npm run dev:app` to start the Webpack development server
5. Open a new terminal and run `npm run dev:electron` to start the Electron UI in development mode.
6. Refer to `Examples` sections below to spin up example applications.
2. Run `npm run start:electron` to start the electron app.
3. Run `npm audit fix` or `npm audit fix --force` if prompted
4. Refer to `Examples` sections below to spin up example applications.
(Recommended):
If you have mongo community edition running locally just run `npm run start:microservices` to start populating database with server data(more detail in Microservices Example section).

#

Expand Down
2 changes: 1 addition & 1 deletion __backend-tests__/chronosMethods.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { EcoTwoTone } = require('@material-ui/icons');
const { EcoTwoTone } = require('@mui/icons-material');
const Chronos = require('../chronos_npm_package/chronos.js');
const helpers = require('../chronos_npm_package/controllers/utilities.js');
const hpropagate = require('hpropagate');
Expand Down
6 changes: 3 additions & 3 deletions __backend-tests__/mockdbsetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const connectDB = async () => {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then((result) => {
console.log(result.connection.readyState)
console.log(result.connection.host)
// console.log(result.connection.readyState)
// console.log(result.connection.host)
}).catch((err) => {
console.log('Unable to connect to MongoMemoryServer')
// console.log('Unable to connect to MongoMemoryServer')
});
};

Expand Down
6 changes: 3 additions & 3 deletions __tests__/components/About.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import About from '../../app/components/About';
import About from '../../app/components/About/About';
import DashboardContextProvider from '../../app/context/DashboardContext';

describe('About Page', () => {
Expand All @@ -22,7 +22,7 @@ describe('About Page', () => {
expect(element.querySelectorAll('h3').length).toBe(3);
});

it('Should have one div', () => {
expect(element.querySelectorAll('div').length).toBe(1);
it('Should have three divs', () => {
expect(element.querySelectorAll('div').length).toBe(3);
});
});
2 changes: 1 addition & 1 deletion __tests__/components/Contact.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import Contact from '../../app/components/Contact';
import Contact from '../../app/components/Contact/Contact';
import DashboardContextProvider from '../../app/context/DashboardContext';

describe('Contact Page', () => {
Expand Down
63 changes: 55 additions & 8 deletions __tests__/components/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/* eslint-disable import/no-named-as-default-member */
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import Header from '../../app/components/Header';
import Header from '../../app/components/Header/Header';
import ServiceDropdown from '../../app/components/Header/ServiceDropdown';
import { DashboardContext } from '../../app/context/DashboardContext';
import { ApplicationContext } from '../../app/context/ApplicationContext';
import { HashRouter as Router } from 'react-router-dom';
Expand Down Expand Up @@ -55,13 +56,59 @@ describe('Speed Chart', () => {
});

// trying to test the functionality of component not passed as props
it('Should check/uncheck the checkbox when clicking services', () => {
// const checkBox = screen.getByRole('checkbox');
// fireEvent.click(checkBox);
// expect(checkBox.parentElement).toHaveClass('selected');
// fireEvent.click(checkBox);
// expect(checkBox.parentElement).not.toHaveClass('selected');
});
// it('Should check/uncheck the checkbox when clicking services', () => {
// const checkBox = screen.getByTestId('checkbox');
// fireEvent.click(checkBox);
// expect(checkBox.parentElement).toHaveClass('selected');
// fireEvent.click(checkBox);
// expect(checkBox.parentElement).not.toHaveClass('selected');
// });

it('Should also change selectModal to true or false', () => {});
});

describe('ServiceDropdown test', () => {
it('opens and closes ServiceDropdown component on click', () => {
const servicesData = [
{ microservice: 'inventory' },
{ microservice: 'orders' },
{ microservice: 'auth' }
];

// Define initial selected services state
const selectedServices = [];

// Define a mock toggleDropdown function
const toggleDropdown = jest.fn();

// Render the ServiceDropdown component
render(
<ServiceDropdown
servicesData={servicesData}
selectedServices={selectedServices}
setSelectedServices={jest.fn()} // Mock setSelectedServices function
isOpen={false} // Assuming dropdown is closed initially
toggleDropdown={toggleDropdown}
/>
);

// Assert that dropdown is initially closed
expect(screen.queryByText('inventory')).not.toBeInTheDocument();

// simulate click event on button within ServiceDropdown component
const selectButton = screen.getByTestId('ssButton');
fireEvent.click(selectButton);

// expect the toggleDropdown function to have been called
expect(toggleDropdown).toHaveBeenCalled();

// Assert that dropdown is now open by checking that service is rendered
// expect(screen.getByText('inventory')).toBeInTheDocument();

// // Simulate click event to close the dropdown
// fireEvent.click(selectButton);

// // Assert that dropdown is now closed by checking that service is no longer rendered
// expect(screen.getByText('inventory')).not.toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion __tests__/components/Settings.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import Settings from '../../app/components/Settings';
import Settings from '../../app/components/Setting/Setting';
import { DashboardContext } from '../../app/context/DashboardContext';
import '@testing-library/jest-dom';

Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/SignUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HashRouter as Router } from 'react-router-dom';

jest.mock('electron', () => ({ ipcRenderer: { sendSync: jest.fn() } }));

describe('Create Signup Page', () => {
xdescribe('Create Signup Page', () => {
beforeEach(() => {
render(
<Router>
Expand All @@ -18,11 +18,11 @@ describe('Create Signup Page', () => {
);
});

it('should render', () => {
xit('should render', () => {
expect(screen).toBeTruthy();
});

it('Should contain an h1, h2, form, two buttons, and three inputs', () => {
xit('Should contain an h1, h2, form, two buttons, and three inputs', () => {
const element = screen.getByTestId('SignUp');
expect(element.querySelectorAll('h1').length).toBe(1);
expect(element.querySelectorAll('h2').length).toBe(1);
Expand All @@ -31,7 +31,7 @@ describe('Create Signup Page', () => {
expect(element.querySelectorAll('input').length).toBe(4);
});

it('Sign up button should submit email, username, and password to addUser', async () => {
xit('Sign up button should submit email, username, and password to addUser', async () => {
screen.debug();

const username = screen.getByPlaceholderText('enter username');
Expand Down
6 changes: 3 additions & 3 deletions app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import Splash from './components/Splash';
import DashboardContainer from './containers/DashboardContainer';
import './stylesheets/scrollBar.scss';
import Splash from './components/Splash/Splash';
import DashboardContainer from './containers/DashboardContainer/DashboardContainer';
import './index.scss';


// this is the fitness gram pacer test
Expand Down
1 change: 0 additions & 1 deletion app/assets/search.svg

This file was deleted.

64 changes: 27 additions & 37 deletions app/charts/AwsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@ import React, { useState } from 'react';
import Plot from 'react-plotly.js';
import { all, solo as soloStyle } from './sizeSwitch';

// interface AwsCpuChartProps {
// key: string;
// renderService: string;
// metric: string;
// timeList: any;
// valueList: any;
// sizing: string;
// colourGenerator: Function;
// }

interface SoloStyles {
height: number;
width: number;
}

interface IPlotlyData {
name: any;
x: any;
y: any;
type: any;
mode: any;
marker: { color: string };
}

/**
* @params props - the props object containing relevant data.
* @desc Handles AWS Charts. Memoized component to generate an AWS chart with formatted data.
Expand All @@ -26,34 +25,31 @@ interface SoloStyles {
const AwsChart: React.FC<any> = React.memo(props => {
const { renderService, metric, timeList, valueList, colourGenerator, sizing } = props;
const [solo, setSolo] = useState<SoloStyles | null>(null);

setInterval(() => {
if (solo !== soloStyle) {
setSolo(soloStyle);
}
}, 20);

const createChart = () => {
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));
// const hashedColour = colourGenerator(renderService);
let plotlyData: {
name: any;
x: any;
y: any;
type: any;
mode: any;
marker: { color: string };
};
plotlyData = {
name: metric,
x: timeArr,
y: valueList,
type: 'scattergl',
mode: 'lines',
marker: { color: colourGenerator() },
};
const sizeSwitch = sizing === 'all' ? all : solo;
const timeArr = timeList?.map((el: any) => moment(el).format('kk:mm:ss'));

let plotlyData:IPlotlyData= {
name: metric,
x: timeArr,
y: valueList,
type: 'scattergl',
mode: 'lines',
marker: { color: colourGenerator() },
};

return (
const sizeSwitch = sizing === 'all' ? all : solo;

return (
<div
className="chart"
data-testid="Health Chart"
>
<Plot
data={[plotlyData]}
config={{ displayModeBar: false }}
Expand Down Expand Up @@ -90,12 +86,6 @@ const AwsChart: React.FC<any> = React.memo(props => {
},
}}
/>
);
};

return (
<div className="chart" data-testid="Health Chart">
{createChart()}
</div>
);
});
Expand Down
Loading

0 comments on commit ea70be2

Please sign in to comment.