Skip to content

armgit / ente

Public Imported from GitHub
0

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

Trim low-value avatar tests

Neeraj Gupta381c9dcc5367
diff --git a/mobile/apps/photos/test/ui/viewer/file_details/added_by_widget_test.dart b/mobile/apps/photos/test/ui/viewer/file_details/added_by_widget_test.dart
deleted file mode 100644
index c4904f40cb..0000000000
--- a/mobile/apps/photos/test/ui/viewer/file_details/added_by_widget_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-import "package:ente_components/ente_components.dart";
-import "package:flutter/material.dart";
-import "package:flutter_test/flutter_test.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/models/file/file.dart";
-import "package:photos/models/metadata/file_magic.dart";
-import "package:photos/ui/viewer/file_details/added_by_widget.dart";
-
-void main() {
- testWidgets("public uploader avatar stays black", (tester) async {
- final file = EnteFile()
- ..uploadedFileID = 1
- ..pubMagicMetadata = PubMagicMetadata(uploaderName: "Guest");
-
- await tester.pumpWidget(
- MaterialApp(
- theme: ComponentTheme.lightTheme(),
- localizationsDelegates: AppLocalizations.localizationsDelegates,
- supportedLocales: AppLocalizations.supportedLocales,
- home: Scaffold(body: AddedByWidget(file)),
- ),
- );
-
- final avatar = tester.widget<DecoratedBox>(
- find
- .ancestor(of: find.text("G"), matching: find.byType(DecoratedBox))
- .first,
- );
- expect((avatar.decoration as BoxDecoration).color, Colors.black);
- });
-}
diff --git a/mobile/apps/photos/test/utils/avatar_util_test.dart b/mobile/apps/photos/test/utils/avatar_util_test.dart
index 2ff3df0fd4..15a073e392 100644
--- a/mobile/apps/photos/test/utils/avatar_util_test.dart
+++ b/mobile/apps/photos/test/utils/avatar_util_test.dart
@@ -1,5 +1,3 @@
-import "package:ente_components/ente_components.dart";
-import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
import "package:photos/utils/avatar_util.dart";
@@ -21,7 +19,7 @@ void main() {
expect(before.key, "email:[email protected]");
expect(after.key, before.key);
- expect(after.initial, "B");
+ expect(before.role, AvatarIdentityRole.standard);
});
test("falls back through stable IDs before name", () {
@@ -72,35 +70,4 @@ void main() {
expect(identity.role, AvatarIdentityRole.currentUser);
expect(identity.key, "email:[email protected]");
});
-
- testWidgets("semantic avatar roles stay black across themes", (tester) async {
- for (final theme in [
- ComponentTheme.lightTheme(),
- ComponentTheme.darkTheme(),
- ]) {
- for (final identity in [
- AvatarIdentity.account(
- label: "A",
- email: "[email protected]",
- userID: 7,
- currentUserEmail: "[email protected]",
- ),
- AvatarIdentity.publicUploader(label: "A"),
- ]) {
- late Color backgroundColor;
- await tester.pumpWidget(
- MaterialApp(
- theme: theme,
- home: Builder(
- builder: (context) {
- backgroundColor = avatarBackgroundColor(context, identity);
- return const SizedBox.shrink();
- },
- ),
- ),
- );
- expect(backgroundColor, Colors.black);
- }
- }
- });
}
diff --git a/mobile/packages/ente_components/test/components/avatar_test.dart b/mobile/packages/ente_components/test/components/avatar_test.dart
index 84fa7f6312..a4922f2bbe 100644
--- a/mobile/packages/ente_components/test/components/avatar_test.dart
+++ b/mobile/packages/ente_components/test/components/avatar_test.dart
@@ -63,10 +63,6 @@ void main() {
color: AvatarComponentColor.cyan,
),
const AvatarComponent.seeded(initials: 'A', seed: 0),
- const AvatarComponent(
- initials: 'P',
- color: AvatarComponentColor.black,
- ),
],
),
),
@@ -76,7 +72,6 @@ void main() {
expect(find.text('K'), findsOneWidget);
expect(find.text('C'), findsOneWidget);
expect(find.text('A'), findsOneWidget);
- expect(find.text('P'), findsOneWidget);
expect(avatarLight.length, avatarDark.length);
final cyanAvatar = tester.widget<DecoratedBox>(
@@ -85,45 +80,13 @@ void main() {
.first,
);
expect((cyanAvatar.decoration as BoxDecoration).color, avatarCyan);
- final blackAvatar = tester.widget<DecoratedBox>(
- find
- .ancestor(of: find.text('P'), matching: find.byType(DecoratedBox))
- .first,
- );
- expect((blackAvatar.decoration as BoxDecoration).color, Colors.black);
},
);
-
- testWidgets('identity colors use the theme palette at a stable index', (
- tester,
- ) async {
- const identityKey = '[email protected]';
- final paletteIndex =
- avatarSeedForIdentity(identityKey) % avatarLight.length;
- for (final (theme, palette) in [
- (ComponentTheme.lightTheme(), avatarLight),
- (ComponentTheme.darkTheme(), avatarDark),
- ]) {
- late Color color;
- await tester.pumpWidget(
- _wrap(
- Builder(
- builder: (context) {
- color = avatarColorForIdentity(context, identityKey);
- return const SizedBox.shrink();
- },
- ),
- theme: theme,
- ),
- );
- expect(color, palette[paletteIndex]);
- }
- });
}
-Widget _wrap(Widget child, {ThemeData? theme}) {
+Widget _wrap(Widget child) {
return MaterialApp(
- theme: theme ?? ComponentTheme.lightTheme(),
+ theme: ComponentTheme.lightTheme(),
home: Scaffold(body: Center(child: child)),
);
}