Skip to content

High performance self-hosted photo and video management solution.

1.9 KB
Raw Blame
import 'package:flutter_test/flutter_test.dart';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/services/store.service.dart';
import 'package:immich_mobile/presentation/actions/action.widget.dart';
import 'package:immich_mobile/presentation/actions/asset_debug.action.dart';
import 'package:immich_ui/immich_ui.dart';

import '../../factories/remote_asset_factory.dart';
import '../presentation_context.dart';

void main() {
  late PresentationContext context;

  setUp(() async {
    context = await PresentationContext.create();
    await StoreService.I.put(StoreKey.advancedTroubleshooting, true);
  });

  tearDown(() async {
    await context.dispose();
  });

  group('AssetDebugAction', () {
    testWidgets('visible for a single asset when advanced troubleshooting is on', (tester) async {
      await tester.pumpTestWidget(
        context,
        const ActionIconButton(action: AssetDebugAction(source: .timeline)),
        overrides: context.selected({RemoteAssetFactory.create()}),
      );

      expect(find.byType(ImmichIconButton), findsOneWidget);
    });

    testWidgets('hidden for multiple assets', (tester) async {
      await tester.pumpTestWidget(
        context,
        const ActionIconButton(action: AssetDebugAction(source: .timeline)),
        overrides: context.selected({RemoteAssetFactory.create(), RemoteAssetFactory.create()}),
      );

      expect(find.byType(ImmichIconButton), findsNothing);
    });

    testWidgets('hidden when advanced troubleshooting is off', (tester) async {
      await StoreService.I.put(StoreKey.advancedTroubleshooting, false);

      await tester.pumpTestWidget(
        context,
        const ActionIconButton(action: AssetDebugAction(source: .timeline)),
        overrides: context.selected({RemoteAssetFactory.create()}),
      );

      expect(find.byType(ImmichIconButton), findsNothing);
    });
  });
}