Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Trim memories viewer tests

ashilkn46e868dfda5f
diff --git a/mobile/apps/photos/test/db/social_db_test.dart b/mobile/apps/photos/test/db/social_db_test.dart
index c4161c342e..56c1347b59 100644
--- a/mobile/apps/photos/test/db/social_db_test.dart
+++ b/mobile/apps/photos/test/db/social_db_test.dart
@@ -31,54 +31,34 @@ void main() {
test("heart state stays inside the requested collection scope", () async {
await SocialDB.instance.upsertReactions([
- _reaction(id: "visible", collectionID: 10, userID: 1),
- _reaction(id: "hidden", collectionID: 20, userID: 2),
- _reaction(id: "deleted", collectionID: 20, userID: 3, isDeleted: true),
+ _reaction(id: "hidden", collectionID: 20, userID: 1),
+ _reaction(id: "deleted", collectionID: 20, userID: 2, isDeleted: true),
_reaction(
id: "comment-reaction",
collectionID: 10,
- userID: 4,
+ userID: 2,
commentID: "comment",
),
]);
expect(
await SocialDB.instance.hasUserReactedToFileInCollections(100, 1, [10]),
- isTrue,
- );
- expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 2, [10]),
isFalse,
);
expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 2, [20]),
- isTrue,
- );
- expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 2, [
+ await SocialDB.instance.hasUserReactedToFileInCollections(100, 1, [
10,
20,
]),
isTrue,
);
expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 3, [
- 10,
- 20,
- ]),
- isFalse,
- );
- expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 4, [
+ await SocialDB.instance.hasUserReactedToFileInCollections(100, 2, [
10,
20,
]),
isFalse,
);
- expect(
- await SocialDB.instance.hasUserReactedToFileInCollections(100, 1, []),
- isFalse,
- );
});
test("latest comment stays inside the eligible collection scope", () async {
@@ -91,20 +71,7 @@ void main() {
100,
candidateCollectionIDs: [10],
);
- final hiddenLatest = await SocialDB.instance.getLatestCommentForFile(
- 100,
- candidateCollectionIDs: [20],
- );
-
expect(visibleLatest?.id, "visible");
- expect(hiddenLatest?.id, "hidden");
- expect(
- await SocialDB.instance.getLatestCommentForFile(
- 100,
- candidateCollectionIDs: const [],
- ),
- isNull,
- );
});
test("comment count stays inside the requested collection scope", () async {
@@ -118,10 +85,6 @@ void main() {
await SocialDB.instance.getCommentCountForFileInCollections(100, [10]),
1,
);
- expect(
- await SocialDB.instance.getCommentCountForFileInCollections(100, [20]),
- 1,
- );
expect(
await SocialDB.instance.getCommentCountForFileInCollections(100, [
10,
@@ -129,10 +92,6 @@ void main() {
]),
2,
);
- expect(
- await SocialDB.instance.getCommentCountForFileInCollections(100, []),
- 0,
- );
});
}
diff --git a/mobile/apps/photos/test/ui/home/memories/memory_progress_indicator_test.dart b/mobile/apps/photos/test/ui/home/memories/memory_progress_indicator_test.dart
index ac604be905..d82499aaf2 100644
--- a/mobile/apps/photos/test/ui/home/memories/memory_progress_indicator_test.dart
+++ b/mobile/apps/photos/test/ui/home/memories/memory_progress_indicator_test.dart
@@ -3,99 +3,41 @@ import "package:flutter_test/flutter_test.dart";
import "package:photos/ui/home/memories/memory_progress_indicator.dart";
void main() {
- group("memory progress layout", () {
- test("derives equal segment widths from the available width", () {
- expect(
- memoryProgressSegmentWidthForLayout(totalSteps: 6, availableWidth: 343),
- closeTo(48.833333, 0.000001),
- );
- expect(
- memoryProgressSegmentWidthForLayout(
- totalSteps: 18,
- availableWidth: 343,
- ),
- closeTo(9.611111, 0.000001),
- );
- });
-
- test(
- "switches when equal chunks would be narrower than the legibility limit",
- () {
- expect(
- memoryProgressUsesContinuousTrack(
- totalSteps: 19,
- availableWidth: 343,
- ),
- isFalse,
- );
- expect(
- memoryProgressUsesContinuousTrack(
- totalSteps: 20,
- availableWidth: 343,
- ),
- isTrue,
- );
- expect(
- memoryProgressUsesContinuousTrack(
- totalSteps: 41,
- availableWidth: 736,
- ),
- isFalse,
- );
- expect(
- memoryProgressUsesContinuousTrack(
- totalSteps: 42,
- availableWidth: 736,
- ),
- isTrue,
- );
- },
- );
- });
-
- for (final availableWidth in [343.0, 736.0]) {
- for (final totalSteps in [6, 18]) {
- testWidgets("fills ${availableWidth}px with $totalSteps equal chunks", (
- tester,
- ) async {
- final currentIndex = totalSteps ~/ 2;
+ testWidgets("fills the available width with equal chunks", (tester) async {
+ const totalSteps = 6;
+ const availableWidth = 343.0;
+ const currentIndex = 3;
- await tester.pumpWidget(
- MaterialApp(
- home: Center(
- child: SizedBox(
- width: availableWidth,
- child: MemoryProgressIndicator(
- totalSteps: totalSteps,
- currentIndex: currentIndex,
- ),
- ),
+ await tester.pumpWidget(
+ const MaterialApp(
+ home: Center(
+ child: SizedBox(
+ width: availableWidth,
+ child: MemoryProgressIndicator(
+ totalSteps: totalSteps,
+ currentIndex: currentIndex,
),
),
- );
+ ),
+ ),
+ );
- expect(find.byType(Row), findsOneWidget);
- final widths = [
- for (var index = 0; index < totalSteps; index++)
- tester
- .getSize(find.byKey(ValueKey("memory-progress-segment-$index")))
- .width,
- ];
- final segmentWidth = widths.first;
- final currentWidth = widths[currentIndex];
+ final widths = [
+ for (var index = 0; index < totalSteps; index++)
+ tester
+ .getSize(find.byKey(ValueKey("memory-progress-segment-$index")))
+ .width,
+ ];
- expect(currentWidth / segmentWidth, closeTo(1.0, 0.000001));
- for (final width in widths) {
- expect(width, closeTo(segmentWidth, 0.000001));
- }
- expect(
- widths.reduce((left, right) => left + right) +
- ((totalSteps - 1) * kMemoryProgressGap),
- closeTo(availableWidth, 0.000001),
- );
- });
+ for (final width in widths.skip(1)) {
+ expect(width, widths.first);
}
- }
+ expect(
+ widths.reduce((left, right) => left + right) +
+ ((totalSteps - 1) * kMemoryProgressGap),
+ availableWidth,
+ );
+ });
testWidgets("uses the full track when segmented chunks become too narrow", (
tester,