mirror of
https://github.com/immich-app/immich.git
synced 2025-12-22 09:15:34 +03:00
feat(mobile): init of add quick action configurator and settings for viewer actions
This commit is contained in:
@@ -3,6 +3,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/constants/enums.dart';
|
||||
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/edit_image_action_button.widget.dart';
|
||||
import 'package:immich_mobile/presentation/widgets/action_buttons/share_action_button.widget.dart';
|
||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
||||
|
||||
LocalAsset createLocalAsset({
|
||||
@@ -137,6 +140,56 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('edit button', () {
|
||||
test('should show for images when not in locked view', () {
|
||||
final context = ActionButtonContext(
|
||||
asset: createRemoteAsset(type: AssetType.image),
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.timeline,
|
||||
);
|
||||
|
||||
expect(ActionButtonType.edit.shouldShow(context), isTrue);
|
||||
});
|
||||
|
||||
test('should not show in locked view', () {
|
||||
final context = ActionButtonContext(
|
||||
asset: createRemoteAsset(type: AssetType.image),
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: true,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.timeline,
|
||||
);
|
||||
|
||||
expect(ActionButtonType.edit.shouldShow(context), isFalse);
|
||||
});
|
||||
|
||||
test('should not show for non-image assets', () {
|
||||
final context = ActionButtonContext(
|
||||
asset: createRemoteAsset(type: AssetType.video),
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.timeline,
|
||||
);
|
||||
|
||||
expect(ActionButtonType.edit.shouldShow(context), isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('shareLink button', () {
|
||||
test('should show when not in locked view and asset has remote', () {
|
||||
final remoteAsset = createRemoteAsset();
|
||||
@@ -961,5 +1014,53 @@ void main() {
|
||||
expect(archivedWidgets, isNotEmpty);
|
||||
expect(nonArchivedWidgets, isNotEmpty);
|
||||
});
|
||||
|
||||
test('should encode and parse quick action order consistently', () {
|
||||
final encoded = ActionButtonBuilder.encodeQuickActionOrder([
|
||||
ActionButtonType.edit,
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.archive,
|
||||
]);
|
||||
|
||||
final decoded = ActionButtonBuilder.parseQuickActionOrder(encoded);
|
||||
|
||||
final expectedOrder = ActionButtonBuilder.normalizeQuickActionOrder([
|
||||
ActionButtonType.edit,
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.archive,
|
||||
]);
|
||||
|
||||
expect(decoded, expectedOrder);
|
||||
});
|
||||
|
||||
test('should build quick actions honoring custom order', () {
|
||||
final remoteAsset = createRemoteAsset();
|
||||
final context = ActionButtonContext(
|
||||
asset: remoteAsset,
|
||||
isOwner: true,
|
||||
isArchived: false,
|
||||
isTrashEnabled: true,
|
||||
isInLockedView: false,
|
||||
currentAlbum: null,
|
||||
advancedTroubleshooting: false,
|
||||
isStacked: false,
|
||||
source: ActionSource.viewer,
|
||||
);
|
||||
|
||||
final quickActions = ActionButtonBuilder.buildQuickActions(
|
||||
context,
|
||||
quickActionOrder: const [
|
||||
ActionButtonType.archive,
|
||||
ActionButtonType.share,
|
||||
ActionButtonType.edit,
|
||||
ActionButtonType.delete,
|
||||
],
|
||||
);
|
||||
|
||||
expect(quickActions.length, ActionButtonBuilder.defaultQuickActionLimit);
|
||||
expect(quickActions.first, isA<ArchiveActionButton>());
|
||||
expect(quickActions[1], isA<ShareActionButton>());
|
||||
expect(quickActions[2], isA<EditImageActionButton>());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user