Test Specification - VikRic/MealPlanner GitHub Wiki

Objective

The objective of this test plan is to ensure the functionality, reliability, and correctness of the application's core features by using a combination of automated unit tests and manual UI tests.

  • Backend logic for recipes (create, fetch, format, and build query)
  • Frontend UI interactions for login, registration, recipe search, and calendar integration
  • Integration with external recipe API

Time plan

Task Estimated Actual
Manual TC 1h
Unit tests 5m
Running manualtests 5m
Code inspection 1h
Test report 1h

Test Environment

Component Tool/Setup
Unit tests Node.js + Jest
Frontend UI Manual testing in web browser
Mocking jest.mock(), fake models
API mocking Mocked fetch() in unit tests

Test Strategy

Automatic Testing

Automated tests are written in JavaScript using Jest. These are unit tests focused on individual functions and class methods in the backend.

Goals:

  • Ensure correct business logic (e.g., recipe formatting, query building)
  • Detect regressions early
  • Test edge cases (e.g., failed fetch, empty inputs)

Manual Testing

Manual tests are written as step-by-step UI scenarios for critical use cases such as registration, login, searching for recipes, and interacting with the calendar.

Goals:

  • Validate user-facing features
  • Check UI feedback and interactions
  • Simulate real-user behavior for core workflows

Automatic tests

1. Test: Create and save a new recipe

  • Test Description: Checks if a new recipe can be created and added to savedRecipes.
  • Class: RecipeController
  • Method: createRecipe
  • Verifies:
    • save() is called on the mocked model.
    • One recipe is returned in the result.
    • The returned recipe has the correct title.

2. Test: Fetch recipes from API (success case)

  • Test Description: Simulates a successful fetch() call to an external recipe API.
  • Class: RecipeController
  • Method: fetchRecipesFromAPI
  • Verifies:
    • Returned data matches expected API format.

3. Test: Fetch recipes from API (failure case)

  • Test Description: Simulates a failed fetch() call (e.g., ok: false).
  • Class: RecipeController
  • Method: fetchRecipesFromAPI
  • Verifies:
    • Method returns null when fetch fails.

4. Test: Build MongoDB query (full parameters)

  • Test Description: Constructs a MongoDB aggregation pipeline with all input parameters.
  • Class: RecipeController
  • Method: buildQuery
  • Verifies:
    • Output is a proper $match and $sample MongoDB query array matching all filters.

5. Test: Build MongoDB query (partial parameters)

  • Test Description: Constructs query with some empty parameters (e.g., no diet or time).
  • Class: RecipeController
  • Method: buildQuery
  • Verifies:
    • Empty parameters produce empty $match clauses.

6. Test: Build MongoDB query (empty parameters)

  • Test Description: Constructs query when all filters are empty.
  • Class: RecipeController
  • Method: buildQuery
  • Verifies:
    • All $match stages are empty except for final $sample.

7. Test: Format ingredients (normal input)

  • Test Description: Formats a list of ingredients from API data to expected internal format.
  • Class: RecipeController
  • Method: formatIngredients
  • Verifies:
    • Returns an array of objects with { amount, name, unit }.

8. Test: Format ingredients (empty values)

  • Test Description: Checks behavior when the input is missing expected fields like unitShort.
  • Class: RecipeController
  • Method: formatIngredients
  • Verifies:
    • Returns an empty array when unit info is missing.

Manual Test-Cases

TC1.1 Register new user

Use case 01:

Scenario: Register a new user

Test steps

  • Start the app
  • In the top right corner, click login.
  • Click Sign Up.
  • Enter Username & Password and click on Continue
  • Should be redirected to frontpage.

Expected

  • The system should show that the user is logged in. It will be an icon in the topright corner instead of login text."

TC1.2 Login user

Use case 02:

Scenario: Login with username & password

Test steps

  • Start the app
  • In the top right corner, click login.
  • Enter Username & click on Continue
  • Enter Password & click on Continue
  • Should be redirected to frontpage.

Expected

  • The system should show that the user is logged in. It will be an icon in the topright corner instead of login text."

TC2.1 Get data from API on frontend successful

Use case 03:

Scenario: Get data from API on frontend successful

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Most left input field shows "How many meals"
  • Enter a digit and check one of the checkboxes. Press the button 'Get recipe'

Expected

  • The system should send back data with 1 random recipe"

TC2.2 Enter empty digit force reprompt

Use case: 03:

Scenario: Leave "How many meals" field empty.

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Most left input field shows "How many meals"
  • Press the button "Get recipe"

Expected

  • The system should show the text "Please enter the number of recipes you'd like ."

TC2.3 Pick a time limit in the ETA dropdown

Use case: 04:

Scenario: Get a specific recipe

Test steps

  • Start the app
  • On the navbar - click Recipe
  • In the dropdown called Estimated total time. Pick any of the available options.
  • Check one of the checkboxes.
  • Press the button "Get recipe"

Expected

  • The app should show a recipe that corresponds with that time limit..

TC2.4 Pick a restriction in the restriction dropdown

Use case: 05:

Scenario: Get a specific recipe

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Check one of the checkboxes.
  • In the dropdown that shows "Choose restriction". Pick any of the available restrictions
  • Press the button "Get recipe"

Expected

  • The app should show a recipe that corresponds with that allergy.

TC2.5 Choose a cuisine in the cuisine combobox

Use case: 06:

Scenario: Get a specific recipe

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Check one of the checkboxes.
  • In the field Cuisine, enter a cuisine such as (Asian, Chinese or Italian)"
  • Press the button "Get recipe"

Expected

  • The app should show a recipe that corresponds with that cuisine.

TC2.6 Search recipe by ingredient

Use case: 09:

Scenario: Search recipe via ingredients

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Fill in data according to previous tests. This time in the "Search for ingredient in recipe" field. Enter "bean"

Expected

  • All recipes that show up should have bean as an ingredient.

TC3.1 Show a calendar

Use case: 07:

Scenario: Show a calendar

Test steps

  • Start the app
  • On the navbar - click Recipe
  • A calendar should be shown with recipes or without depending if you've added any.

Expected

  • The app should show a calendar with recipes if you've added any. Otherwise it will show an empty calendar.

TC3.2 Add recipe to calendar

Use case: 08:

Scenario: Add recipe to calendar

Test steps

  • Start the app
  • On the navbar - click Recipe
  • Fill in data according to previous tests.
  • A calendar should be shown with recipes or without depending if you've added any.
  • On any of the recipe cards that show up. Click the blue button with the text "Add".

Expected

  • The app should show a alert in the top of the screen with the text Recipe added.

TC4.1 Show ingredientlist

Use case: 08:

Scenario: Show ingredientlist

Test steps

  • Start the app
  • On the navbar - click Recipe
  • On the right side of the screen you have weekly ingredients. That should update when you add or remove a recipe.

Expected

  • The ingredient list should show an updated list of all ingredients.