Skip to content

armgit / ente

Public Imported from GitHub
0

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

Focus avatar identity coverage

Neeraj Gupta5645e8f3bc48
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
new file mode 100644
index 0000000000..c4904f40cb
--- /dev/null
+++ b/mobile/apps/photos/test/ui/viewer/file_details/added_by_widget_test.dart
@@ -0,0 +1,31 @@
+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 55fb8fb253..64293fc6f4 100644
--- a/mobile/apps/photos/test/utils/avatar_util_test.dart
+++ b/mobile/apps/photos/test/utils/avatar_util_test.dart
@@ -4,16 +4,18 @@ import "package:flutter_test/flutter_test.dart";
import "package:photos/utils/avatar_util.dart";
void main() {
- test("prefers normalized email for avatar identity", () {
- expect(
- avatarIdentityKey(
- email: " [email protected] ",
- userID: 7,
- personID: "person-1",
- name: "Alice",
- ),
+ test("email identity is normalized and independent of the label", () {
+ final before = AvatarIdentity(
+ label: "Alice",
+ email: " [email protected] ",
+ userID: 7,
+ personID: "person-1",
);
+ final after = AvatarIdentity(label: "Bob", email: "[email protected]");
+
+ expect(before.key, "email:[email protected]");
+ expect(after.key, before.key);
+ expect(after.initial, "B");
});
test("falls back through stable IDs before name", () {
@@ -33,17 +35,6 @@ void main() {
expect(avatarIdentityKey(name: " Alice Smith "), "name:alice smith");
});
- test("display name changes do not change email identity", () {
- final before = AvatarIdentity(label: "Alice", email: "[email protected]");
- final after = AvatarIdentity(
- label: "Alice Smith",
- email: "[email protected]",
- );
-
- expect(after.key, before.key);
- expect(after.initial, "A");
- });
-
test("marks the signed-in email as the current-user role", () {
final identity = AvatarIdentity.account(
label: "Alice",
@@ -56,19 +47,6 @@ void main() {
expect(identity.key, "email:[email protected]");
});
- test("uses the saved person ID when no account identity exists", () {
- final identity = AvatarIdentity.account(
- label: "Alice",
- email: null,
- userID: null,
- personID: "person-1",
- currentUserEmail: "[email protected]",
- );
-
- expect(identity.role, AvatarIdentityRole.standard);
- expect(identity.key, "person:person-1");
- });
-
testWidgets("semantic avatar roles stay black across themes", (tester) async {
for (final theme in [
ComponentTheme.lightTheme(),