-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: edit base cocktails * fix * chore: added eslint rule * fix * fix * fix * chore: update version
- Loading branch information
1 parent
6ab5b80
commit e9590fc
Showing
29 changed files
with
571 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import { ValidateCocktailRequest, validateCocktail } from './validation-helpers/validate-cocktail'; | ||
|
||
describe('Edit Base Cocktails', () => { | ||
beforeEach(() => { | ||
window.localStorage.clear(); | ||
window.localStorage.setItem('CapacitorStorage.messuarement-system', 'Imperial'); | ||
}); | ||
|
||
it('Edit base cocktail with new values', () => { | ||
cy.visit('#/cocktails'); | ||
|
||
const cocktailId = '2'; | ||
cy.get(`#all-cocktails-${cocktailId}`).click(); | ||
|
||
validateCocktail({ | ||
name: 'Gin & Tonic', | ||
category: 'Cocktail', | ||
tags: [], | ||
abv: '9.38%', | ||
ingredients: [ | ||
{ name: 'Gin', amount: '1 1/3 fl oz' }, | ||
{ name: 'Tonic', amount: '4 fl oz' } | ||
], | ||
isEditedText: false | ||
}); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown-content').should('not.be.visible'); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown').click(); | ||
cy.dataCy('cocktail-dialog-dropdown-content').should('be.visible'); | ||
cy.dataCy('dropdown-edit-cocktail').click(); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown-content').should('not.be.visible'); | ||
|
||
cy.dataCy('cocktail-category-select').select('Other'); | ||
|
||
cy.dataCy('edit-tags').click(); | ||
|
||
cy.dataCy('tag-1').click(); | ||
cy.dataCy('edit-tags-drawer-close').click(); | ||
|
||
cy.dataCy(['ingredient-group-0', 'amount-input']).clear(); | ||
cy.dataCy(['ingredient-group-0', 'amount-input']).type('2'); | ||
cy.dataCy(['ingredient-group-0', 'amount-input']).blur(); | ||
|
||
cy.dataCy('save-cocktail').click(); | ||
|
||
const validateCocktailRequest: ValidateCocktailRequest = { | ||
name: 'Gin & Tonic', | ||
category: 'Other', | ||
tags: ['IBA'], | ||
ingredients: [ | ||
{ name: 'Gin', amount: '2 fl oz' }, | ||
{ name: 'Tonic', amount: '4 fl oz' } | ||
], | ||
abv: '12.5%', | ||
isEditedText: true | ||
}; | ||
|
||
validateCocktail(validateCocktailRequest); | ||
|
||
// Validate that when dialog is reopened, the latest values are still there | ||
cy.dataCy('close-dialog').click(); | ||
cy.get(`#all-cocktails-${cocktailId}`).click(); | ||
validateCocktail(validateCocktailRequest); | ||
}); | ||
|
||
it('Restore Cocktail', () => { | ||
window.localStorage.setItem( | ||
'CapacitorStorage.cocktail-information', | ||
JSON.stringify([ | ||
{ | ||
id: '2', | ||
category: 2, | ||
ingredientGroups: [ | ||
{ | ||
amount: '2', | ||
ingredientId: '6', | ||
unit: 'fl oz' | ||
}, | ||
{ | ||
amount: '4', | ||
ingredientId: '7', | ||
unit: 'fl oz' | ||
} | ||
], | ||
tags: ['1'] | ||
} | ||
]) | ||
); | ||
|
||
cy.visit('#/cocktails'); | ||
|
||
const cocktailId = '2'; | ||
cy.get(`#all-cocktails-${cocktailId}`).click(); | ||
|
||
validateCocktail({ | ||
name: 'Gin & Tonic', | ||
category: 'Other', | ||
tags: ['IBA'], | ||
ingredients: [ | ||
{ name: 'Gin', amount: '2 fl oz' }, | ||
{ name: 'Tonic', amount: '4 fl oz' } | ||
], | ||
abv: '12.5%', | ||
isEditedText: true | ||
}); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown-content').should('not.be.visible'); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown').click(); | ||
cy.dataCy('cocktail-dialog-dropdown-content').should('be.visible'); | ||
cy.dataCy('dropdown-restore-cocktail').click(); | ||
|
||
cy.dataCy('cocktail-dialog-dropdown-content').should('not.be.visible'); | ||
|
||
const validateCocktailRequest = { | ||
name: 'Gin & Tonic', | ||
category: 'Cocktail', | ||
tags: [], | ||
abv: '9.38%', | ||
ingredients: [ | ||
{ name: 'Gin', amount: '1 1/3 fl oz' }, | ||
{ name: 'Tonic', amount: '4 fl oz' } | ||
], | ||
isEditedText: false | ||
}; | ||
|
||
validateCocktail(validateCocktailRequest); | ||
|
||
// Validate that when dialog is reopened, the latest values are still there | ||
cy.dataCy('close-dialog').click(); | ||
cy.get(`#all-cocktails-${cocktailId}`).click(); | ||
validateCocktail(validateCocktailRequest); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export type ValidateCocktailRequest = { | ||
name: string; | ||
category: string; | ||
tags: string[]; | ||
abv: string; | ||
ingredients: { name: string; amount: string }[]; | ||
isEditedText: boolean; | ||
}; | ||
|
||
export function validateCocktail(cocktail: ValidateCocktailRequest) { | ||
const { name, category, isEditedText, tags, ingredients, abv } = cocktail; | ||
|
||
cy.dataCy('cocktail-name').should('have.text', name); | ||
cy.dataCy('cocktail-category').should('have.text', category); | ||
|
||
if (isEditedText) { | ||
cy.dataCy('cocktail-edited-text').should('exist'); | ||
} else { | ||
cy.dataCy('cocktail-edited-text').should('not.exist'); | ||
} | ||
|
||
cy.get('[data-cy=cocktail-tags] > p').should('have.length', tags.length); | ||
tags.forEach(tag => { | ||
cy.get('[data-cy=cocktail-tags] > p').should('include.text', tag); | ||
}); | ||
|
||
for (let i = 0; i < ingredients.length; i++) { | ||
const element = ingredients[i]; | ||
cy.get(`[data-cy=ingredient-group-${i}] [data-cy=ingredient-name]`).should('include.text', element.name); | ||
cy.get(`[data-cy=ingredient-group-${i}] [data-cy=ingredient-amount]`).should('include.text', element.amount); | ||
} | ||
|
||
cy.dataCy('cocktail-abv').should('include.text', abv); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
• You can now edit base recipes | ||
• Updated German translations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.