Skip to content

Commit f094bff

Browse files
authored
Merge pull request #7 from oslabs-beta/cyrus
Webpack to Vite
2 parents 55e23df + 7af1dff commit f094bff

Some content is hidden

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

58 files changed

+2152
-713
lines changed

__tests__/server.test.tsx

Lines changed: 133 additions & 122 deletions
Large diffs are not rendered by default.

__tests__/userAuth.test.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import mockData from '../mockData';
77
import { Sessions, Users } from '../server/models/reactypeModels';
88
const request = require('supertest');
99
const mongoose = require('mongoose');
10-
const MONGO_DB = process.env.MONGO_DB_TEST;
10+
const mockNext = jest.fn(); // Mock nextFunction
11+
const MONGO_DB = import.meta.env.MONGO_DB_TEST;
1112
const { user } = mockData;
13+
const PORT = 8080;
1214

1315
const num = Math.floor(Math.random() * 1000);
1416

@@ -40,7 +42,6 @@ describe('User Authentication tests', () => {
4042
expect(response.text).toBe('test request is working');
4143
});
4244
});
43-
4445
describe('/signup', () => {
4546
describe('POST', () => {
4647
//testing new signup
@@ -147,39 +148,3 @@ describe('User Authentication tests', () => {
147148
});
148149
});
149150
});
150-
151-
// describe('sessionIsCreated', () => {
152-
153-
// // note that the username and password in this test are kept in the heroku database
154-
// // DO NOT CHANGE unless you have access to the heroku database
155-
// it("returns the message 'Success' when the user passes all auth checks", () => {
156-
// return request(app)
157-
// .post('/login')
158-
// .send({
159-
// username: 'test',
160-
// password: 'password1!',
161-
// isFbOauth: false
162-
// })
163-
// .then((res) => expect(res.body).toHaveProperty('sessionId'));
164-
// });
165-
166-
// // // OAuth tests (currently inoperative)
167-
// // xdescribe('Github oauth tests', () => {
168-
// // describe('/github/callback?code=', () => {
169-
// // describe('GET', () => {
170-
// // it('responds with status 400 and error message if no code received', () => {
171-
// // return request(server)
172-
// // .get('/github/callback?code=')
173-
// // .expect(400)
174-
// // .then((res) => {
175-
// // return expect(res.text).toEqual(
176-
// // '"Undefined or no code received from github.com"'
177-
// // );
178-
// // });
179-
// // });
180-
// // it('responds with status 400 if invalid code received', () => {
181-
// // return request(server).get('/github/callback?code=123456').expect(400);
182-
// // });
183-
// // });
184-
// // });
185-
// // });

app/.electron/main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import MenuBuilder from './menu';
3030

3131
// mode that the app is running in
3232
const isDev =
33-
process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
33+
import.meta.env.NODE_ENV === 'development' ||
34+
import.meta.env.NODE_ENV === 'test';
3435
const port = 8080;
3536
const selfHost = `http://localhost:${port}`;
3637

@@ -388,8 +389,8 @@ ipcMain.on('github', (event) => {
388389
? `http://localhost:${DEV_PORT}/auth/github`
389390
: `https://reactype-caret.herokuapp.com/auth/github`;
390391
const options = {
391-
client_id: process.env.GITHUB_ID,
392-
client_secret: process.env.GITHUB_SECRET,
392+
client_id: import.meta.env.GITHUB_ID,
393+
client_secret: import.meta.env.GITHUB_SECRET,
393394
scopes: ['user:email', 'notifications']
394395
};
395396
// create new browser window object with size, title, security options

app/.electron/menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var MenuBuilder = function (mainWindow, appName) {
4747
devTools: false
4848
}
4949
});
50-
if (process.env.NODE_ENV === 'development') {
50+
if (import.meta.env.NODE_ENV === 'development') {
5151
tutorial.loadURL(`http://localhost:8080/#/tutorial`);
5252
} else {
5353
tutorial.loadURL(`${Protocol.scheme}://rse/index-prod.html#/tutorial`);

app/src/Dashboard/NavbarDash.tsx

Lines changed: 113 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,38 @@ import SortIcon from '@mui/icons-material/Sort';
1919
import StarBorderIcon from '@mui/icons-material/StarBorder';
2020
import PersonIcon from '@mui/icons-material/Person';
2121
import greenLogo from '../public/icons/png/512x512.png';
22-
import {setStyle} from '../redux/reducers/slice/styleSlice'
23-
import { useSelector,useDispatch } from 'react-redux';
22+
import { setStyle } from '../redux/reducers/slice/styleSlice';
23+
import { useSelector, useDispatch } from 'react-redux';
2424

2525
// NavBar text and button styling
26-
const useStyles = makeStyles((theme: Theme) => createStyles({
27-
root: {
28-
flexGrow: 1,
29-
width: '100%',
30-
},
31-
menuButton: {
32-
marginRight: theme.spacing(2),
33-
color: 'white',
34-
},
35-
title: {
36-
flexGrow: 1,
37-
color: 'white',
38-
},
39-
manageProject: {
40-
display: 'flex',
41-
justifyContent: 'center',
42-
},
43-
}));
26+
const useStyles = makeStyles((theme: Theme) =>
27+
createStyles({
28+
root: {
29+
flexGrow: 1,
30+
width: '100%'
31+
},
32+
menuButton: {
33+
marginRight: theme.spacing(2),
34+
color: 'white'
35+
},
36+
title: {
37+
flexGrow: 1,
38+
color: 'white'
39+
},
40+
manageProject: {
41+
display: 'flex',
42+
justifyContent: 'center'
43+
}
44+
})
45+
);
4446
// sorting options
4547
const sortMethods = ['RATING', 'DATE', 'USER'];
4648
// Drop down menu button for SORT PROJECTS
4749
const StyledMenu = withStyles({
4850
paper: {
49-
border: '1px solid #d3d4d5',
51+
border: '1px solid #d3d4d5'
5052
}
51-
})(props => (
53+
})((props) => (
5254
<Menu
5355
elevation={0}
5456
// getContentAnchorEl={null}
@@ -63,7 +65,7 @@ const StyledMenu = withStyles({
6365
{...props}
6466
/>
6567
));
66-
const StyledMenuItem = withStyles(theme => ({
68+
const StyledMenuItem = withStyles((theme) => ({
6769
root: {
6870
'&:focus': {
6971
'& .MuiListItemIcon-root, & .MuiListItemText-primary': {
@@ -76,95 +78,123 @@ const StyledMenuItem = withStyles(theme => ({
7678
export default function NavBar(props) {
7779
// TO DO: import setStyle
7880
const classes = useStyles();
79-
const style = useSelector(store => store.styleSlice);
81+
const style = useSelector((store) => store.styleSlice);
8082
const dispatch = useDispatch();
8183
const toggling = () => setIsOpen(!isOpen);
8284
// toggle to open and close dropdown sorting menu
8385
const [isOpen, setIsOpen] = useState(false);
8486
// State for sort projects button
8587
const [anchorEl, setAnchorEl] = React.useState(null);
86-
const handleClick = event => {
88+
const handleClick = (event) => {
8789
setAnchorEl(event.currentTarget);
8890
};
8991
const handleClose = () => {
9092
setAnchorEl(null);
9193
};
9294
return (
9395
<div className={classes.root} style={style}>
94-
<AppBar position='static'>
96+
<AppBar position="static">
9597
<Toolbar>
96-
<Link to="/" style={{display: 'inline-flex', justifyContent: 'center', textDecoration: 'none'}}>
98+
<Link
99+
to="/"
100+
style={{
101+
display: 'inline-flex',
102+
justifyContent: 'center',
103+
textDecoration: 'none'
104+
}}
105+
>
97106
<Avatar src={greenLogo}></Avatar>
98-
<Typography variant="h6" style={{ marginTop: '0.3rem', marginLeft: '0.5rem', color: 'silver' }} className={classes.title}>
107+
<Typography
108+
variant="h6"
109+
style={{
110+
marginTop: '0.3rem',
111+
marginLeft: '0.5rem',
112+
color: 'silver'
113+
}}
114+
className={classes.title}
115+
>
99116
ReacType
100117
</Typography>
101-
</Link>
102-
<div style ={ { marginLeft: '0.5rem', textDecoration: 'none' } }>
118+
</Link>
119+
<div style={{ marginLeft: '0.5rem', textDecoration: 'none' }}>
103120
<Button
104-
variant='contained'
105-
color='primary'
106-
onClick={handleClick}
107-
className='navbarButton'
108-
id='navbarButton'
109-
endIcon={<SortIcon/>}
110-
>
111-
SORT PROJECT
112-
</Button>
113-
<StyledMenu // Dropdown menu connected to Manage Project Button
114-
id='customized-menus'
115-
anchorEl={anchorEl}
116-
keepMounted
117-
open={Boolean(anchorEl)}
118-
onClose={handleClose}
119-
>
120-
{sortMethods.map((option, index) => (
121-
<StyledMenuItem onClick={() => {
122-
props.optionClicked(option);
123-
toggling();
124-
handleClose();
125-
}}
126-
variant='contained'
127-
color='primary'
128-
style={{ minWidth: '137.69px' }}
129-
className={classes.manageProject}
130-
key={index}
131-
>
132-
<Button
133-
color='primary'
134-
endIcon={(option === 'RATING') ? <StarBorderIcon/> : (option === 'DATE') ? <EventNoteIcon/> : (option === 'USER') ? <PersonIcon/> : ''}
135-
>
136-
{option}
137-
</Button>
138-
</StyledMenuItem>
139-
))}
140-
</StyledMenu>
141-
</div>
142-
<Button
143-
className='navbarButton'
144-
id='navbarDashButton'
145-
color='primary'
146-
variant='contained'
147-
style={{minWidth: '113.97px'}}
148-
endIcon={props.isThemeLight ? <Brightness3Icon/> : <Brightness5Icon/>}
121+
variant="contained"
122+
color="primary"
123+
onClick={handleClick}
124+
className="navbarButton"
125+
id="navbarButton"
126+
endIcon={<SortIcon />}
127+
>
128+
SORT PROJECT
129+
</Button>
130+
<StyledMenu // Dropdown menu connected to Manage Project Button
131+
id="customized-menus"
132+
anchorEl={anchorEl}
133+
keepMounted
134+
open={Boolean(anchorEl)}
135+
onClose={handleClose}
136+
>
137+
{sortMethods.map((option, index) => (
138+
<StyledMenuItem
139+
onClick={() => {
140+
props.optionClicked(option);
141+
toggling();
142+
handleClose();
143+
}}
144+
variant="contained"
145+
color="primary"
146+
style={{ minWidth: '137.69px' }}
147+
className={classes.manageProject}
148+
key={index}
149+
>
150+
<Button
151+
color="primary"
152+
endIcon={
153+
option === 'RATING' ? (
154+
<StarBorderIcon />
155+
) : option === 'DATE' ? (
156+
<EventNoteIcon />
157+
) : option === 'USER' ? (
158+
<PersonIcon />
159+
) : (
160+
''
161+
)
162+
}
163+
>
164+
{option}
165+
</Button>
166+
</StyledMenuItem>
167+
))}
168+
</StyledMenu>
169+
</div>
170+
<Button
171+
className="navbarButton"
172+
id="navbarDashButton"
173+
color="primary"
174+
variant="contained"
175+
style={{ minWidth: '113.97px' }}
176+
endIcon={
177+
props.isThemeLight ? <Brightness3Icon /> : <Brightness5Icon />
178+
}
149179
onClick={() => {
150180
!style.backgroundColor
151181
? dispatch(setStyle({ backgroundColor: '#21262D' })) //dark mode color
152-
: dispatch(setStyle( null ))
182+
: dispatch(setStyle(null));
153183
props.isThemeLight ? props.setTheme(false) : props.setTheme(true);
154184
}}
155185
>
156186
{props.isThemeLight ? 'Dark Mode' : 'Light Mode'}
157-
</Button>
187+
</Button>
158188
<div>
159-
<Link to='/' style={{textDecoration: 'none'}}>
189+
<Link to="/" style={{ textDecoration: 'none' }}>
160190
<Button
161-
variant='contained'
162-
color='primary'
163-
style={{ minWidth: '137.69px'}}
191+
variant="contained"
192+
color="primary"
193+
style={{ minWidth: '137.69px' }}
164194
className="navbarButton"
165195
id="ratingButton"
166-
endIcon={<HomeIcon/>}
167-
>
196+
endIcon={<HomeIcon />}
197+
>
168198
HOME
169199
</Button>
170200
</Link>

0 commit comments

Comments
 (0)