Skip to content

Commit

Permalink
Add and test new feature
Browse files Browse the repository at this point in the history
Now it's possible to configure high-protein vegan meals.
  • Loading branch information
wlsf82 committed Dec 5, 2023
1 parent b6d1375 commit 6974811
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 22 deletions.
56 changes: 56 additions & 0 deletions cypress/e2e/mealSuggestion.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,60 @@ describe('Meal suggestion', () => {
cy.step('Render heading centralized on mobile viewport')
cy.get('@heading').should('have.css', 'text-align', 'center')
})

it('filters by a "high-protein" meal', () => {
cy.get('@filterSelectField').select('Alto teor de proteína')

cy.step('Assert high-protein meal is visible')
cy.get('@mealName')
.should('be.visible')
.and('contain', 'com alto teor de proteína')
cy.get('@ingredientsLabel').should('be.visible')
cy.get('@ingredients')
.should('be.visible')
.its('length')
.should('be.at.least', 1)
})

it('filters and searches by a "high-protein" meal', () => {
cy.get('@filterSelectField').select('Alto teor de proteína')
cy.get('@searchField')
.type('Sopa de lentilha{enter}')
cy.get('@searchField')
.blur()

cy.step('Assert that specifc high-protein meal is shown')
cy.get('@mealName')
.should('be.visible')
.and('contain', 'Sopa de lentilha (sopa com alto teor de proteína)')
cy.get('@ingredientsLabel').should('be.visible')
cy.get('@ingredients')
.should('be.visible')
.and('contain', 'lentilha')
.and('contain', 'cenoura')
.and('contain', 'cebola')
.and('contain', 'alho')
.and('contain', 'tempero verde')
.its('length')
.should('equal', 5)
})

it('filters and searches for a high-protein meal (negative scenario)', () => {
cy.step('Filter by high-protei then search for a non-high-protein meal')
cy.get('@filterSelectField').select('Alto teor de proteína')
cy.get('@searchField')
.type('Nhoque{enter}')
cy.get('@searchField')
.blur()

cy.step('Assert that high-protein meal is still visible')
cy.get('@mealName')
.should('be.visible')
.and('contain', 'com alto teor de proteína')
cy.get('@ingredientsLabel').should('be.visible')
cy.get('@ingredients')
.should('be.visible')
.its('length')
.should('be.at.least', 1)
})
})
1 change: 1 addition & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1>Refeição vegana 🌱</h1>
<option value="soup">Sopas</option>
<option value="sandwich">Sanduíches</option>
<option value="hot">Pratos quentes</option>
<option value="high-protein">Alto teor de proteína</option>
</select>
</div>
<div id="search-container">
Expand Down
63 changes: 42 additions & 21 deletions src/meals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@ const meals = [
{
name: 'Feijoada',
ingredients: ['feijão vermelho', 'abobrinha', 'cenoura', 'cebola', 'alho', 'couve', 'laranja'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Escondidinho',
ingredients: ['batata ou aipim', 'picado carnal', 'molho de tomate', 'cebola', 'alho'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Arroz exótico',
ingredients: ['arroz', 'tofu', 'brócolis', 'ervilha', 'cenoura'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'À la minuta',
ingredients: ['batata frita', 'arroz', 'proteína', 'feijão'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Almondegas com arroz',
ingredients: ['almondegas', 'molho de tomate', 'arroz',],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Lasanha de berinjela',
Expand All @@ -38,22 +43,26 @@ const meals = [
{
name: 'Massa à bolonhesa',
ingredients: ['lentilha', 'azeite', 'massa de espaguete', 'molho de tomate', 'cebola', 'alho'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Panqueca à bolonhesa',
ingredients: ['azeite', 'farinha de trigo', 'cenoura/beterraba/espinafre', 'leite vegetal', 'chia', 'cebola', 'alho', 'molho de tomate', 'picado carnal'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Chilly',
ingredients: ['picado carnal', 'feijão vermelho', 'molho de tomate', 'pimenta', 'milho', 'abacate', 'cebola', 'tomate', 'alho', 'pimentão', 'nachos'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Carreteiro',
ingredients: ['proteína', 'arroz', 'cebola', 'alho', 'molho de tomate', 'tempero verde'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Nhoque',
Expand All @@ -63,7 +72,8 @@ const meals = [
{
name: 'Strogonoff',
ingredients: ['proteína', 'champignon', 'arroz', 'cebola', 'alho', 'molho de tomate', 'creme vegetal', 'batata palha ou frita'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Galeto de frangos felizes',
Expand All @@ -73,27 +83,32 @@ const meals = [
{
name: 'Feijão tropeiro',
ingredients: ['feijão', 'farinha de mandioca', 'cenoura', 'couve', 'cebola', 'alho'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Arroz e feijão',
ingredients: ['arroz', 'feijão', 'cebola', 'alho'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Tofu e legumes ao shoyo com arroz',
ingredients: ['arroz', 'tofu', 'pimentão', 'cebola', 'cenoura', 'abobrinha', 'shoyo'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Almôndegas de seitan com arroz negro',
ingredients: ['almôndsgas de seitan', 'arroz negro', 'molho de tomate', 'ervilhas'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Pizza de picado carnal com milho',
ingredients: ['massa de pizza', 'picado carnal', 'milho enlatado', 'molho de tomate', 'orégano'],
type: 'hot'
type: 'hot',
highProtein: true
},
{
name: 'Pizza de brócolis com milho',
Expand All @@ -118,7 +133,8 @@ const meals = [
{
name: 'Saladão',
ingredients: ['folhas verdes', 'tomate', 'azeitonas', 'milho', 'proteína (ex.: Heura)', 'crutons', 'pimenta'],
type: 'salad'
type: 'salad',
highProtein: true
},
{
name: 'Salada de quinoa e pistaches',
Expand Down Expand Up @@ -158,7 +174,8 @@ const meals = [
{
name: 'Minestrone',
ingredients: ['massa para sopa', 'feijão', 'ervilha', 'cenoura', 'molho de tomate'],
type: 'soup'
type: 'soup',
highProtein: true
},
{
name: 'Sopa de batata doce cremosa',
Expand All @@ -183,7 +200,8 @@ const meals = [
{
name: 'Sopa de lentilha',
ingredients: ['lentilha', 'cenoura', 'cebola', 'alho', 'tempero verde'],
type: 'soup'
type: 'soup',
highProtein: true
},
{
name: 'Sopa cremosa de brócolis',
Expand Down Expand Up @@ -213,7 +231,8 @@ const meals = [
{
name: 'Sanduíche de milanesa de seitan',
ingredients: ['maionese ou humus', 'pão integral', 'bife à milanesa de seitan', 'tomate', 'alface'],
type: 'sandwich'
type: 'sandwich',
highProtein: true
},
{
name: 'Xis Macaco',
Expand All @@ -223,12 +242,14 @@ const meals = [
{
name: 'Subway',
ingredients: ['maionese ou humus', 'baguete', 'tomate', 'alface', 'cebola roxa', 'Heura'],
type: 'sandwich'
type: 'sandwich',
highProtein: true
},
{
name: 'Hamburger',
ingredients: ['maionese ou humus', 'pão de hamburger', 'tomate', 'alface', 'proteína'],
type: 'sandwich'
type: 'sandwich',
highProtein: true
},
{
name: 'Cachorro quente',
Expand Down
6 changes: 5 additions & 1 deletion src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ mealTypeFilter.addEventListener('change', e => {
// eslint-disable-next-line no-undef
filteredMeals = [...meals]
generateMeal()
} else if (selectedType === 'high-protein') {
// eslint-disable-next-line no-undef
filteredMeals = meals.filter(meal => meal.highProtein)
generateMeal()
} else {
// eslint-disable-next-line no-undef
filteredMeals = meals.filter(meal => meal.type === selectedType)
Expand Down Expand Up @@ -54,7 +58,7 @@ function generateMeal() {
}

function showMealName(meal) {
mealName.innerHTML = `Refeição: ${meal.name} (${mealEnum[meal.type]})`
mealName.innerHTML = `Refeição: ${meal.name} (${mealEnum[meal.type]}${meal.highProtein ? ' com alto teor de proteína' : ''})`
}

function showIngredients(ingredients) {
Expand Down

0 comments on commit 6974811

Please sign in to comment.