Skip to content

Commit a8a3a24

Browse files
committed
Merge branch 'dev' into ted-dev
2 parents 6123883 + e982757 commit a8a3a24

File tree

14 files changed

+963
-538
lines changed

14 files changed

+963
-538
lines changed

__tests__/components/About.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
3-
import About from '../../app/components/About';
3+
import About from '../../app/components/About/About';
44
import DashboardContextProvider from '../../app/context/DashboardContext';
55

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

25-
it('Should have one div', () => {
26-
expect(element.querySelectorAll('div').length).toBe(1);
25+
it('Should have three divs', () => {
26+
expect(element.querySelectorAll('div').length).toBe(3);
2727
});
2828
});

__tests__/components/Contact.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
3-
import Contact from '../../app/components/Contact';
3+
import Contact from '../../app/components/Contact/Contact';
44
import DashboardContextProvider from '../../app/context/DashboardContext';
55

66
describe('Contact Page', () => {

__tests__/components/Header.test.tsx

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/* eslint-disable import/no-named-as-default-member */
33
import React from 'react';
44
import { render, fireEvent, screen } from '@testing-library/react';
5-
import Header from '../../app/components/Header';
5+
import Header from '../../app/components/Header/Header';
6+
import ServiceDropdown from '../../app/components/Header/ServiceDropdown';
67
import { DashboardContext } from '../../app/context/DashboardContext';
78
import { ApplicationContext } from '../../app/context/ApplicationContext';
89
import { HashRouter as Router } from 'react-router-dom';
@@ -55,13 +56,59 @@ describe('Speed Chart', () => {
5556
});
5657

5758
// trying to test the functionality of component not passed as props
58-
it('Should check/uncheck the checkbox when clicking services', () => {
59-
// const checkBox = screen.getByRole('checkbox');
60-
// fireEvent.click(checkBox);
61-
// expect(checkBox.parentElement).toHaveClass('selected');
62-
// fireEvent.click(checkBox);
63-
// expect(checkBox.parentElement).not.toHaveClass('selected');
64-
});
59+
// it('Should check/uncheck the checkbox when clicking services', () => {
60+
// const checkBox = screen.getByTestId('checkbox');
61+
// fireEvent.click(checkBox);
62+
// expect(checkBox.parentElement).toHaveClass('selected');
63+
// fireEvent.click(checkBox);
64+
// expect(checkBox.parentElement).not.toHaveClass('selected');
65+
// });
6566

6667
it('Should also change selectModal to true or false', () => {});
6768
});
69+
70+
describe('ServiceDropdown test', () => {
71+
it('opens and closes ServiceDropdown component on click', () => {
72+
const servicesData = [
73+
{ microservice: 'inventory' },
74+
{ microservice: 'orders' },
75+
{ microservice: 'auth' }
76+
];
77+
78+
// Define initial selected services state
79+
const selectedServices = [];
80+
81+
// Define a mock toggleDropdown function
82+
const toggleDropdown = jest.fn();
83+
84+
// Render the ServiceDropdown component
85+
render(
86+
<ServiceDropdown
87+
servicesData={servicesData}
88+
selectedServices={selectedServices}
89+
setSelectedServices={jest.fn()} // Mock setSelectedServices function
90+
isOpen={false} // Assuming dropdown is closed initially
91+
toggleDropdown={toggleDropdown}
92+
/>
93+
);
94+
95+
// Assert that dropdown is initially closed
96+
expect(screen.queryByText('inventory')).not.toBeInTheDocument();
97+
98+
// simulate click event on button within ServiceDropdown component
99+
const selectButton = screen.getByTestId('ssButton');
100+
fireEvent.click(selectButton);
101+
102+
// expect the toggleDropdown function to have been called
103+
expect(toggleDropdown).toHaveBeenCalled();
104+
105+
// Assert that dropdown is now open by checking that service is rendered
106+
// expect(screen.getByText('inventory')).toBeInTheDocument();
107+
108+
// // Simulate click event to close the dropdown
109+
// fireEvent.click(selectButton);
110+
111+
// // Assert that dropdown is now closed by checking that service is no longer rendered
112+
// expect(screen.getByText('inventory')).not.toBeInTheDocument();
113+
});
114+
});

__tests__/components/Settings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render, fireEvent, screen } from '@testing-library/react';
3-
import Settings from '../../app/components/Settings';
3+
import Settings from '../../app/components/Setting/Setting';
44
import { DashboardContext } from '../../app/context/DashboardContext';
55
import '@testing-library/jest-dom';
66

__tests__/components/SignUp.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { HashRouter as Router } from 'react-router-dom';
77

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

10-
describe('Create Signup Page', () => {
10+
xdescribe('Create Signup Page', () => {
1111
beforeEach(() => {
1212
render(
1313
<Router>

app/components/Header/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ interface HeaderProps {
3030
};
3131

3232
return (
33-
<div className="microservice-header">
33+
<div className="microservice-header" data-testid="Header">
3434
<h1 className="microserviceTitle">{app}</h1>
3535
<ServiceDropdown
3636
servicesData={servicesData}
3737
selectedServices={selectedServices}
3838
setSelectedServices={setSelectedServices}
3939
isOpen={selectModal}
4040
toggleDropdown={toggleDropdown}
41+
data-testid="ServiceDropdownToggle"
4142
/>
4243
<LiveToggle live={live} toggleLive={() => setLive && setLive(!live)} />
4344
</div>

app/components/Header/ServiceDropdown.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
const ServiceDropdown = ({ servicesData, selectedServices, setSelectedServices, isOpen, toggleDropdown }) => {
3+
const ServiceDropdown = ({ servicesData, selectedServices, setSelectedServices, isOpen, toggleDropdown }) => {
44
const handleCheckbox = (e) => {
55
const service = e.target.value;
66
if (e.target.checked) {
@@ -12,7 +12,7 @@ const ServiceDropdown = ({ servicesData, selectedServices, setSelectedServices,
1212

1313
return (
1414
<div className={isOpen ? 'dropdown active' : 'dropdown'}>
15-
<div className={isOpen ? 'select disabled' : 'select'} onClick={toggleDropdown}>
15+
<div className={isOpen ? 'select disabled' : 'select'} onClick={toggleDropdown} data-testid="ssButton">
1616
Select Services
1717
</div>
1818
{isOpen && (
@@ -21,6 +21,7 @@ const ServiceDropdown = ({ servicesData, selectedServices, setSelectedServices,
2121
<label key={service.microservice} className="select">
2222
{service.microservice}
2323
<input
24+
data-testid="checkbox"
2425
type="checkbox"
2526
value={service.microservice}
2627
checked={selectedServices.includes(service.microservice)}

app/components/Occupied/Occupied.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const Occupied = React.memo(() => {
8282

8383
>
8484
<Button
85-
style={currentStyle}
8685
className={classes.paper}
8786
onClick={() => setModal({isOpen:true,type:'envModal'})}
8887
>

app/components/SearchBar/styles.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
align-items: center;
1111
}
1212

13+
.form :hover{
14+
cursor: pointer;
15+
}
16+
1317
.inputContainer {
1418
position: relative;
1519
display: flex;
@@ -18,10 +22,11 @@
1822
.searchIconSvg {
1923
transform: scale(0.1) translate(758.9px, -720px);
2024
position: absolute;
21-
fill: white;
25+
fill: rgb(131, 129, 133);
2226
}
2327
}
2428

29+
2530
#textInput {
2631
background-color: transparent;
2732
font-family: 'Roboto';

app/components/Styling.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ const lightAndDark = {
4444
backgroundColor: '#F7F8F8',
4545
color: '#24272A',
4646
},
47+
darkModeButtons:{
48+
backgroundColor: '#F3F3F7',
49+
color: '#1C202D',
50+
},
51+
lightModeButtons:{
52+
backgroundColor: '#1C202D',
53+
color: '#1C202D',
54+
}
4755
};
4856

4957
export default lightAndDark;

0 commit comments

Comments
 (0)