Skip to content

Commit

Permalink
Add christmas cocktails (#442)
Browse files Browse the repository at this point in the history
* feat: added christmas season

* chore: add sherry eggnog

* add hot toddy

* add winter rita

* add the galah

* add tests and remove deprecated code

* chore: set version
  • Loading branch information
anton-gustafsson authored Nov 27, 2023
1 parent c86e913 commit 48390a8
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 86 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.moimob.drinkable"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14400
versionName "1.44.0"
versionCode 14401
versionName "1.44.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/14401.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
• Added 4 new cocktails
• Added 1 new ingredient
62 changes: 62 additions & 0 deletions src/data/cocktail-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2528,5 +2528,67 @@ const cocktails: StaticCocktail[] = [
{ amount: '60', ingredientId: '86', unit: Unit.DASH }
],
tags: []
},
{
id: '184',
imageSrc: 'images/sherry_eggnog.jpg',
isImagePortrait: false,
translation: 'sherry-eggnog',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '60', ingredientId: '158', unit: Unit.ML },
{ amount: '1', ingredientId: '16', unit: Unit.TSP },
{ amount: '1', ingredientId: '114', unit: '' },
{ amount: '120', ingredientId: '77', unit: Unit.ML },
{ amount: '', ingredientId: '141', unit: '' }
],
tags: [Tag.Christmas]
},
{
id: '185',
imageSrc: 'images/hot_toddy.jpg',
isImagePortrait: false,
translation: 'hot-toddy',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '60', ingredientId: '52', unit: Unit.ML },
{ amount: '15', ingredientId: '115', unit: Unit.ML },
{ amount: '150', ingredientId: '91', unit: Unit.ML },
{ amount: '1', ingredientId: '103', unit: '' },
{ amount: '1', ingredientId: '105', unit: '' },
{ amount: '2', ingredientId: '102', unit: '' }
],
tags: [Tag.Christmas]
},
{
id: '186',
imageSrc: 'images/winter_rita.jpg',
isImagePortrait: false,
translation: 'winter-rita',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '60', ingredientId: '18', unit: Unit.ML },
{ amount: '7.5', ingredientId: '36', unit: Unit.ML },
{ amount: '30', ingredientId: '2', unit: Unit.ML },
{ amount: '15', ingredientId: '64', unit: Unit.ML },
{ amount: '15', ingredientId: '3', unit: Unit.ML },
{ amount: '', ingredientId: '46', unit: '' }
],
tags: [Tag.Christmas]
},
{
id: '187',
imageSrc: 'images/the_galah.jpg',
isImagePortrait: false,
translation: 'the-galah',
category: DrinkCategory.Cocktail,
ingredientGroups: [
{ amount: '30', ingredientId: '54', unit: Unit.ML },
{ amount: '30', ingredientId: '36', unit: Unit.ML },
{ amount: '15', ingredientId: '143', unit: Unit.ML },
{ amount: '15', ingredientId: '2', unit: Unit.ML },
{ amount: '90', ingredientId: '26', unit: Unit.ML }
],
tags: []
}
];
5 changes: 3 additions & 2 deletions src/data/ingredient-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ const currentIngredients: StaticIngredient[] = [
{ id: '147', translation: 'cream-liqueur', spiritType: SpiritType.None, abv: 17, replacementIds: ['108'] },
{ id: '148', translation: 'limoncello-di-capri', spiritType: SpiritType.None, abv: 30, replacementIds: ['51'] },
{ id: '149', translation: 'dooleys', spiritType: SpiritType.None, abv: 17 },
{ id: '150', translation: 'creme-de-banana', spiritType: SpiritType.None, abv: 17 },
// 150 is removed due to duplicate
{ id: '151', translation: 'hard-cider', spiritType: SpiritType.None, abv: 4 },
{ id: '152', translation: 'gammel-dansk', spiritType: SpiritType.None, abv: 38 },
{ id: '153', translation: 'calvados', spiritType: SpiritType.CognacBrandy, abv: 42, replacementIds: ['65'] },
{ id: '154', translation: 'wheat-beer', spiritType: SpiritType.None, abv: 5 },
{ id: '155', translation: 'apple-schnapps', spiritType: SpiritType.None, abv: 18 },
{ id: '156', translation: '7-up', spiritType: SpiritType.None, replacementIds: ['45'] },
{ id: '157', translation: 'passion-fruit-syrup', spiritType: SpiritType.None }
{ id: '157', translation: 'passion-fruit-syrup', spiritType: SpiritType.None },
{ id: '158', translation: 'sherry', spiritType: SpiritType.None, abv: 17 }
];
6 changes: 5 additions & 1 deletion src/locales/en/cocktails.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,9 @@
"mulled-wine": "Mulled Wine",
"captain-kidds-punch": "Captain Kidd’s Punch",
"pure-passion": "Pure Passion",
"old-cuban": "Old Cuban"
"old-cuban": "Old Cuban",
"sherry-eggnog": "Sherry Eggnog",
"hot-toddy": "Hot Toddy",
"winter-rita": "Winter Rita",
"the-galah": "The Galah"
}
3 changes: 2 additions & 1 deletion src/locales/en/ingredients.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,6 @@
"wheat-beer": "Wheat Beer",
"apple-schnapps": "Apple Schnapps",
"7-up": "7 Up",
"passion-fruit-syrup": "Passion Fruit Syrup"
"passion-fruit-syrup": "Passion Fruit Syrup",
"sherry": "Sherry"
}
6 changes: 5 additions & 1 deletion src/locales/en/instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,9 @@
"mulled-wine": "Simmer 3 cups water with, sugar, cloves, cinnamon sticks, and lemon peel in a stainless steel pot for 10 minutes.\nAdd wine heat to a 'coffee temperature' (DO NOT BOIL) then add the brandy.",
"captain-kidds-punch": "Mix all ingredients together in a shaker and strain into a collins glass.\nUse Caribbean dark Rum for a sweeter taste. Top with nutmeg",
"pure-passion": "Mix up all ingredients with a cocktail stirrer and serve with crushed ice with mint and edible flour if available.",
"old-cuban": "Shake a handful of mint, white rum, sugar syrup, lime juice and 2 dashes angostura bitters with ice. Double strain into a glass and top with prosecco."
"old-cuban": "Shake a handful of mint, white rum, sugar syrup, lime juice and 2 dashes angostura bitters with ice. Double strain into a glass and top with prosecco.",
"sherry-eggnog": "Shake sherry, powdered sugar, and egg with ice and strain into a collins glass.\nFill with milk and stir.\nSprinkle nutmeg on top and serve.",
"hot-toddy": "STEP 1 Whisk the whisky and honey together and split between 2 heatproof glasses. Add half of the cinnamon stick to each, then top up with boiling water.\n\nSTEP 2 Add a splash of lemon juice to each, then taste and add more to your preference. Finish each with a slice of lemon, studded with a clove, and serve immediately.",
"winter-rita": "Salt rim.\nCombine all ingredients, shake with ice, and strain over fresh ice.",
"the-galah": "Mix together the alcoholic portions and top with Pineapple and Lime juice."
}
42 changes: 12 additions & 30 deletions src/services/local-storage-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export class LocalStorageService {
await this.addDefaultIngredientList([]);
}

// 2023-11-27 - Remove Ingredient 150 due to duplication
if (this._ingredientLists.flatMap(x => x.ingredients).find(x => x === '150') !== undefined) {
this._ingredientLists.forEach(x => {
x.ingredients = x.ingredients.filter(y => y !== '150');
});

this.updateIngredientLists(this._ingredientLists);
}

const messuarementSystem = await this.getFromLocalStorage(StorageKey.MessuarementSystem, false);
this._messuarementSystem = messuarementSystem !== null ? messuarementSystem : MessuarementSystem.Imperial;

Expand All @@ -56,10 +65,11 @@ export class LocalStorageService {

const shoppingLists = await this.getFromLocalStorage(StorageKey.ShoppingLists);
this._shoppingLists = shoppingLists !== null ? shoppingLists : [];

await this.migrateFavoriteCocktails();
}

/**
* Migration made 2023-09-06. Remove after 6 months?
*/
private async migrateSavedIngredients() {
const savedIngredientsStorageKey: StorageKey = StorageKey.SavedIngredients;

Expand All @@ -85,30 +95,6 @@ export class LocalStorageService {
await this.updateIngredientLists([ingredientList]);
}

private async migrateFavoriteCocktails() {
const keyExists = await this.keyExists(StorageKey.FavoriteCocktails);

if (keyExists) {
const favoriteResponse = await this.getFromLocalStorage(StorageKey.FavoriteCocktails);
const favoriteCocktails = favoriteResponse !== null ? favoriteResponse.map(String) : [];

favoriteCocktails.forEach((element: string) => {
const cocktailInformation = this._cocktailInformation.find(x => x.id === element);
if (cocktailInformation !== undefined) {
cocktailInformation.isFavorite = true;
} else {
this._cocktailInformation.push({
id: element,
isFavorite: true
});
}
});

await this.updateCocktailInformation(this._cocktailInformation);
await Preferences.remove({ key: StorageKey.FavoriteCocktails });
}
}

public async updateCocktails(cocktails: Cocktail[]) {
// No not save alocholInformation to LocalStorage
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -307,10 +293,6 @@ export enum StorageKey {
*/
SavedIngredients = 'saved-ingredients',
MessuarementSystem = 'messuarement-system',
/**
* @deprecated FavoriteCocktails have been replaced with CocktailInformation
*/
FavoriteCocktails = 'favorite-cocktails',
WidgetOrder = 'widget-order',
Cocktails = 'cocktails',
Ingredients = 'ingredients',
Expand Down
Binary file added static/images/hot_toddy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/sherry_eggnog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/the_galah.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/winter_rita.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/data/cocktail-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ describe('getStaticCocktails', () => {
expect(ids.length).toBe([...new Set(ids)].length);
});

test('translation keys should not include duplicates', () => {
const ingredients = getStaticCocktails();

const names = ingredients.map(x => x.translation);

expect(names.length).toBe([...new Set(names)].length);
});

test('IBA Cocktails should include a secondary IBA tag', () => {
const cocktails = getStaticCocktails();

Expand Down
8 changes: 8 additions & 0 deletions tests/data/ingredient-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ describe('getStaticIngredients', () => {

expect(ids.length).toBe([...new Set(ids)].length);
});

test('translation keys should not include duplicates', () => {
const ingredients = getStaticIngredients();

const names = ingredients.map(x => x.translation);

expect(names.length).toBe([...new Set(names)].length);
});
});
68 changes: 19 additions & 49 deletions tests/services/local-storage-service.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CocktailInformation } from 'domain/entities/cocktail-information';
import { LocalStorageService, StorageKey } from 'services/local-storage-service';
import { expect } from '@jest/globals';
import { IngredientList } from 'domain/entities/ingredient-list';
Expand Down Expand Up @@ -57,54 +56,6 @@ describe('LocalStorageService', () => {
expect(result).toStrictEqual(['1', '2', '3']);
});

test('Initialize - Migrate from FavoriteCocktails', async () => {
const key = 'CapacitorStorage.favorite-cocktails';
window.localStorage.setItem(key, JSON.stringify(['1', '2', '3']));
await sut.initialize();

const cocktailInformation = JSON.parse(
window.localStorage.getItem('CapacitorStorage.cocktail-information')
) as CocktailInformation[];

expect(cocktailInformation.length).toBe(3);

for (let i = 1; i < cocktailInformation.length; i++) {
const element = cocktailInformation[i - 1];
expect(element.id).toBe(i.toString());
expect(element.isFavorite).toBe(true);
}

expect(window.localStorage.getItem(key)).toBeNull();
});

test('Initialize - Migrate from FavoriteCocktails - existing rating', async () => {
const key = 'CapacitorStorage.favorite-cocktails';
const informationKey = 'CapacitorStorage.cocktail-information';

window.localStorage.setItem(key, JSON.stringify(['1', '2', '3']));
window.localStorage.setItem(
informationKey,
JSON.stringify([
{
id: '1',
rating: 5
}
])
);

await sut.initialize();

const cocktailInformation = JSON.parse(
window.localStorage.getItem('CapacitorStorage.cocktail-information')
) as CocktailInformation[];

expect(cocktailInformation.length).toBe(3);
expect(window.localStorage.getItem(key)).toBeNull();
expect(cocktailInformation[0].rating).toBeTruthy();
expect(cocktailInformation[1].rating).toBeUndefined();
expect(cocktailInformation[2].rating).toBeUndefined();
});

test('Initialize - Migrate from Saved Ingredients', async () => {
const key = 'CapacitorStorage.saved-ingredients';

Expand All @@ -123,4 +74,23 @@ describe('LocalStorageService', () => {
expect(ingredientLists[0].id).toBe(0);
expect(ingredientLists[0].name).toBe('My Bar');
});

test('Initialize - Remove Ingredient with id 150', async () => {
const key = 'CapacitorStorage.' + StorageKey.IngredientLists;

window.localStorage.setItem(
key,
JSON.stringify([
{ name: 'My Bar', ingredients: ['1', '150'] },
{ name: 'Test', ingredients: ['150', '2'] }
])
);

await sut.initialize();

const ingredientLists = JSON.parse(window.localStorage.getItem(key)) as IngredientList[];
expect(ingredientLists.length).toBe(2);
expect(ingredientLists[0].ingredients).toEqual(['1']);
expect(ingredientLists[1].ingredients).toEqual(['2']);
});
});

0 comments on commit 48390a8

Please sign in to comment.