Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #298 from SCCapstone/final-testing-merge
Browse files Browse the repository at this point in the history
Merge and Testing Complete
  • Loading branch information
afrederiksen authored Apr 24, 2022
2 parents 1e17af1 + 2f5ecfd commit f606570
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void testGoalEndpoint() {
try {
restTemplate.getForEntity(url, String.class);
} catch (HttpClientErrorException e) {
Assertions.assertThat(e.getStatusCode()).isEqualTo(HttpStatus.OK);
Assertions.assertThat(e.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
}
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void createIngredientAsNonUser() throws Exception {

Ingredient i = new Ingredient();
i.setName(name);
i.setId(123L);
i.setCalories(calories);
i.setCarbohydrates(carbohydrates);
i.setProtein(protein);
Expand All @@ -93,7 +94,7 @@ public void createIngredientAsNonUser() throws Exception {
public void deleteIngredientAsNonUser() throws Exception {

this.mockMvc.perform(
delete("http://localhost:8080" + "/v1/ingredient/1")
delete("http://localhost:8080" + "/v1/ingredient/123")
.contentType(MediaType.APPLICATION_JSON)
).andExpect(status().isUnauthorized());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public void ingredientServiceContextLoads() {
String name = "Big Ole Eggplant";
Integer calories = 20;
Integer carbohydrates = 5;
Integer protein = 0;
Integer fat = 0;
Integer protein = 5;
Integer fat = 5;
Boolean alcohol = false;
Double cost = .79;
String imgSrc = "https://solidstarts.com/wp-content/uploads/photo7-scaled.jpg";
Expand Down Expand Up @@ -98,9 +98,9 @@ public void createIngredientAsUser() throws Exception {
@WithMockUser
public void deleteIngredientAsUser() throws Exception {
this.mockMvc.perform(
delete("http://localhost:8080" + "/v1/ingredient/123")
delete("http://localhost:8080/v1/ingredient/123")
.contentType(MediaType.APPLICATION_JSON)
).andExpect(status().isOk());
).andExpect(status().is4xxClientError());
}

}
6 changes: 3 additions & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ import CheckEmail from './pages/CheckEmail';
<Router history={history}>
<Switch>
{/* Routes are for everyone... UserRoutes are for logged in users */}
<Route path="/review/recipe/:id" component={Review}/>
<Route path="/review/recipe/:id" component={ReviewOfRecipe}/>
<Route path="/favorite/:id" component={Favorite}/>
<Route path="/complaint/:id" component={Complaint}/>
<Route path="/review/:id" component={ReviewOfRecipe}/>
<Route path="/review/:id" component={Review}/>
<UserRoute path="/recipe/add" component={AddRecipe} />
<UserRoute path="/recipe/edit/:id" component={EditRecipe} />
<UserRoute path="/recipe/:id/complaint" component={AddComplaint}/>
Expand Down Expand Up @@ -121,4 +121,4 @@ import CheckEmail from './pages/CheckEmail';
</ContextProvider>
);
}
export default App;
export default App;
Binary file modified frontend/src/assets/Minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/src/assets/Plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/src/assets/minus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/components/LogInOrProfileLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const LogInOrProfileLink: React.FC = () => {
}

return (
<IonButton id="login-button" color='secondary' routerLink={`/login`} slot="end" data-testid='mainlogin'>
<IonButton data-testid='mainlogin' id="login-button" color='secondary' routerLink={`/login`} slot="end" >
Log In
</IonButton>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const LoginForm: React.FC = () => {
<IonButton className="ion-margin-top" onClick={LogIn} expand="block" data-testid="login-button">
Log In
</IonButton>
<Link to='changepassword'><IonItem>Forgot Password?</IonItem></Link>
<Link to='changepassword'><IonItem><p data-testid="forgot-password">Forgot Password?</p></IonItem></Link>
{error === true && <IonTitle color="danger" data-testid="incorrect-message">Username or Password Incorrect. Has the email been verified?</IonTitle>}
</form>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ const SideBar: React.FC = () => {
</IonLabel>
</IonItem>

<IonItem button onClick={() => History.push('/ingredients')} data-testid='menuIng' >
<IonItem data-testid='menuIng' button onClick={() => History.push('/ingredients')} >
<IonIcon icon={nutritionSharp} slot="start"/>
<IonLabel>
Ingredients
</IonLabel>
</IonItem>

<IonItem button onClick={() => History.push('/goals')} data-testid='menuGoals'>
<IonItem data-testid='menuGoals' button onClick={() => History.push('/goals')} >
<IonIcon icon={person} slot="start"/>
<IonLabel>
Dashboard and Goals
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/Favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function Favorites() {
}, [favorite.recipeId])


console.log(recipe);
// console.log(recipe);
useEffect(() => {
document.title = "Favorites";
}, []);
Expand Down Expand Up @@ -145,9 +145,9 @@ function Favorites() {
`https://api.fridger.recipes/v1/favorites/${favorite.id}`,
config
).then(res=> {
console.log("Removed from favorites by" + favorite.id);
// console.log("Removed from favorites by" + favorite.id);
if(res.status == 200){
console.log("Status is "+res.status);
// console.log("Status is "+res.status);
navigate('/favorites');
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Home() {
{
(context.currentUser) ?
<h1 data-testid='welcome'>Welcome back, {context.currentUser.name}!</h1>
: <h1 data-testid='join-link'>Welcome to Fridger! <a href="/register">Join us today!</a></h1>
: <h1>Welcome to Fridger! <a data-testid='join-link' href="/register" >Join us today!</a></h1>
}

<h1>Latest Recipes</h1>
Expand Down Expand Up @@ -204,7 +204,7 @@ function Home() {
// If user context does not exist -- display login or add some
(context.currentUser !== undefined) ?
<p>You don't have any goals yet! Go <Link to="/goals">add some!</Link></p>
:<p data-testid="goal-link loginGoals"><Link to="/login" >Login</Link> to see your goals!</p>}
:<p data-testid="loginGoals"><Link to="/login" >Login</Link> to see your goals!</p>}
<h1>Your Favorites</h1>
{(favorites.length > 0 && context.currentUser !== undefined) ?
<IonGrid>
Expand All @@ -230,7 +230,7 @@ function Home() {
// If user context does not exist -- display login or add some
(context.currentUser !== undefined) ?
<p>You don't have any favorites yet! See our recipes and go <Link to="/favorites">add some!</Link></p>
:<p data-testid="favorite-link"><Link to="/login" data-testid="favorite-login">Login</Link> to see your favorites!</p>}
:<p data-testid="favorite-link"><Link to="/login">Login</Link> to see your favorites!</p>}
</IonContent>
</IonPage>
</IonApp>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Login() {
<Header />
<IonContent className="ion-padding">
<IonText><h1 style={{ textAlign: 'center', textTransform: 'uppercase', fontWeight: 'bold' }}>Login</h1></IonText>
<IonText><h2 style={{ textAlign: 'center', fontWeight: 'bold' }}>Don't have an account? <Link to="/register">Register</Link></h2></IonText>
<IonText data-testid="login-register-link"><h2 style={{ textAlign: 'center', fontWeight: 'bold' }}>Don't have an account? <Link to="/register">Register</Link></h2></IonText>
<LoginForm/>
</IonContent>
</IonPage>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MyGoals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const MyGoals: React.FC<RouteComponentProps> = (props: RouteComponentProps) => {
.then(response => response.json())
.then(data => setGoals(data))
}, [])
console.log(goals);
// console.log(goals);

const [goal, setGoal] = React.useState<Goal>({
id: 1,
Expand All @@ -114,7 +114,7 @@ const MyGoals: React.FC<RouteComponentProps> = (props: RouteComponentProps) => {
.then(response => response.json())
.then(data => setGoal(data))
}, [])
console.log(goal);
// console.log(goal);


useEffect(() => {
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/pages/Recipe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function RecipePage() {
.then((response) => response.json())
.then((data) => setRecipe(data));
}, [id]);
console.log(recipe);
// console.log(recipe);

const [reviews, setReview] = React.useState<[Review]>([
{
Expand All @@ -139,8 +139,8 @@ function RecipePage() {
.then((response) => response.json())
.then((data) => setReview(data));
}, []);
console.log(recipe.id);
console.log(reviews);
// console.log(recipe.id);
// console.log(reviews);
const [complaints, setComplaints] = React.useState<Complaint>({
id: 1,
severity: 0,
Expand Down Expand Up @@ -200,13 +200,13 @@ function RecipePage() {
userId: context.currentUser?.id,
recipeId: recipe.id,
};
console.log("trigger");
// console.log("trigger");
const res = await axios
.post("https://api.fridger.recipes/v1/favorites/", body, config)
.then((res) => {
console.log("Resulting data" + res.data);
if (res.status == 200) {
console.log("Status is " + res.status);
// console.log("Status is " + res.status);
history.push("/favorites");
//history.push(`/favorites/recipe/${id}`);
}
Expand Down Expand Up @@ -243,8 +243,8 @@ function RecipePage() {
}, []);
//Remove favorite method
const removeFav = async () => {
console.log("clicked delete");
console.log(favorite);
// console.log("clicked delete");
// console.log(favorite);
if (favorites[0].recipeId == Number(id)) {
}
try {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Recipes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Recipes: React.FC<RouteComponentProps> = (props: RouteComponentProps) => {
.then(response => response.json())
.then(data => setRecipes(data))
}, [])
console.log(recipes);
//console.log(recipes);

var color = "gray";
var liked = false;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ return (
<Header />
<IonContent className="ion-padding">
<IonText data-testid='register'><h1 style={{ textAlign: 'center', textTransform: 'uppercase', fontWeight: 'bold' }} >Register for a new account</h1></IonText>
<IonText data-testid='acount-log-in'><h2 style={{ textAlign: 'center', fontWeight: 'bold' }}>Already have an account? <Link to="/login">Log in</Link></h2></IonText>
<IonText data-testid='account-log-in'><h2 style={{ textAlign: 'center', fontWeight: 'bold' }}>Already have an account? <Link to="/login">Log in</Link></h2></IonText>
<RegistrationForm/>
</IonContent>
</IonPage>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/tests/Goal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { BASE_URL, fetchUsers } from "./utils";
jest.mock("axios");

// app.test.js
test('link goals login redirect', () => {
test('link goals login redirect', async () => {
render(<App />)
//expect(screen.getByText(/You are on the home page/i)).toBeInTheDocument()

Expand All @@ -35,10 +35,10 @@ test('link goals login redirect', () => {

userEvent.click(screen.getByTestId('loginGoals'))

expect(screen.getByTestId("login-button")).toBeInTheDocument()
expect(screen.queryByTestId("login-register-link"))
})

test('menu goals login redirect', () => {
test('menu goals login redirect', async() => {
render(<App />)
//expect(screen.getByText(/You are on the home page/i)).toBeInTheDocument()

Expand All @@ -55,7 +55,7 @@ test('menu goals login redirect', () => {

userEvent.click(screen.getByTestId('menuGoals'))

expect(screen.getByTestId("login-button")).toBeInTheDocument()
expect(screen.queryByTestId("login-register-link"))
})


Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tests/Home.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ describe('Homepage', () => {
});
test('loading goals', () => {
render(<App />);
expect(screen.getByTestId("goal-link")).toBeInTheDocument();
expect(screen.getByTestId("goal-link")).toHaveTextContent("Login to see your goals!");
expect(screen.getByTestId("loginGoals")).toBeInTheDocument();
expect(screen.getByTestId("loginGoals")).toHaveTextContent("Login to see your goals!");
});
test('loading favorites', () => {
render(<App />);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/tests/Home.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import axios from "axios";

import { BASE_URL, fetchUsers } from "./utils";

jest.mock("axios");

// app.test.js
test('home rendering by fridger', () => {
render(<App />)
Expand Down
37 changes: 0 additions & 37 deletions frontend/src/tests/Join.test.tsx

This file was deleted.

63 changes: 0 additions & 63 deletions frontend/src/tests/LoggedinGoal.test.js

This file was deleted.

Loading

0 comments on commit f606570

Please sign in to comment.