Skip to content

Commit a44289c

Browse files
committed
Merge branch 'dev' into Hernan/alerts
2 parents 36b1f68 + 2d0e249 commit a44289c

File tree

20 files changed

+178
-92
lines changed

20 files changed

+178
-92
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,4 @@ amplifytools.xcconfig
524524
**.sample
525525
#amplify-do-not-edit-end
526526

527-
team-provider-info.json
527+
/amplify/team-provider-info.json

__tests__/NavBar.test.tsx

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import '@testing-library/jest-dom/extend-expect';
44
import { MemoryRouter } from 'react-router-dom';
55
import { ThemeProvider, createTheme } from '@mui/material/styles';
66
import NavBar from '../app/src/components/top/NavBar';
7-
import navBarButtons from '../app/src/components/top/NavBarButtons';
87
import * as projectFunctions from '../app/src/helperFunctions/projectGetSaveDel';
98
import { Provider } from 'react-redux';
9+
import { act } from 'react-dom/test-utils';
1010
import { configureStore } from '@reduxjs/toolkit';
1111
import rootReducer from '../app/src/redux/reducers/rootReducer';
1212
import { initialState as appStateInitialState } from '../app/src/redux/reducers/slice/appStateSlice';
1313

14-
15-
1614
// Mock the non-serializable HTMLTypes
1715
const mockHTMLTypes = [
1816
{
@@ -47,7 +45,6 @@ const mockHTMLTypes = [
4745
},
4846
];
4947

50-
5148
// Mocking the theme
5249
const theme = createTheme({
5350
spacing: (value) => `${value}px`,
@@ -117,8 +114,10 @@ describe('NavBar Component', () => {
117114

118115
console.log('After rendering NavBar');
119116

120-
const publishButton = getByText('Publish');
121-
fireEvent.click(publishButton);
117+
await act(async () => {
118+
const publishButton = getByText('Publish');
119+
fireEvent.click(publishButton);
120+
});
122121
});
123122

124123
it('handles publish correctly with new project', async () => {
@@ -147,26 +146,27 @@ describe('NavBar Component', () => {
147146

148147
console.log('After rendering NavBar');
149148

150-
// Check if the "Publish" button is present
151-
const publishButton = queryByText('Publish');
149+
await act(async () => {
150+
// Check if the "Publish" button is present
151+
const publishButton = queryByText('Publish');
152152

153-
if (publishButton) {
154-
fireEvent.click(publishButton);
155-
} else {
156-
// If "Publish" button is not found, look for the "Unpublish" button
157-
const unpublishButton = getByText('Unpublish');
158-
fireEvent.click(unpublishButton);
159-
}
153+
if (publishButton) {
154+
fireEvent.click(publishButton);
155+
} else {
156+
// If "Publish" button is not found, look for the "Unpublish" button
157+
const unpublishButton = getByText('Unpublish');
158+
fireEvent.click(unpublishButton);
159+
}
160160

161-
// Check if the modal for a new project is displayed
162-
const projectNameInput = queryByTestId('project-name-input');
161+
// Check if the modal for a new project is displayed
162+
const projectNameInput = queryByTestId('project-name-input');
163163

164-
if (projectNameInput) {
165-
// entering a project name in the modal
166-
fireEvent.change(projectNameInput, { target: { value: 'My Project' } });
167-
}
164+
if (projectNameInput) {
165+
// entering a project name in the modal
166+
fireEvent.change(projectNameInput, { target: { value: 'My Project' } });
167+
}
168168
});
169-
169+
});
170170

171171
it('handles unpublish correctly', async () => {
172172
const unpublishProjectMock = jest.spyOn(projectFunctions, 'unpublishProject');
@@ -239,7 +239,8 @@ describe('NavBar Component', () => {
239239
fireEvent.click(exportComponentsOption);
240240

241241
});
242-
test('handles dropdown menu correctly', async () => {
242+
243+
it('handles dropdown menu correctly', async () => {
243244
const store = configureStore({
244245
reducer: rootReducer,
245246
preloadedState: {
@@ -248,8 +249,9 @@ describe('NavBar Component', () => {
248249
},
249250
},
250251
});
251-
252-
// Render component
252+
253+
console.log('Before rendering NavBar');
254+
253255
const { getByTestId, getByText } = render(
254256
<Provider store={store}>
255257
<MemoryRouter>
@@ -259,33 +261,34 @@ describe('NavBar Component', () => {
259261
</MemoryRouter>
260262
</Provider>
261263
);
262-
263-
// Initially, the dropdown should have the "hideNavDropDown" class
264-
const dropdownMenu = getByTestId('navDropDown');
265-
expect(dropdownMenu).toHaveClass('hideNavDropDown');
266-
267-
// Find and click the button to open the dropdown
268-
const moreVertButton = getByTestId('more-vert-button');
269-
fireEvent.click(moreVertButton);
270-
271-
// After clicking, the dropdown should have the "navDropDown" class
272-
expect(dropdownMenu).toHaveClass('navDropDown');
273-
274-
275-
//clear canvas click
276-
const clearCanvasMenuItem = getByText('Clear Canvas');
277-
fireEvent.click(clearCanvasMenuItem);
278-
expect(dropdownMenu).toHaveClass('navDropDown');
279-
280-
// After clicking "Marketplace", it should remain open
281-
const marketplaceMenuItem = getByText('Marketplace');
282-
fireEvent.click(marketplaceMenuItem);
283-
expect(dropdownMenu).toHaveClass('navDropDown');
284-
285-
// Close the dropdown by clicking the button again
286-
fireEvent.click(moreVertButton);
287-
288-
// After closing, the dropdown should have the "hideNavDropDown" class
289-
expect(dropdownMenu).toHaveClass('hideNavDropDown');
264+
265+
console.log('After rendering NavBar');
266+
267+
await act(async () => {
268+
269+
const dropdownMenu = getByTestId('navDropDown');
270+
expect(dropdownMenu).toHaveClass('hideNavDropDown');
271+
272+
273+
const moreVertButton = getByTestId('more-vert-button');
274+
fireEvent.click(moreVertButton);
275+
276+
277+
expect(dropdownMenu).toHaveClass('hideNavDropDown');
278+
279+
280+
const clearCanvasMenuItem = getByText('Clear Canvas');
281+
fireEvent.click(clearCanvasMenuItem);
282+
expect(dropdownMenu).toHaveClass('hideNavDropDown');
283+
284+
285+
const marketplaceMenuItem = getByText('Marketplace');
286+
fireEvent.click(marketplaceMenuItem);
287+
expect(dropdownMenu).toHaveClass('hideNavDropDown');
288+
289+
fireEvent.click(moreVertButton);
290+
291+
expect(dropdownMenu).toHaveClass('hideNavDropDown');
292+
});
290293
});
291-
});
294+
})

app/src/components/App.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@ export const App = (): JSX.Element => {
3232

3333
// following useEffect runs on first mount
3434
useEffect(() => {
35-
console.log('state.isLoggedIn', state.isLoggedIn)
3635
// console.log('cookies.get in App', Cookies.get())
3736
// if user is a guest, see if a project exists in localforage and retrieve it
3837
// v17 May not currently work yet
3938
if (!state.isLoggedIn) {
40-
console.log('not state.islogged in')
4139
localforage.getItem('guestProject').then((project) => {
4240
// if project exists, use dispatch to set initial state to that project
43-
console.log('guestProject', project)
4441
if (project) {
4542
dispatch(setInitialState(project));
46-
console.log('project', project)
4743
}
4844
});
4945
} else {

app/src/components/ContextAPIManager/CreateTab/CreateContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ const CreateContainer = () => {
8282
setCurrentContext('');
8383
};
8484

85-
console.log('state.allContext', state.allContext);
8685
return (
8786
<>
8887
<Grid container display="flex" justifyContent="space-evenly">

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const AddContextForm = ({
2323
setErrorStatus
2424
}) => {
2525
const { allContext } = contextStore;
26-
console.log('all contexts', allContext);
2726
const [btnDisabled, setBtnDisabled] = useState(false);
2827
const [open, setOpen] = useState(false);
2928
const { state, isDarkMode } = useSelector((store: RootState) => ({

app/src/components/StateManagement/CreateTab/components/StatePropsPanel.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const StatePropsPanel = ({ isThemeLight, data }): JSX.Element => {
6262
try{
6363
let retVal = JSON.parse(value);
6464
if(Array.isArray(retVal)){
65-
console.log('is this an array still', retVal)
6665
setInputTypeError('');
6766
return retVal
6867
}else{
@@ -195,7 +194,6 @@ const StatePropsPanel = ({ isThemeLight, data }): JSX.Element => {
195194
if (exists) {
196195
setInputKey(table.row.key);
197196
setInputType(table.row.type);
198-
console.log("tablerowvalue", table.row.value);
199197
setInputValue(table.row.value ? JSON.stringify(table.row.value) : '');
200198
} else clearForm();
201199
};
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import React from 'react';
2+
import Table from '@mui/material/Table';
3+
import TableBody from '@mui/material/TableBody';
4+
import TableContainer from '@mui/material/TableContainer';
5+
import TableHead from '@mui/material/TableHead';
6+
import TableRow from '@mui/material/TableRow';
7+
import Paper from '@mui/material/Paper';
8+
import { styled } from '@mui/material/styles';
9+
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
10+
import { useSelector } from 'react-redux';
11+
import { RootState } from '../../../redux/store'
12+
13+
const StyledTableCell = styled(TableCell)(({ theme }) => ({
14+
[`&.${tableCellClasses.head}`]: {
15+
backgroundColor: theme.palette.common.black,
16+
color: theme.palette.common.white,
17+
},
18+
[`&.${tableCellClasses.body}`]: {
19+
color: theme.palette.common.black,
20+
fontSize: 14,
21+
},
22+
}));
23+
24+
const StyledTableRow = styled(TableRow)(({ theme }) => ({
25+
'&:nth-of-type(odd)': {
26+
backgroundColor: theme.palette.action.hover
27+
},
28+
// hide last border
29+
'&:last-child td, &:last-child th': {
30+
border: 0,
31+
},
32+
}));
33+
34+
export default function DataTable(props) {
35+
const {
36+
currComponentState, parentProps, clickedComp, data,
37+
} = props;
38+
const state = useSelector((store:RootState) => store.appState)
39+
40+
// determine if the current component is a root component
41+
let isRoot = false;
42+
43+
for (let i = 0; i < data.length; i++) {
44+
if (data[i].name === clickedComp) {
45+
if (state.rootComponents.includes(data[i].id)) isRoot = true;
46+
}
47+
}
48+
49+
return (
50+
<TableContainer component={Paper} sx={{ maxHeight: '350px' }}>
51+
<Table
52+
sx={{ width: '510px' }}
53+
aria-label="customized table"
54+
stickyHeader
55+
>
56+
57+
{/* we are checking if the clicked component is a root component-- if yes, it doesn't have any parents so don't need passed-in props table */}
58+
{(!isRoot
59+
&& (
60+
<>
61+
<TableHead>
62+
<TableRow>
63+
<StyledTableCell align="center" colSpan={3}>
64+
Props Passed in from Parent:
65+
</StyledTableCell>
66+
</TableRow>
67+
</TableHead>
68+
<TableBody>
69+
<StyledTableRow>
70+
<StyledTableCell component="th" scope="row"><b>Key</b></StyledTableCell>
71+
<StyledTableCell align="right"><b>Type</b></StyledTableCell>
72+
<StyledTableCell align="right"><b>Initial Value</b></StyledTableCell>
73+
</StyledTableRow>
74+
{parentProps ? parentProps.map((data, index) => (
75+
<StyledTableRow key={index}>
76+
<StyledTableCell component="th" scope="row">{data.key}</StyledTableCell>
77+
<StyledTableCell align="right">{data.type}</StyledTableCell>
78+
<StyledTableCell align="right">{data.value}</StyledTableCell>
79+
</StyledTableRow>
80+
)) : ''}
81+
</TableBody>
82+
</>
83+
)
84+
)}
85+
86+
{/* The below table will contain the state initialized within the clicked component */}
87+
<TableHead>
88+
<TableRow>
89+
<StyledTableCell align="center" colSpan={3}>
90+
State Initialized in Current Component:
91+
</StyledTableCell>
92+
</TableRow>
93+
</TableHead>
94+
<TableBody>
95+
<StyledTableRow>
96+
<StyledTableCell component="th" scope="row"><b>Key</b></StyledTableCell>
97+
<StyledTableCell align="right"><b>Type</b></StyledTableCell>
98+
<StyledTableCell align="right"><b>Initial Value</b></StyledTableCell>
99+
</StyledTableRow>
100+
{currComponentState ? currComponentState.map((data, index) => (
101+
<StyledTableRow key={index}>
102+
<StyledTableCell component="th" scope="row">{data.key}</StyledTableCell>
103+
<StyledTableCell align="right">{data.type}</StyledTableCell>
104+
<StyledTableCell align="right">{data.value}</StyledTableCell>
105+
</StyledTableRow>
106+
)) : ''}
107+
</TableBody>
108+
</Table>
109+
</TableContainer>
110+
);
111+
}

app/src/components/left/RoomsContainer.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const RoomsContainer = () => {
6262
if (currentStore !== event) {
6363
currentStore = JSON.parse(currentStore);
6464
event = JSON.parse(event);
65-
console.log('stores do not match');
6665
if (currentStore.darkMode.isDarkMode !== event.darkMode.isDarkMode) {
6766
store.dispatch(toggleDarkMode());
6867
} else if (currentStore.appState !== event.appState) {
@@ -75,7 +74,6 @@ const RoomsContainer = () => {
7574
store.dispatch(cooperativeStyle(event.styleSlice));
7675
}
7776
}
78-
console.log('updated user Store from another user: ', store.getState());
7977
});
8078
}
8179

@@ -84,7 +82,6 @@ const RoomsContainer = () => {
8482
}
8583

8684
function joinRoom() {
87-
console.log(roomCode);
8885
dispatch(changeRoom(roomCode));
8986
setConfirmRoom((confirmRoom) => roomCode);
9087

app/src/components/left/Sidebar.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ const Sidebar: React.FC<SidebarProps> = ({
2222
setActiveTab(newValue);
2323
toggleVisibility(true);// Show the left-container when a different tab is clicked
2424
oldValue = newValue;//setting the oldvalue to match the new tab
25-
console.log('oldValue change', oldValue)
2625
};
2726

2827
const handleTabClick = (event: React.MouseEvent, oldValue: number) => {
2928
if (activeTab === oldValue) { //if the person is clicking the same tab, oldValue should match activeTab since it did not trigger an onChange
30-
console.log('handleTabChange null', oldValue)
3129
setActiveTab(null);
3230
toggleVisibility(false); // Hide the left-container when the same tab is clicked again
3331
}

app/src/components/marketplace/MarketplaceCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ const MarketplaceCard = ({ proj }: { proj: Project }) => {
5858
try {
5959
const objId: string = proj._id.toString();
6060
// the below functions are commented out as not to incur too many charges
61-
// const response: string = await Storage.get(objId);
61+
const response: string = await Storage.get(objId);
6262
// const response: string = await Storage.get('test');
63-
// setS3ImgURL(response);
63+
setS3ImgURL(response);
6464
} catch (error) {
6565
console.error(`Error fetching image preview for ${proj._id}: `, error);
6666
}

app/src/components/right/DeleteProjects.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ function ProjectsDialog(props: ProjectDialogProps) {
4444
const selectedProject = projects.filter(
4545
(project: any) => project._id === value
4646
)[0];
47-
console.log('deleting this one', selectedProject)
4847
deleteProject(selectedProject);
4948
localforage.removeItem(window.localStorage.getItem('ssid'));
5049
dispatch(setInitialState(initialState))

0 commit comments

Comments
 (0)