From 3b26069ec5d1a6c056ec7ad9bf098569ce90a044 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sun, 21 Jul 2024 11:25:40 +0200 Subject: [PATCH 1/2] feat: 951 - new method User.getUserWikiPage Impacted files: * `user.dart`: new method `getUserWikiPage` * `user_management_test_prod.dart`: test of new method `User.getUserWikiPage` --- lib/src/model/user.dart | 7 +++++++ test/user_management_test_prod.dart | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/src/model/user.dart b/lib/src/model/user.dart index d1b9c3f263..5257ca6b34 100644 --- a/lib/src/model/user.dart +++ b/lib/src/model/user.dart @@ -27,4 +27,11 @@ class User extends JsonObject { @override Map toJson() => _$UserToJson(this); + + static String getUserWikiPage(final String userId) => Uri( + scheme: 'https', + host: 'wiki.openfoodfacts.org', + path: 'User:' + '${userId.substring(0, 1).toUpperCase()}${userId.substring(1)}', + ).toString(); } diff --git a/test/user_management_test_prod.dart b/test/user_management_test_prod.dart index 4408184f8c..99f20fc4a6 100644 --- a/test/user_management_test_prod.dart +++ b/test/user_management_test_prod.dart @@ -185,6 +185,15 @@ void main() { expect(status.status, koStatus); }); }); + + group('wiki page', () { + test('user wiki page', () async { + expect( + User.getUserWikiPage('teolemon'), + 'https://wiki.openfoodfacts.org/User:Teolemon', + ); + }); + }); } String _generateRandomString(int length) { From 48cec02960fbc7b5187a83c94c8aceafa6c83207 Mon Sep 17 00:00:00 2001 From: monsieurtanuki Date: Sun, 21 Jul 2024 11:49:19 +0200 Subject: [PATCH 2/2] Unrelated test minor fix. --- test/api_get_save_product_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/api_get_save_product_test.dart b/test/api_get_save_product_test.dart index b8826deb8a..584a7fd7af 100644 --- a/test/api_get_save_product_test.dart +++ b/test/api_get_save_product_test.dart @@ -65,7 +65,7 @@ void main() { final String barcode = getBookBarcode(0); const OpenFoodFactsLanguage language = OpenFoodFactsLanguage.GERMAN; - const String genericName = 'Softdrink'; + const String genericName = 'Softdrink beverage'; const List ingredientsText = [ 'Wasser', 'Kohlensäure', @@ -711,7 +711,7 @@ void main() { } const String barcode = '111111555555'; - const String genericName = 'Softdrink'; + const String genericName = 'Softdrink beverage'; const String labels = 'MyTestLabel'; const String quantity = '5.5 Liter';