Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune duplicate test coverage

Manav Rathi52f07b1fee70
diff --git a/mobile/apps/photos/test/models/gallery_group_type_test.dart b/mobile/apps/photos/test/models/gallery_group_type_test.dart
index b873f8e7a3..11c1b00355 100644
--- a/mobile/apps/photos/test/models/gallery_group_type_test.dart
+++ b/mobile/apps/photos/test/models/gallery_group_type_test.dart
@@ -20,41 +20,6 @@ void main() {
sundayFinalMicrosecond.microsecondsSinceEpoch,
));
});
-
- test("excludes the previous Sunday and following Monday", () {
- final monday = DateTime(2026, 8, 17);
- final previousSundayFinalMicrosecond = monday.subtract(
- const Duration(microseconds: 1),
- );
- final nextMonday = DateTime(2026, 8, 24);
- final range = GroupType.week.getGroupRange(_fileAt(monday));
-
- expect(
- previousSundayFinalMicrosecond.microsecondsSinceEpoch,
- lessThan(range.$1),
- );
- expect(nextMonday.microsecondsSinceEpoch, greaterThan(range.$2));
- });
-
- test("groups Monday morning and Sunday evening together", () {
- final mondayMorning = DateTime(2026, 8, 17, 9);
- final sundayEvening = DateTime(2026, 8, 23, 18);
-
- expect(
- GroupType.week.getGroupRange(_fileAt(mondayMorning)),
- GroupType.week.getGroupRange(_fileAt(sundayEvening)),
- );
- });
-
- test("normalizes weeks across year boundaries", () {
- final sunday = DateTime(2026, 1, 4, 23, 59, 59, 999, 999);
- final range = GroupType.week.getGroupRange(_fileAt(sunday));
-
- expect(range, (
- DateTime(2025, 12, 29).microsecondsSinceEpoch,
- DateTime(2026, 1, 5).microsecondsSinceEpoch - 1,
- ));
- });
});
}
diff --git a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart
index 18286b4b4e..f3d5f43cb6 100644
--- a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart
+++ b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart
@@ -126,17 +126,6 @@ void main() {
expect(contactsService.lastUpdatedName, "Alex R");
});
- test("updateAttributes does not sync unchanged person name", () async {
- final updated = await personService.updateAttributes(
- "person-1",
- name: "Alex",
- );
-
- expect(updated.data.name, "Alex");
- expect(contactsService.createOrUpdateCalls, 0);
- expect(contactsService.lastUpdatedName, isNull);
- });
-
test(
"does not auto-create a contact without a configured person avatar",
() async {
diff --git a/mobile/apps/photos/test/services/photos_contacts_service_test.dart b/mobile/apps/photos/test/services/photos_contacts_service_test.dart
index 08be678289..6119dd86d5 100644
--- a/mobile/apps/photos/test/services/photos_contacts_service_test.dart
+++ b/mobile/apps/photos/test/services/photos_contacts_service_test.dart
@@ -61,34 +61,6 @@ void main() {
);
});
- test('debugOpenAndSync hydrates local cache even when sync fails', () async {
- await service.debugOpenAndSync(session);
-
- expect(service.hasHydratedCache, isTrue);
- expect(service.getCachedContact(contactUserId: 7), isNotNull);
- expect((await service.getContact(email: '[email protected]'))?.id, 'ct_1');
- expect(service.getCachedSavedName(contactUserId: 7), 'Alice');
- expect(service.getCachedSavedName(email: '[email protected]'), 'Alice');
- expect(service.getCachedResolvedEmail(contactUserId: 7), '[email protected]');
- expect(service.getCachedContacts().single.contactUserId, 7);
- expect(
- service.getCachedResolvedEmail(email: '[email protected]'),
- );
- expect(contactsService.openCalls, 1);
- expect(contactsService.syncCalls, 1);
- });
-
- test('user id lookup does not fall back to email', () async {
- await service.debugOpenAndSync(session);
-
- expect(
- await service.getContact(contactUserId: 99, email: '[email protected]'),
- isNull,
- );
- expect((await service.getContact(email: '[email protected]'))?.id, 'ct_1');
- });
-
test('deletion tombstone evicts contact indexes', () async {
await service.debugOpenAndSync(session);
@@ -110,67 +82,6 @@ void main() {
expect(service.getCachedContacts(), isEmpty);
});
- test(
- 'stale in-flight debugOpenAndSync does not repopulate cache after session switch',
- () async {
- contactsService.getContactsBarrier = Completer<void>();
- contactsService.getContactsStarted = Completer<void>();
- contactsService.localContactsPages =
- Queue<List<contacts.ContactRecord>>.of([
- const [
- contacts.ContactRecord(
- id: 'ct_old',
- contactUserId: 7,
- email: '[email protected]',
- data: contacts.ContactData(contactUserId: 7, name: 'Alice'),
- profilePictureAttachmentId: null,
- isDeleted: false,
- createdAt: 1,
- updatedAt: 2,
- ),
- ],
- const [
- contacts.ContactRecord(
- id: 'ct_new',
- contactUserId: 9,
- email: '[email protected]',
- data: contacts.ContactData(contactUserId: 9, name: 'Bob'),
- profilePictureAttachmentId: null,
- isDeleted: false,
- createdAt: 3,
- updatedAt: 4,
- ),
- ],
- ]);
- contactsService.syncPages = Queue<List<contacts.ContactRecord>>.of([
- const [],
- const [],
- ]);
-
- final oldOpenAndSync = service.debugOpenAndSync(session);
- await contactsService.getContactsStarted!.future;
-
- final nextSession = contacts.ContactsSession(
- baseUrl: session.baseUrl,
- authToken: 'token-2',
- userId: 2,
- accountKey: Uint8List.fromList([9, 9, 9]),
- );
- await service.debugOpenAndSync(nextSession);
-
- expect(service.getCachedSavedName(contactUserId: 9), 'Bob');
- expect(service.getCachedSavedName(contactUserId: 7), isNull);
-
- contactsService.getContactsBarrier!.complete();
- await oldOpenAndSync;
-
- expect(service.getCachedSavedName(contactUserId: 9), 'Bob');
- expect(service.getCachedResolvedEmail(contactUserId: 9), '[email protected]');
- expect(service.getCachedSavedName(contactUserId: 7), isNull);
- expect(service.getCachedResolvedEmail(contactUserId: 7), isNull);
- },
- );
-
test('session switch creates a fresh contacts service instance', () async {
final firstService = FakeContactsService(
localContacts: const [
@@ -295,16 +206,10 @@ class FakeContactsService extends Fake implements contacts.ContactsService {
final List<contacts.ContactRecord> localContacts;
final List<contacts.ContactRecord> syncDiff;
final Object? syncError;
- Queue<List<contacts.ContactRecord>>? localContactsPages;
- Queue<List<contacts.ContactRecord>>? syncPages;
final Map<String, Uint8List> profilePictureBytesByContactId = {};
Completer<void>? openBarrier;
Completer<void>? openStarted;
- Completer<void>? getContactsBarrier;
- Completer<void>? getContactsStarted;
int openCalls = 0;
- int syncCalls = 0;
- int getContactsCalls = 0;
int getProfilePictureCalls = 0;
@override
@@ -323,22 +228,7 @@ class FakeContactsService extends Fake implements contacts.ContactsService {
@override
Future<List<contacts.ContactRecord>> getContacts({
bool includeDeleted = false,
- }) async {
- getContactsCalls += 1;
- final pages = localContactsPages;
- final response = pages != null && pages.isNotEmpty
- ? pages.removeFirst()
- : localContacts;
- final started = getContactsStarted;
- if (started != null && !started.isCompleted) {
- started.complete();
- }
- final barrier = getContactsBarrier;
- if (getContactsCalls == 1 && barrier != null && !barrier.isCompleted) {
- await barrier.future;
- }
- return response;
- }
+ }) async => localContacts;
@override
Future<contacts.ContactRecord?> getContactByUserId(
@@ -356,11 +246,6 @@ class FakeContactsService extends Fake implements contacts.ContactsService {
@override
Future<List<contacts.ContactRecord>> sync() async {
- syncCalls += 1;
- final pages = syncPages;
- if (pages != null && pages.isNotEmpty) {
- return pages.removeFirst();
- }
final error = syncError;
if (error != null) {
throw error;
diff --git a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
index 78cc74467c..8bae5175a4 100644
--- a/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
+++ b/mobile/apps/photos/test/ui/components/action_sheet_widget_test.dart
@@ -10,38 +10,6 @@ import "package:photos/ui/components/models/button_type.dart";
void main() {
group("showActionSheet", () {
- testWidgets("returns the tapped button action", (tester) async {
- ButtonResult? result;
-
- await _pumpLauncher(tester, (context) async {
- result = await showActionSheet(
- context: context,
- buttons: const [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: "Confirm",
- isInAlert: true,
- buttonAction: ButtonAction.first,
- ),
- ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: "Cancel",
- isInAlert: true,
- buttonAction: ButtonAction.cancel,
- ),
- ],
- );
- });
-
- await _openLauncher(tester);
- await tester.tap(find.text("Confirm"));
- await tester.pumpAndSettle();
-
- expect(result?.action, ButtonAction.first);
- expect(result?.exception, isNull);
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
-
testWidgets("returns the cancel action from the close button", (
tester,
) async {
@@ -76,34 +44,6 @@ void main() {
expect(find.byType(BottomSheetComponent), findsNothing);
});
- testWidgets("returns null when dismissed", (tester) async {
- ButtonResult? result;
- var completed = false;
-
- await _pumpLauncher(tester, (context) async {
- result = await showActionSheet(
- context: context,
- buttons: const [
- ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: "Cancel",
- isInAlert: true,
- buttonAction: ButtonAction.cancel,
- ),
- ],
- );
- completed = true;
- });
-
- await _openLauncher(tester);
- await tester.tapAt(const Offset(10, 10));
- await tester.pumpAndSettle();
-
- expect(completed, isTrue);
- expect(result, isNull);
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
-
testWidgets("preserves the legacy success confirmation delay", (
tester,
) async {
diff --git a/mobile/apps/photos/test/ui/components/dialog_widget_test.dart b/mobile/apps/photos/test/ui/components/dialog_widget_test.dart
index be772ab7eb..9a4f99abf7 100644
--- a/mobile/apps/photos/test/ui/components/dialog_widget_test.dart
+++ b/mobile/apps/photos/test/ui/components/dialog_widget_test.dart
@@ -11,97 +11,6 @@ import "package:photos/utils/dialog_util.dart";
void main() {
group("showDialogWidget", () {
- testWidgets("returns the tapped button action", (tester) async {
- ButtonResult? result;
-
- await _pumpLauncher(tester, (context) async {
- result = await showDialogWidget(
- context: context,
- title: "Confirm",
- buttons: const [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: "Continue",
- isInAlert: true,
- buttonAction: ButtonAction.first,
- ),
- ],
- );
- });
-
- await _openLauncher(tester);
- await tester.tap(find.text("Continue"));
- await tester.pumpAndSettle();
-
- expect(result?.action, ButtonAction.first);
- expect(result?.exception, isNull);
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
-
- testWidgets("returns the cancel action from the close button", (
- tester,
- ) async {
- ButtonResult? result;
-
- await _pumpLauncher(tester, (context) async {
- result = await showDialogWidget(
- context: context,
- title: "Confirm",
- buttons: const [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: "Continue",
- isInAlert: true,
- buttonAction: ButtonAction.first,
- ),
- ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: "Cancel",
- isInAlert: true,
- buttonAction: ButtonAction.second,
- ),
- ],
- );
- });
-
- await _openLauncher(tester);
- await tester.tap(find.byTooltip("Close"));
- await tester.pumpAndSettle();
-
- expect(result?.action, ButtonAction.second);
- expect(result?.exception, isNull);
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
-
- testWidgets("returns null when dismissed", (tester) async {
- ButtonResult? result;
- var completed = false;
-
- await _pumpLauncher(tester, (context) async {
- result = await showDialogWidget(
- context: context,
- title: "Dismissible",
- buttons: const [
- ButtonWidget(
- buttonType: ButtonType.secondary,
- labelText: "Cancel",
- isInAlert: true,
- buttonAction: ButtonAction.cancel,
- ),
- ],
- );
- completed = true;
- });
-
- await _openLauncher(tester);
- await tester.tapAt(const Offset(10, 10));
- await tester.pumpAndSettle();
-
- expect(completed, isTrue);
- expect(result, isNull);
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
-
testWidgets("honors non-dismissible sheets", (tester) async {
await _pumpLauncher(
tester,
@@ -130,38 +39,6 @@ void main() {
await tester.pumpAndSettle();
expect(find.byType(BottomSheetComponent), findsNothing);
});
-
- testWidgets("returns an error result when a button callback throws", (
- tester,
- ) async {
- ButtonResult? result;
-
- await _pumpLauncher(tester, (context) async {
- result = await showDialogWidget(
- context: context,
- title: "Failure",
- buttons: [
- ButtonWidget(
- buttonType: ButtonType.neutral,
- labelText: "Fail",
- isInAlert: true,
- buttonAction: ButtonAction.first,
- onTap: () async {
- throw StateError("boom");
- },
- ),
- ],
- );
- });
-
- await _openLauncher(tester);
- await tester.tap(find.text("Fail"));
- await tester.pumpAndSettle();
-
- expect(result?.action, ButtonAction.error);
- expect(result?.exception, isA<Exception>());
- expect(find.byType(BottomSheetComponent), findsNothing);
- });
});
group("showTextInputDialog", () {
diff --git a/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart b/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
index d962ce5ee7..f6b6888db4 100644
--- a/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
+++ b/mobile/packages/backup_exclusion/test/backup_exclusion_test.dart
@@ -37,26 +37,6 @@ void main() {
},
);
- test('logs a warning when the channel returns false', () async {
- TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
- .setMockMethodCallHandler(channel, (_) async => false);
-
- final logs = <LogRecord>[];
- final sub = Logger('BackupExclusion').onRecord.listen(logs.add);
-
- await invokeExcludeFromBackup(testPath);
-
- await sub.cancel();
- expect(
- logs.any(
- (r) =>
- r.level == Level.WARNING &&
- r.message.contains('excludeFromBackup returned false'),
- ),
- isTrue,
- );
- });
-
test('logs a warning when the channel throws PlatformException', () async {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (_) async {
diff --git a/mobile/packages/contacts/test/contacts_service_test.dart b/mobile/packages/contacts/test/contacts_service_test.dart
index b82e3440a9..07712c6803 100644
--- a/mobile/packages/contacts/test/contacts_service_test.dart
+++ b/mobile/packages/contacts/test/contacts_service_test.dart
@@ -180,28 +180,6 @@ void main() {
expect(await database.getCachedAttachment('att_profile'), isNull);
});
- test(
- 'getContactByUserId resolves cached contact without scanning all rows',
- () async {
- await service.open(
- ContactsSession(
- baseUrl: 'http://localhost:8080',
- authToken: 'token',
- userId: 1,
- accountKey: Uint8List.fromList([1, 2, 3]),
- ),
- );
-
- final created = await service.createContact(
- const ContactData(contactUserId: 42, name: 'Douglas'),
- );
-
- final cached = await service.getContactByUserId(42);
- expect(cached?.id, created.id);
- expect(cached?.data?.name, 'Douglas');
- },
- );
-
test('open can resolve account key from provider', () async {
await service.open(
ContactsSession(
diff --git a/mobile/packages/ente_components/test/components/button_test.dart b/mobile/packages/ente_components/test/components/button_test.dart
index 650b896f5f..6d17609096 100644
--- a/mobile/packages/ente_components/test/components/button_test.dart
+++ b/mobile/packages/ente_components/test/components/button_test.dart
@@ -195,28 +195,6 @@ void main() {
},
);
- testWidgets("ButtonComponent does not dismiss modal routes by default", (
- tester,
- ) async {
- await tester.pumpWidget(
- _wrapModalTestApp(
- child: ButtonComponent(
- label: "Stay",
- shouldSurfaceExecutionStates: false,
- onTap: () {},
- ),
- ),
- );
-
- await tester.tap(find.text("Open"));
- await tester.pumpAndSettle();
-
- await tester.tap(find.text("Stay"));
- await tester.pumpAndSettle();
-
- expect(find.text("Stay"), findsOneWidget);
- });
-
testWidgets(
"ButtonComponent does not dismiss normal page routes when configured",
(tester) async {
diff --git a/server/pkg/controller/push_test.go b/server/pkg/controller/push_test.go
index 39328c3d53..3b2d54b4f7 100644
--- a/server/pkg/controller/push_test.go
+++ b/server/pkg/controller/push_test.go
@@ -159,14 +159,6 @@ func TestFCMSendDoesNotClassifyInvalidArgumentAsUnregistered(t *testing.T) {
require.False(t, errors.Is(err, errUnregisteredToken))
}
-func TestFCMErrorCode(t *testing.T) {
- require.Equal(t, "UNREGISTERED", fcmErrorCode([]byte(fcmUnregisteredBody)))
- require.Equal(t, "INVALID_ARGUMENT", fcmErrorCode([]byte(fcmInvalidArgumentBody)))
- require.Equal(t, "", fcmErrorCode([]byte(`{"error":"bad"}`)))
- require.Equal(t, "", fcmErrorCode([]byte("not json")))
- require.Equal(t, "", fcmErrorCode(nil))
-}
-
func captureLogs(t *testing.T) *logtest.Hook {
t.Helper()
logger := log.StandardLogger()
diff --git a/server/pkg/utils/ua/ua_test.go b/server/pkg/utils/ua/ua_test.go
index 630e889511..62e87ec343 100644
--- a/server/pkg/utils/ua/ua_test.go
+++ b/server/pkg/utils/ua/ua_test.go
@@ -5,16 +5,6 @@ import (
"testing"
)
-func TestGetDeviceType(t *testing.T) {
- deviceType, err := GetDeviceType("Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1")
- if err != nil {
- t.Fatalf("GetDeviceType returned error: %v", err)
- }
- if deviceType != "Smartphone" {
- t.Fatalf("GetDeviceType = %q, want %q", deviceType, "Smartphone")
- }
-}
-
func TestGetDeviceTypeReturnsErrorForUnparsableUserAgent(t *testing.T) {
deviceType, err := GetDeviceType("")
if err == nil {
diff --git a/web/apps/photos/tests/ml-index-flags.test.ts b/web/apps/photos/tests/ml-index-flags.test.ts
deleted file mode 100644
index 800eaac595..0000000000
--- a/web/apps/photos/tests/ml-index-flags.test.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { mlIndexFlagsForRustResult } from "ente-new/photos/services/ml/index-flags";
-import { describe, expect, test } from "vitest";
-
-describe("ML index runtime flags", () => {
- test.each([
- [false, false, 1],
- [true, false, 3],
- [false, true, 5],
- [true, true, 7],
- ])(
- "encodes CoreML=%s and WebGPU=%s as %d",
- (usedCoreml, usedWebgpu, expected) => {
- expect(mlIndexFlagsForRustResult({ usedCoreml, usedWebgpu })).toBe(
- expected,
- );
- },
- );
-});