Files
buzz/mobile/test/features/channels/camera_capture_cleanup_test.dart
klopez4212 a3b097745a Refine mobile attachment picking (#3313)
## What
- morph the composer plus button into the attachment menu, camera, and
photo surfaces
- add ordered multi-select with inline recent photos and system picker
fallback
- add native iOS attachment/photo popovers and align the Android camera
treatment

## Stack
- follows #3312

## Validation
- `just mobile-check`
- `flutter test test/features/channels/compose_bar_test.dart`
- full mobile pre-push suite

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
2026-07-28 18:05:43 +01:00

55 lines
1.5 KiB
Dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker/image_picker.dart';
import 'package:buzz/features/channels/camera_capture_cleanup.dart';
void main() {
test('deletes the inline camera file after upload succeeds', () async {
final file = File(
'${Directory.systemTemp.path}/buzz-camera-${DateTime.now().microsecondsSinceEpoch}.jpg',
);
await file.writeAsBytes([1, 2, 3]);
await processCapturedImage(XFile(file.path), (_) async {});
expect(await file.exists(), isFalse);
});
test('deletes the inline camera file when upload fails', () async {
final file = File(
'${Directory.systemTemp.path}/buzz-camera-${DateTime.now().microsecondsSinceEpoch}.jpg',
);
await file.writeAsBytes([1, 2, 3]);
await expectLater(
processCapturedImage(
XFile(file.path),
(_) async => throw Exception('upload failed'),
),
throwsException,
);
expect(await file.exists(), isFalse);
});
test('deletes every native picker file after processing', () async {
final suffix = DateTime.now().microsecondsSinceEpoch;
final files = [
File('${Directory.systemTemp.path}/buzz-photo-$suffix-1.jpg'),
File('${Directory.systemTemp.path}/buzz-photo-$suffix-2.jpg'),
];
for (final file in files) {
await file.writeAsBytes([1, 2, 3]);
}
await processTemporaryImages([
for (final file in files) XFile(file.path),
], (_) async {});
for (final file in files) {
expect(await file.exists(), isFalse);
}
});
}