fix: show date on memories page (#32245)
fix: show date on memories page (#32206) * fix: show date on memories page * Clean up API * Drop imports --------- (cherry picked from commit 108a3cadbfe3b3e4305c04d8e4217aafb445f626) Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Adam Gastineau <adam@agg.im>
This commit is contained in:
co-authored by
Alex
Adam Gastineau
parent
5b2a3a52be
commit
f6fc530734
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/domain/models/memory.model.dart';
|
||||
import 'package:immich_mobile/presentation/pages/memory_list.page.dart';
|
||||
import 'package:immich_mobile/providers/infrastructure/memory.provider.dart';
|
||||
|
||||
import '../factories/remote_asset_factory.dart';
|
||||
import 'presentation_context.dart';
|
||||
|
||||
void main() {
|
||||
late PresentationContext context;
|
||||
|
||||
setUp(() async => context = await PresentationContext.create());
|
||||
tearDown(() async => await context.dispose());
|
||||
|
||||
Memory newMemory({required MemoryTypeEnum type, required DateTime memoryAt, String? personName}) => Memory(
|
||||
id: 'memory-${memoryAt.toIso8601String()}',
|
||||
createdAt: DateTime(2026),
|
||||
updatedAt: DateTime(2026),
|
||||
ownerId: 'user-1',
|
||||
type: type,
|
||||
data: MemoryData(year: memoryAt.year, personName: personName),
|
||||
isSaved: false,
|
||||
memoryAt: memoryAt,
|
||||
assets: [RemoteAssetFactory.create()],
|
||||
);
|
||||
|
||||
Future<void> pumpPage(WidgetTester tester, List<Memory> memories) => tester.pumpTestWidget(
|
||||
context,
|
||||
const MemoryListPage(),
|
||||
overrides: [allMemoriesProvider(false).overrideWith((ref) => memories)],
|
||||
expectSettle: false,
|
||||
);
|
||||
|
||||
group('MemoryListPage', () {
|
||||
testWidgets('shows the date of each on this day memory', (tester) async {
|
||||
await pumpPage(tester, [
|
||||
newMemory(type: MemoryTypeEnum.onThisDay, memoryAt: DateTime(2025, 10, 7)),
|
||||
newMemory(type: MemoryTypeEnum.onThisDay, memoryAt: DateTime(2025, 10, 6)),
|
||||
]);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('October 7, 2025'), findsOneWidget);
|
||||
expect(find.text('October 6, 2025'), findsOneWidget);
|
||||
expect(find.textContaining('ago'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('shows the person name for a birthday memory', (tester) async {
|
||||
await pumpPage(tester, [
|
||||
newMemory(type: MemoryTypeEnum.birthday, memoryAt: DateTime(2025, 10, 7), personName: 'Alice'),
|
||||
]);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text("Alice's birthday"), findsOneWidget);
|
||||
expect(find.text('October 7, 2025'), findsNothing);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user