Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image to recipe #46

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
24bc60a
Added landing page with Get Started button
anurgj Oct 24, 2024
6c3a53b
Replace existing .env with sample.env file
Oct 25, 2024
9cc4344
Merge pull request #10 from SE-Fall24-RZA/dotenv-fix
robbiethomas1101 Oct 25, 2024
ae58525
Added function to rate existing recipes in database
Oct 26, 2024
aec0859
Tests now use correct cluster
Oct 26, 2024
7220766
Created api route for rating existing recipes
Oct 26, 2024
c010e88
added unit test for new rating system
Oct 26, 2024
70fa6e6
Replaced displayed numeric rating with star ratings
Oct 26, 2024
714525d
Added button to rate existing recipes from frontend
Oct 26, 2024
bc1924d
Merge pull request #15 from SE-Fall24-RZA/rating-system
robbiethomas1101 Oct 26, 2024
8bc6070
Added initialization for test data prior to tests being run
Oct 26, 2024
7f41146
Merge pull request #16 from SE-Fall24-RZA/test-improvements
robbiethomas1101 Oct 26, 2024
da03335
Created API route to add a recipe to the meal plan
Oct 27, 2024
abb89e0
Created API route to get the meal plan for a user
Oct 27, 2024
dc85e7d
Made UI Changes, need to fix Remove Bookmark
anurgj Oct 27, 2024
ffdfd66
Fixed errors with removing and adding bookmarks
Oct 28, 2024
f171481
Test for removing recipe from meal plan
Oct 28, 2024
147daa6
Merge branch 'group31-fall24' into meal-plan
robbiethomas1101 Oct 28, 2024
6cb7f7b
Merge pull request #18 from SE-Fall24-RZA/meal-plan
robbiethomas1101 Oct 28, 2024
6270d38
Fixed error from resolving merge conflict
Oct 28, 2024
f8d9814
Updated Login/Signup forms
anurgj Oct 28, 2024
f871ecd
Updated getMealPlan to return full recipes instead of just ids
Oct 29, 2024
8e34c41
Created basic meal plan ui page
Oct 29, 2024
3b425fc
Merge pull request #19 from SE-Fall24-RZA/new-login-form
anurgj Oct 29, 2024
28243cd
Refined meal plan UI page
Oct 29, 2024
f5d59a2
Added ability to add/remove recipes from meal plan on frontend
Oct 29, 2024
ef1e40e
Merge branch 'group31-fall24' into meal-plan-ui
robbiethomas1101 Oct 29, 2024
91d9c8f
Updated AddRecipe.js to accomodate uploading image
siddiquizayaan Oct 29, 2024
b566679
Merge pull request #20 from SE-Fall24-RZA/meal-plan-ui
robbiethomas1101 Oct 29, 2024
6f79c40
Added workflow to run backend tests on push
Oct 29, 2024
3e3830b
Modifications to jest environment for workflow
Oct 29, 2024
50a5f01
Update testing workflow
Oct 29, 2024
a98956a
Added babel to support jest testing
Oct 29, 2024
4b1095f
Adjustments to babel config
Oct 29, 2024
a027d6c
More babel adjustments
Oct 29, 2024
8c3be27
Adjustments to setup for tests
Oct 29, 2024
37b2bad
Adjustments to input data in test setup
Oct 29, 2024
73df3e4
Cleaned up testing workflow and testing seup
Oct 29, 2024
401df41
Configured tests to run on PR opening, and stopped old coverage workflow
Oct 29, 2024
9dcec0a
Merge pull request #21 from SE-Fall24-RZA/testing-workflows
robbiethomas1101 Oct 29, 2024
54cd524
Fixed bug making meal plan disappear
Oct 31, 2024
cbd12d9
Merge pull request #25 from SE-Fall24-RZA/meal-plan-bug
robbiethomas1101 Oct 31, 2024
71a6b9a
Enabled code coverage for backend tests
Oct 31, 2024
2afc18e
Added more tests for user api routes
Oct 31, 2024
e7a43e8
Added more bookmarks tests
Oct 31, 2024
e4089e0
Added more recipes backend tests
Oct 31, 2024
731ce5c
Added remove bookmark tests
Oct 31, 2024
6eddaf6
Added test for ingredient list
Oct 31, 2024
5bee88b
Updated existing backendTests workflow
Oct 31, 2024
5f7f101
Added a workflow to run the tests and collect coverage information
Oct 31, 2024
0dee34b
Removed unneeded console.log calls to reduce terminal clutter
Oct 31, 2024
d155eda
Merge pull request #29 from SE-Fall24-RZA/backend-testing
robbiethomas1101 Oct 31, 2024
0074123
Update AddRecipe.js accepting both image url/upload
siddiquizayaan Oct 31, 2024
c6fc007
Trying to integrate with backend
siddiquizayaan Oct 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/backendCoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Running Backend Tests With Coverage

on:
pull_request:
branches:
- group31-fall24
- master

jobs:
run_backend_tests_Coverage:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
cd Code/backend
touch .env
echo RECIPES_DB_URI=${{ secrets.TESTING_DB_URI }} >> .env
echo RECIPES_NS=${{ secrets.DB_NAME }} >> .env
echo PORT=${{ secrets.API_PORT }} >> .env
echo GMAIL=${{ secrets.GMAIL }} >> .env
npm install
- name: Run backend tests with coverage
run: |
cd Code/backend
npm run test-cov
33 changes: 33 additions & 0 deletions .github/workflows/backendTests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Running Backend Tests

on: push

jobs:
run_backend_tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
cd Code/backend
touch .env
echo RECIPES_DB_URI=${{ secrets.TESTING_DB_URI }} >> .env
echo RECIPES_NS=${{ secrets.DB_NAME }} >> .env
echo PORT=${{ secrets.API_PORT }} >> .env
echo GMAIL=${{ secrets.GMAIL }} >> .env
npm install
- name: Run backend tests
run: |
cd Code/backend
npm test

2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Running Code Coverage

on: [push, pull_request]
on: workflow_dispatch

jobs:
build:
Expand Down
12 changes: 12 additions & 0 deletions Code/backend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
4 changes: 0 additions & 4 deletions Code/backend/.env

This file was deleted.

9 changes: 6 additions & 3 deletions Code/backend/__tests__/test.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const mongodb = require("mongodb");
//const mongodb = require("mongodb");
import { TextEncoder, TextDecoder } from 'util';
Object.assign(global, { TextDecoder, TextEncoder });
import * as mongodb from "mongodb"
const MongoClient = mongodb.MongoClient;
// const request = require("supertest")(httplocalhost5000apiv1);
const expect = require("chai").expect;
//import expect from "chai"
// var util= require('util');
// var encoder = new util.TextEncoder('utf-8');
//
Expand All @@ -23,8 +27,7 @@ function test_connectivity_func() {
// Connection URI. Update username, password, and your-cluster-url to reflect your cluster.
// See httpsdocs.mongodb.comecosystemdriversnode for more details

const uri =
"mongodb+srv://atharvajoshi067:[email protected]/recipe_recommender?retryWrites=true&w=majority";
const uri = process.env.RECIPES_DB_URI;
var result = false;
try {
// Connect to the MongoDB cluster
Expand Down
39 changes: 26 additions & 13 deletions Code/backend/__tests__/test1.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,80 @@
const request = require("supertest")("http://localhost:5000/api/v1");
import app from "../server";
const baseURL = "/api/v1";

const request = require("supertest");
const expect = require("chai").expect;

describe("GET /recipes", function () {
it("is the API is functional test 1", async function () {
const response = await request.get("/recipes?CleanedIngredients=coconut");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=coconut");

expect(response.status).to.eql(200);
});

it("is the API is functional test 2", async function () {
const response = await request.get("/recipes?CleanedIngredients=COCONUT");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=COCONUT");

expect(response.status).to.eql(200);
});

it("is the API is functional test 3", async function () {
const response = await request.get("/recipes?CleanedIngredients=mango");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=mango");

expect(response.status).to.eql(200);
});

it("is the API is functional test 4", async function () {
const response = await request.get("/recipes?CleanedIngredients=MANGO");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=MANGO");

expect(response.status).to.eql(200);
});

it("is the API is functional test 5", async function () {
const response = await request.get("/recipes?CleanedIngredients=Mango");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=Mango");

expect(response.status).to.eql(200);
});

it("is the API is functional test 6", async function () {
const response = await request.get("/recipes?CleanedIngredients=mANGO");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=mANGO");

expect(response.status).to.eql(200);
});

it("is the API is functional test 7", async function () {
const response = await request.get(
"/recipes?CleanedIngredients={mango, salt}"
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(
baseURL + "/recipes?CleanedIngredients={mango, salt}"
);

expect(response.status).to.eql(200);
});

it("is the API is functional test 8", async function () {
const response = await request.get(
"/recipes?CleanedIngredients={salt, mango}"
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(
baseURL + "/recipes?CleanedIngredients={salt, mango}"
);

expect(response.status).to.eql(200);
});

it("is the API is functional test 8", async function () {
const response = await request.get("/recipes?CleanedIngredients={}");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients={}");

expect(response.status).to.eql(200);
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=pear");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=pear");

expect(response.body.filters.CleanedIngredients).to.eql("pear");
});
Expand Down
32 changes: 22 additions & 10 deletions Code/backend/__tests__/test2.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,69 @@
const request = require("supertest")("http://localhost:5000/api/v1");
import app from "../server";
const baseURL = "/api/v1";

const request = require("supertest");
const expect = require("chai").expect;

describe("GET /recipes", function () {
it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=pear");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=pear");

expect(response.body.filters.CleanedIngredients).to.eql("pear");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=peach");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=peach");

expect(response.body.filters.CleanedIngredients).to.eql("peach");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=salt");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=salt");

expect(response.body.filters.CleanedIngredients).to.eql("salt");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=sugar");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=sugar");

expect(response.body.filters.CleanedIngredients).to.eql("sugar");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=cheese");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=cheese");

expect(response.body.filters.CleanedIngredients).to.eql("cheese");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=lemon");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=lemon");

expect(response.body.filters.CleanedIngredients).to.eql("lemon");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=spinach");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=spinach");

expect(response.body.filters.CleanedIngredients).to.eql("spinach");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=apple");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=apple");

expect(response.body.filters.CleanedIngredients).to.eql("apple");
});

it("is the API is fetching the filtered ingredient", async function () {
const response = await request.get("/recipes?CleanedIngredients=tortillas");
await request(app).get(baseURL + "/recipes/initDB")
const response = await request(app).get(baseURL + "/recipes?CleanedIngredients=tortillas");

expect(response.body.filters.CleanedIngredients).to.eql("tortillas");
});
Expand Down
65 changes: 65 additions & 0 deletions Code/backend/__tests__/testAddRecipes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import app from "../server";
const baseURL = "/api/v1/recipes";

const request = require("supertest");
const expect = require("chai").expect;

describe("POST /addRecipes", function () {
it("Should add a recipe if all fields are provided", async function() {
await request(app).get(baseURL + "/initDB");
const recipe = {
recipeName: "Test_Recipe_1",
cookingTime: 20,
dietType: "Normal",
recipeRating: 3,
cuisine: "American",
imageURL: "",
recipeURL: "",
instructions: "1) Cook the food \n2) Eat the food",
ingredients: ["Meat", "Pasta", "Sauce"],
restaurants: ["Pasta House"],
locations: ["Raleigh"]
}
const response = await request(app).post(baseURL + "/addRecipe").send(recipe)
expect(response.status).to.equal(200)
const response2 = await request(app).get(
baseURL + "/getRecipeByName?recipeName=Test_Recipe_1"
);
expect(response2.status).to.equal(200)
expect(response2.text.includes("Test_Recipe_1")).true;
});
it("Should add a recipe if some fields are provided", async function() {
await request(app).get(baseURL + "/initDB");
const recipe = {
recipeName: "Test_Recipe_2",
cookingTime: 20,
recipeRating: 3,
cuisine: "American",
instructions: "1) Cook the food \n2) Eat the food",
ingredients: ["Meat", "Pasta", "Sauce"],
restaurants: [],
locations: []
}
const response = await request(app).post(baseURL + "/addRecipe").send(recipe)
expect(response.status).to.equal(200)
const response2 = await request(app).get(
baseURL + "/getRecipeByName?recipeName=Test_Recipe_2"
);
expect(response2.status).to.equal(200)
expect(response2.text.includes("Test_Recipe_2")).true;
});
it("Should not add a recipe if no name is provided", async function() {
await request(app).get(baseURL + "/initDB");
const recipe = {
cookingTime: 20,
recipeRating: 3,
cuisine: "American",
instructions: "1) Cook the food \n2) Eat the food",
ingredients: ["Meat", "Pasta", "Sauce"],
restaurants: [],
locations: []
}
const response = await request(app).post(baseURL + "/addRecipe").send(recipe)
expect(response.status).to.not.equal(200)
});
})
Loading