From 02c9da2085263d5c3fb030d050720968ddb0e89f Mon Sep 17 00:00:00 2001 From: primozratej Date: Wed, 6 Mar 2024 14:10:51 +0700 Subject: [PATCH 1/9] Remove isPrettyUri does not help in this case now. and rewrite findManifest --- lib/util/extensions.dart | 8 ------ lib/util/opener_controller.dart | 48 ++++++++++++++++++++++----------- test/pretty_urls_test.dart | 23 ---------------- 3 files changed, 33 insertions(+), 46 deletions(-) delete mode 100644 test/pretty_urls_test.dart diff --git a/lib/util/extensions.dart b/lib/util/extensions.dart index bc15fea..c321076 100644 --- a/lib/util/extensions.dart +++ b/lib/util/extensions.dart @@ -94,11 +94,3 @@ extension FutureAsyncValueX on Future> { (asyncValue) => asyncValue.asData?.value, ); } - -extension PrettyUri on Uri { - bool isUriPretty() { - RegExp regex = RegExp(r'index\.php.*[?&]r='); - String path = Uri.decodeComponent(toString()); - return !regex.hasMatch(path); - } -} diff --git a/lib/util/opener_controller.dart b/lib/util/opener_controller.dart index 34b23d7..30bce67 100644 --- a/lib/util/opener_controller.dart +++ b/lib/util/opener_controller.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart'; import 'package:humhub/models/hum_hub.dart'; import 'package:humhub/models/manifest.dart'; -import 'package:humhub/util/extensions.dart'; import 'package:humhub/util/providers.dart'; import 'package:http/http.dart' as http; import 'package:loggy/loggy.dart'; @@ -24,22 +23,40 @@ class OpenerController { OpenerController({required this.ref, required this.helper}); - findManifest(String url) async { + /// Finds the `manifest.json` file associated with the given URL. If the URL does not + /// directly point to the `manifest.json` file, it traverses up the directory structure + /// to locate it. If not found, it assumes a default path format. This method makes + /// asynchronous requests to fetch the manifest data. + /// + /// @param url The URL from which to start searching for the `manifest.json` file. + /// @return A Future that completes with no result once the `manifest.json` file is found + /// or the default path is assumed, or if an error occurs during the search process. + /// Additionally, it may trigger a check for the HumHub module view based on the start URL + /// obtained from the manifest data. + /// + /// @throws Exception if an error occurs during the search process. + Future findManifest(String url) async { Uri uri = assumeUrl(url); - if (!uri.isUriPretty()) { - asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin, isUriPretty: false)); - } else { - for (var i = uri.pathSegments.length - 1; i >= 0; i--) { - String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; - asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin)); - if (!asyncData!.hasError) break; - } - if (uri.pathSegments.isEmpty) { - asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin)); - } + if (uri.pathSegments.isEmpty) { + asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin)); + logDebug("1"); + if (!asyncData!.hasError) return true; } - if (asyncData!.hasError) return; - await checkHumHubModuleView(asyncData!.value!.startUrl); + for (var i = uri.pathSegments.length - 1; i >= 0; i--) { + String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; + asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin)); + logDebug("2 in $i"); + if (!asyncData!.hasError) return true; + } + // Here we still did not find the manifest.json assume that it is somewhere in a format ../../index.php?r=web%2Fpwa-manifest%2Findex + for (var i = uri.pathSegments.length - 1; i >= 0; i--) { + String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; + asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin, isUriPretty: false)); + logDebug("3 in $i"); + if (!asyncData!.hasError) return true; + } + logDebug("4"); + return asyncData!.hasError; } checkHumHubModuleView(String url) async { @@ -67,6 +84,7 @@ class OpenerController { } // Get the manifest.json for given url. await findManifest(helper.model[formUrlKey]!); + await checkHumHubModuleView(asyncData!.value!.startUrl); // If manifest.json does not exist the url is incorrect. // This is a temp. fix the validator expect sync. function this is some established workaround. // In the future we could define our own TextFormField that would also validate the API responses. diff --git a/test/pretty_urls_test.dart b/test/pretty_urls_test.dart deleted file mode 100644 index 5d3ec13..0000000 --- a/test/pretty_urls_test.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:humhub/util/extensions.dart'; - -Future main() async { - group("Testing pretty urls", () { - test("Community url", () { - Uri uri = Uri.parse("https://community.humhub.com/dashboard"); - expect(uri.isUriPretty(), true); - }); - test("Lado", () { - Uri uri = Uri.parse("https://labo-sphere.fr/index.php?r=user%2Fauth%2Flogin"); - expect(uri.isUriPretty(), false); - }); - test("Test12345", () { - Uri uri = Uri.parse("https://sometestproject12345.humhub.com/dashboard"); - expect(uri.isUriPretty(), true); - }); - test("Local", () { - Uri uri = Uri.parse("http://192.168.64.3/humhub/index.php?r=user%2Fauth%2Flogin"); - expect(uri.isUriPretty(), false); - }); - }); -} From c56079a8b167bc77ec3ea419a3da38fd1c1d844e Mon Sep 17 00:00:00 2001 From: primozratej Date: Wed, 6 Mar 2024 14:42:45 +0700 Subject: [PATCH 2/9] Fixed still needts tests --- lib/pages/web_view.dart | 2 +- lib/util/opener_controller.dart | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/pages/web_view.dart b/lib/pages/web_view.dart index a9a2d60..23a02f5 100644 --- a/lib/pages/web_view.dart +++ b/lib/pages/web_view.dart @@ -189,7 +189,7 @@ class WebViewAppState extends ConsumerState { } String? payloadFromPush = InitFromPush.usePayload(); if (payloadFromPush != null) url = payloadFromPush; - return URLRequest(url: Uri.parse(url ?? manifest.baseUrl), headers: ref.read(humHubProvider).customHeaders); + return URLRequest(url: Uri.parse(url ?? manifest.startUrl), headers: ref.read(humHubProvider).customHeaders); } _onLoadStop(InAppWebViewController controller, Uri? url) { diff --git a/lib/util/opener_controller.dart b/lib/util/opener_controller.dart index 30bce67..db5c002 100644 --- a/lib/util/opener_controller.dart +++ b/lib/util/opener_controller.dart @@ -39,23 +39,22 @@ class OpenerController { Uri uri = assumeUrl(url); if (uri.pathSegments.isEmpty) { asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin)); - logDebug("1"); + if (!asyncData!.hasError) return true; + + asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin, isUriPretty: false)); if (!asyncData!.hasError) return true; } - for (var i = uri.pathSegments.length - 1; i >= 0; i--) { + for (var i = uri.pathSegments.length; i >= 0; i--) { String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin)); - logDebug("2 in $i"); if (!asyncData!.hasError) return true; } // Here we still did not find the manifest.json assume that it is somewhere in a format ../../index.php?r=web%2Fpwa-manifest%2Findex - for (var i = uri.pathSegments.length - 1; i >= 0; i--) { + for (var i = uri.pathSegments.length; i >= 0; i--) { String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin, isUriPretty: false)); - logDebug("3 in $i"); if (!asyncData!.hasError) return true; } - logDebug("4"); return asyncData!.hasError; } @@ -84,9 +83,12 @@ class OpenerController { } // Get the manifest.json for given url. await findManifest(helper.model[formUrlKey]!); - await checkHumHubModuleView(asyncData!.value!.startUrl); + logDebug("Here"); + if (asyncData!.hasValue) { + await checkHumHubModuleView(asyncData!.value!.startUrl); + } // If manifest.json does not exist the url is incorrect. - // This is a temp. fix the validator expect sync. function this is some established workaround. + // This is a temp. fix the validator expect sync function this is established workaround. // In the future we could define our own TextFormField that would also validate the API responses. // But it this is not acceptable I can suggest simple popup or tempPopup. if (asyncData!.hasError || !doesViewExist) { From 33c7afd3b244bc9d31b71c7b9812843e56639dcf Mon Sep 17 00:00:00 2001 From: primozratej Date: Thu, 7 Mar 2024 11:43:36 +0700 Subject: [PATCH 3/9] Separate the logic of finding possible urls and actual fetching the data. --- lib/models/manifest.dart | 10 ++++++---- lib/util/opener_controller.dart | 25 +++++++++++++------------ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/models/manifest.dart b/lib/models/manifest.dart index c301976..7b5f337 100644 --- a/lib/models/manifest.dart +++ b/lib/models/manifest.dart @@ -35,10 +35,12 @@ class Manifest { 'theme_color': themeColor, }; - static Future Function(Dio dio) get(String url, {bool isUriPretty = true}) => (dio) async { - Response res = !isUriPretty - ? await dio.get('$url/index.php?r=web%2Fpwa-manifest%2Findex') - : await dio.get('$url/manifest.json'); + static Future Function(Dio dio) get(String url) => (dio) async { + Response res = await dio.get(url); return Manifest.fromJson(res.data); }; + + static String defineUrl(String url, {bool isUriPretty = true}) { + return !isUriPretty ? '$url/index.php?r=web%2Fpwa-manifest%2Findex' : '$url/manifest.json'; + } } diff --git a/lib/util/opener_controller.dart b/lib/util/opener_controller.dart index db5c002..51dba3a 100644 --- a/lib/util/opener_controller.dart +++ b/lib/util/opener_controller.dart @@ -36,26 +36,27 @@ class OpenerController { /// /// @throws Exception if an error occurs during the search process. Future findManifest(String url) async { + List possibleUrls = generatePossibleManifestsUrls(url); + for (var url in possibleUrls) { + asyncData = await APIProvider.of(ref).request(Manifest.get(url)); + if (!asyncData!.hasError) break; + } + return asyncData!.hasError; + } + + List generatePossibleManifestsUrls(String url) { + List urls = []; Uri uri = assumeUrl(url); - if (uri.pathSegments.isEmpty) { - asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin)); - if (!asyncData!.hasError) return true; - asyncData = await APIProvider.of(ref).request(Manifest.get(uri.origin, isUriPretty: false)); - if (!asyncData!.hasError) return true; - } for (var i = uri.pathSegments.length; i >= 0; i--) { String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; - asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin)); - if (!asyncData!.hasError) return true; + urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin)); } - // Here we still did not find the manifest.json assume that it is somewhere in a format ../../index.php?r=web%2Fpwa-manifest%2Findex for (var i = uri.pathSegments.length; i >= 0; i--) { String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; - asyncData = await APIProvider.of(ref).request(Manifest.get(i != 0 ? urlIn : uri.origin, isUriPretty: false)); - if (!asyncData!.hasError) return true; + urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin, isUriPretty: false)); } - return asyncData!.hasError; + return urls; } checkHumHubModuleView(String url) async { From 8345e91ce5b222fbe3c890b1ae0842e34cfa79e1 Mon Sep 17 00:00:00 2001 From: primozratej Date: Thu, 7 Mar 2024 14:44:05 +0700 Subject: [PATCH 4/9] Refactor method for finding manifest and add test --- lib/util/opener_controller.dart | 40 ++++++++++----------- test/opener_test.dart | 64 ++++++++++++--------------------- 2 files changed, 42 insertions(+), 62 deletions(-) diff --git a/lib/util/opener_controller.dart b/lib/util/opener_controller.dart index 51dba3a..d4ccdc4 100644 --- a/lib/util/opener_controller.dart +++ b/lib/util/opener_controller.dart @@ -44,21 +44,6 @@ class OpenerController { return asyncData!.hasError; } - List generatePossibleManifestsUrls(String url) { - List urls = []; - Uri uri = assumeUrl(url); - - for (var i = uri.pathSegments.length; i >= 0; i--) { - String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; - urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin)); - } - for (var i = uri.pathSegments.length; i >= 0; i--) { - String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; - urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin, isUriPretty: false)); - } - return urls; - } - checkHumHubModuleView(String url) async { Response? response; response = await http.Client().get(Uri.parse(url)).catchError((err) { @@ -113,11 +98,6 @@ class OpenerController { bool get allOk => !(asyncData == null || asyncData!.hasError || !doesViewExist); - Uri assumeUrl(String url) { - if (url.startsWith("https://") || url.startsWith("http://")) return Uri.parse(url); - return Uri.parse("https://$url"); - } - String? validateUrl(String? value) { if (value == error404) return 'Your HumHub installation does not exist'; if (value == noConnection) return 'Please check your internet connection.'; @@ -126,4 +106,24 @@ class OpenerController { } return null; } + + static List generatePossibleManifestsUrls(String url) { + List urls = []; + Uri uri = assumeUrl(url); + + for (var i = uri.pathSegments.length; i >= 0; i--) { + String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; + urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin)); + } + for (var i = uri.pathSegments.length; i >= 0; i--) { + String urlIn = "${uri.origin}/${uri.pathSegments.getRange(0, i).join('/')}"; + urls.add(Manifest.defineUrl(i != 0 ? urlIn : uri.origin, isUriPretty: false)); + } + return urls; + } + + static Uri assumeUrl(String url) { + if (url.startsWith("https://") || url.startsWith("http://")) return Uri.parse(url); + return Uri.parse("https://$url"); + } } diff --git a/test/opener_test.dart b/test/opener_test.dart index fba10a1..5112825 100644 --- a/test/opener_test.dart +++ b/test/opener_test.dart @@ -1,9 +1,8 @@ import 'dart:io'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:humhub/pages/opener.dart'; +import 'package:humhub/util/opener_controller.dart'; +import 'package:loggy/loggy.dart'; import 'package:mockito/mockito.dart'; class MyHttpOverrides extends HttpOverrides { @@ -16,50 +15,31 @@ class MyHttpOverrides extends HttpOverrides { class MockFlutterSecureStorage extends Mock implements FlutterSecureStorage {} -Future main() async { - setUp(() { - HttpOverrides.global = MyHttpOverrides(); - }); - - testWidgets('Test opener URL parsing', (WidgetTester tester) async { - // Key value map of URLs with bool that represent the expected value - Map urlsAndValuesIn = { - "https://community.humhub.com": true, - "https://demo.cuzy.app/": true, - "https://sometestproject12345.humhub.com/": true, - "https://sometestproject12345.humhub.com/some/path": true, - "https://sometestproject123456.humhub.com/": false, - "https://sometestproject123456.humhubb.com": false, - "sometestproject12345.humhub.com": true, - "//demo.cuzy.app/": false, +void main() { + group('generatePossibleManifestsUrls', () { + Map uriMap = { + "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub/": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com/humhub": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com/acc": "https://sometestproject12345.humhub.com/z/manifest.json", + "sometestproject12345.humhub.com/login": "https://sometestproject12345.humhub.com/a/manifest.json", }; - Map urlsAndValuesOut = {}; - Key openerKey = const Key('opener'); - - for (var urlEntry in urlsAndValuesIn.entries) { - String url = urlEntry.key; - await tester.pumpWidget( - MaterialApp( - home: ProviderScope( - child: Scaffold(body: Opener(key: openerKey)), - ), - ), - ); - final state = tester.state(find.byKey(openerKey)); - state.controlLer.helper.model[state.controlLer.formUrlKey] = url; - bool isBreaking = false; + test('Check URLs', () { + List failedExpectations = []; - await tester.runAsync(() async { - try { - await state.controlLer.findManifest(url); - } catch (er) { - isBreaking = true; + uriMap.forEach((key, value) { + List generatedUrls = OpenerController.generatePossibleManifestsUrls(key); + if (!generatedUrls.contains(value)) { + failedExpectations.add("🐛 Opener URL $key generated:\n ${generatedUrls.toString()} list \n the expected value $value was not found"); } }); - isBreaking ? urlsAndValuesOut[url] = !isBreaking : urlsAndValuesOut[url] = !state.controlLer.asyncData!.hasError; - } - expect(urlsAndValuesOut, urlsAndValuesIn); + if (failedExpectations.isNotEmpty) { + fail(failedExpectations.join("\n\n")); + } + }); }); } From 5767ef887014f0c73bb8a1b72fcaa9b9fdf6acaf Mon Sep 17 00:00:00 2001 From: primozratej Date: Thu, 7 Mar 2024 14:44:57 +0700 Subject: [PATCH 5/9] remove unused imports --- test/opener_test.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/test/opener_test.dart b/test/opener_test.dart index 5112825..c947e61 100644 --- a/test/opener_test.dart +++ b/test/opener_test.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:humhub/util/opener_controller.dart'; -import 'package:loggy/loggy.dart'; import 'package:mockito/mockito.dart'; class MyHttpOverrides extends HttpOverrides { From 68537abfd6527f37337eea3039591e209c236f15 Mon Sep 17 00:00:00 2001 From: primozratej Date: Mon, 11 Mar 2024 11:15:00 +0700 Subject: [PATCH 6/9] Add tests for community, sometest12345 and test.cuzy.app --- test/opener_test.dart | 111 +++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/test/opener_test.dart b/test/opener_test.dart index c947e61..c7a4533 100644 --- a/test/opener_test.dart +++ b/test/opener_test.dart @@ -1,44 +1,85 @@ -import 'dart:io'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:humhub/util/opener_controller.dart'; -import 'package:mockito/mockito.dart'; -class MyHttpOverrides extends HttpOverrides { - @override - HttpClient createHttpClient(SecurityContext? context) { - return super.createHttpClient(context) - ..badCertificateCallback = (X509Certificate cert, String host, int port) => true; +void main() { + void testGroupOfURIs(Map uriMap) { + List failedExpectations = []; + + uriMap.forEach((key, value) { + List generatedUrls = OpenerController.generatePossibleManifestsUrls(key); + if (!generatedUrls.contains(value)) { + failedExpectations.add( + "🐛 Opener URL $key generated:\n ${generatedUrls.toString()} list \n the expected value $value was not found"); + } + }); + + if (failedExpectations.isNotEmpty) { + fail(failedExpectations.join("\n\n")); + } } -} -class MockFlutterSecureStorage extends Mock implements FlutterSecureStorage {} + group('Generate possible Manifests.json URLs and check if exists', () { + /// [key] represents the opener dialog input string + /// [value] represents the actual manifest.json location -void main() { - group('generatePossibleManifestsUrls', () { - Map uriMap = { - "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", - "test.cuzy.app/humhub/": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", - "test.cuzy.app/": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", - "sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", - "sometestproject12345.humhub.com/humhub": "https://sometestproject12345.humhub.com/manifest.json", - "sometestproject12345.humhub.com/acc": "https://sometestproject12345.humhub.com/z/manifest.json", - "sometestproject12345.humhub.com/login": "https://sometestproject12345.humhub.com/a/manifest.json", - }; - - test('Check URLs', () { - List failedExpectations = []; - - uriMap.forEach((key, value) { - List generatedUrls = OpenerController.generatePossibleManifestsUrls(key); - if (!generatedUrls.contains(value)) { - failedExpectations.add("🐛 Opener URL $key generated:\n ${generatedUrls.toString()} list \n the expected value $value was not found"); - } - }); - - if (failedExpectations.isNotEmpty) { - fail(failedExpectations.join("\n\n")); - } + test('Check HumHub Community URLs', () { + Map map = { + "https://community.humhub.com/": "https://community.humhub.com/manifest.json", + "https://community.humhub.com": "https://community.humhub.com/manifest.json", + "community.humhub.com/": "https://community.humhub.com/manifest.json", + "community.humhub.com": "https://community.humhub.com/manifest.json", + "community.humhub.com/some/more": "https://community.humhub.com/manifest.json", + "https://community.humhub.com/and/more": "https://community.humhub.com/manifest.json", + }; + testGroupOfURIs(map); }); + + test('Check sometestproject12345 URLs', () { + Map map = { + "https://sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com/some/more": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com/manifest.json": + "https://sometestproject12345.humhub.com/manifest.json", + }; + testGroupOfURIs(map); + }); + + test('Check some sometestproject12345 URLs', () { + Map map = { + "https://sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", + "sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com/some/more": "https://sometestproject12345.humhub.com/manifest.json", + "https://sometestproject12345.humhub.com/manifest.json": + "https://sometestproject12345.humhub.com/manifest.json", + }; + testGroupOfURIs(map); + }); + + test('Check some test.cuzy.app URLs', () { + Map map = { + "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "https://test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + }; + testGroupOfURIs(map); + }); + + /// TEMPLATE: copy this and change it for your use case + /*test('Check some HumHum instance URLs', () { + /// [key] represents the opener dialog input string + /// [value] represents the actual manifest.json location + Map map = { + "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + }; + testGroupOfURIs(map); + });*/ }); } From 5f8ec4fae575d4a7daf7f01c3b8c978bff4a5bc9 Mon Sep 17 00:00:00 2001 From: primozratej Date: Mon, 11 Mar 2024 11:17:11 +0700 Subject: [PATCH 7/9] Run flutter test on build --- .github/workflows/version-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/version-release.yml b/.github/workflows/version-release.yml index af4e591..3a2d700 100644 --- a/.github/workflows/version-release.yml +++ b/.github/workflows/version-release.yml @@ -85,6 +85,7 @@ jobs: versionName: ${{ env.version }} - run: flutter clean - run: flutter pub get + - run: flutter test - run: flutter analyze --no-fatal-warnings --no-fatal-infos - run: flutter build apk --release --split-per-abi --build-name="${{ env.version }}" --build-number=${{ env.version_code }} - run: flutter build appbundle --release --build-name="${{ env.version }}" --build-number=${{ env.version_code }} From 5292c7016eeb88afc4642c7b275a629519fbc172 Mon Sep 17 00:00:00 2001 From: primozratej Date: Mon, 11 Mar 2024 11:17:32 +0700 Subject: [PATCH 8/9] fix map --- test/opener_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/opener_test.dart b/test/opener_test.dart index c7a4533..a5d097e 100644 --- a/test/opener_test.dart +++ b/test/opener_test.dart @@ -63,7 +63,7 @@ void main() { test('Check some test.cuzy.app URLs', () { Map map = { "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", - "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "test.cuzy.app/humhub/": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", "test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", "https://test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", From 892ec084b104560bf52b336099d3a707b4666f11 Mon Sep 17 00:00:00 2001 From: primozratej Date: Mon, 11 Mar 2024 11:20:53 +0700 Subject: [PATCH 9/9] Add one more test --- test/opener_test.dart | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/test/opener_test.dart b/test/opener_test.dart index a5d097e..6acfdf1 100644 --- a/test/opener_test.dart +++ b/test/opener_test.dart @@ -47,19 +47,6 @@ void main() { testGroupOfURIs(map); }); - test('Check some sometestproject12345 URLs', () { - Map map = { - "https://sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", - "https://sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", - "sometestproject12345.humhub.com/": "https://sometestproject12345.humhub.com/manifest.json", - "sometestproject12345.humhub.com": "https://sometestproject12345.humhub.com/manifest.json", - "https://sometestproject12345.humhub.com/some/more": "https://sometestproject12345.humhub.com/manifest.json", - "https://sometestproject12345.humhub.com/manifest.json": - "https://sometestproject12345.humhub.com/manifest.json", - }; - testGroupOfURIs(map); - }); - test('Check some test.cuzy.app URLs', () { Map map = { "https://test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", @@ -67,6 +54,7 @@ void main() { "test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", "test.cuzy.app/humhub": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", "https://test.cuzy.app/humhub/some": "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex", + "https://test.cuzy.app/humhub/index.php?r=dashboard%2Fdashboard" : "https://test.cuzy.app/humhub/index.php?r=web%2Fpwa-manifest%2Findex" }; testGroupOfURIs(map); });