Skip to content

Commit

Permalink
[deep link] Add more unit tests (#6746)
Browse files Browse the repository at this point in the history
* 1

* Update deep_links_model.dart

* 1

* lint
  • Loading branch information
hannah-hyj authored Nov 17, 2023
1 parent 5e83456 commit 8fb0fbf
Show file tree
Hide file tree
Showing 4 changed files with 389 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class _NotificationCardSection extends StatelessWidget {
child: Row(
children: [
if (domainErrorCount > 0)
_NotificationCard(
NotificationCard(
title: '$domainErrorCount domain not verified',
description:
'This affects all deep links. Fix issues to make users go directly to your app.',
Expand All @@ -407,7 +407,7 @@ class _NotificationCardSection extends StatelessWidget {
if (domainErrorCount > 0 && pathErrorCount > 0)
const SizedBox(width: defaultSpacing),
if (pathErrorCount > 0)
_NotificationCard(
NotificationCard(
title: '$pathErrorCount path not working',
description:
'Fix these path to make sure users are directed to your app',
Expand Down Expand Up @@ -436,8 +436,10 @@ class _NotificationCardSection extends StatelessWidget {
}
}

class _NotificationCard extends StatelessWidget {
const _NotificationCard({
@visibleForTesting
class NotificationCard extends StatelessWidget {
const NotificationCard({
super.key,
required this.title,
required this.description,
required this.actionButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class DeepLinksController extends DisposableController {
);
}

return _getFilterredLinks(linkDatasByPath.values.toList());
return getFilterredLinks(linkDatasByPath.values.toList());
}

List<LinkData> get getLinkDatasByDomain {
Expand All @@ -162,7 +162,7 @@ class DeepLinksController extends DisposableController {
domainErrors: linkData.domainErrors,
);
}
return _getFilterredLinks(linkDatasByDomain.values.toList());
return getFilterredLinks(linkDatasByDomain.values.toList());
}

final Map<int, AppLinkSettings> _androidAppLinks = <int, AppLinkSettings>{};
Expand Down Expand Up @@ -277,7 +277,7 @@ class DeepLinksController extends DisposableController {
Future<void> validateLinks() async {
allLinkDatasNotifier.value = await _validateAndroidDomain();
displayLinkDatasNotifier.value =
_getFilterredLinks(allLinkDatasNotifier.value!);
getFilterredLinks(allLinkDatasNotifier.value!);

displayOptionsNotifier.value = displayOptionsNotifier.value.copyWith(
domainErrorCount: getLinkDatasByDomain
Expand All @@ -299,7 +299,7 @@ class DeepLinksController extends DisposableController {
displayOptionsNotifier.value =
displayOptionsNotifier.value.copyWith(searchContent: content);
displayLinkDatasNotifier.value =
_getFilterredLinks(allLinkDatasNotifier.value!);
getFilterredLinks(allLinkDatasNotifier.value!);
}

void updateDisplayOptions({
Expand Down Expand Up @@ -328,10 +328,11 @@ class DeepLinksController extends DisposableController {
}

displayLinkDatasNotifier.value =
_getFilterredLinks(allLinkDatasNotifier.value!);
getFilterredLinks(allLinkDatasNotifier.value!);
}

List<LinkData> _getFilterredLinks(List<LinkData> linkDatas) {
@visibleForTesting
List<LinkData> getFilterredLinks(List<LinkData> linkDatas) {
final String searchContent = displayOptions.searchContent;
linkDatas = linkDatas.where((linkData) {
if (searchContent.isNotEmpty &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,11 @@ int _compareLinkData(
switch (sortingOption) {
case SortingOption.errorOnTop:
if (compareDomain) {
if (a.domainErrors.isNotEmpty) return 1;
if (b.domainErrors.isNotEmpty) return -1;
if (a.domainErrors.isNotEmpty) return -1;
if (b.domainErrors.isNotEmpty) return 1;
} else {
if (a.pathError) return 1;
if (b.pathError) return -1;
if (a.pathError) return -1;
if (b.pathError) return 1;
}
return 0;
case SortingOption.aToZ:
Expand Down
Loading

0 comments on commit 8fb0fbf

Please sign in to comment.