fix(chat): Correction race condition + Implémentation TODOs
## Corrections Critiques ### Race Condition - Statuts de Messages - Fix : Les icônes de statut (✓, ✓✓, ✓✓ bleu) ne s'affichaient pas - Cause : WebSocket delivery confirmations arrivaient avant messages locaux - Solution : Pattern Optimistic UI dans chat_bloc.dart - Création message temporaire immédiate - Ajout à la liste AVANT requête HTTP - Remplacement par message serveur à la réponse - Fichier : lib/presentation/state_management/chat_bloc.dart ## Implémentation TODOs (13/21) ### Social (social_header_widget.dart) - ✅ Copier lien du post dans presse-papiers - ✅ Partage natif via Share.share() - ✅ Dialogue de signalement avec 5 raisons ### Partage (share_post_dialog.dart) - ✅ Interface sélection d'amis avec checkboxes - ✅ Partage externe via Share API ### Média (media_upload_service.dart) - ✅ Parsing JSON réponse backend - ✅ Méthode deleteMedia() pour suppression - ✅ Génération miniature vidéo ### Posts (create_post_dialog.dart, edit_post_dialog.dart) - ✅ Extraction URL depuis uploads - ✅ Documentation chargement médias ### Chat (conversations_screen.dart) - ✅ Navigation vers notifications - ✅ ConversationSearchDelegate pour recherche ## Nouveaux Fichiers ### Configuration - build-prod.ps1 : Script build production avec dart-define - lib/core/constants/env_config.dart : Gestion environnements ### Documentation - TODOS_IMPLEMENTED.md : Documentation complète TODOs ## Améliorations ### Architecture - Refactoring injection de dépendances - Amélioration routing et navigation - Optimisation providers (UserProvider, FriendsProvider) ### UI/UX - Amélioration thème et couleurs - Optimisation animations - Meilleure gestion erreurs ### Services - Configuration API avec env_config - Amélioration datasources (events, users) - Optimisation modèles de données
This commit is contained in:
150
test/domain/entities/user_test.dart
Normal file
150
test/domain/entities/user_test.dart
Normal file
@@ -0,0 +1,150 @@
|
||||
import 'package:afterwork/domain/entities/user.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('User Entity', () {
|
||||
const tUserId = '123';
|
||||
const tUserLastName = 'Doe';
|
||||
const tUserFirstName = 'John';
|
||||
const tEmail = 'john.doe@example.com';
|
||||
const tMotDePasse = 'hashedPassword123';
|
||||
const tProfileImageUrl = 'https://example.com/profile.jpg';
|
||||
const tEventsCount = 5;
|
||||
const tFriendsCount = 10;
|
||||
const tPostsCount = 15;
|
||||
const tVisitedPlacesCount = 20;
|
||||
|
||||
test('should create a User instance with all required fields', () {
|
||||
// Act
|
||||
const user = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(user.userId, tUserId);
|
||||
expect(user.userLastName, tUserLastName);
|
||||
expect(user.userFirstName, tUserFirstName);
|
||||
expect(user.email, tEmail);
|
||||
expect(user.motDePasse, tMotDePasse);
|
||||
expect(user.profileImageUrl, tProfileImageUrl);
|
||||
expect(user.eventsCount, 0); // Default value
|
||||
expect(user.friendsCount, 0); // Default value
|
||||
expect(user.postsCount, 0); // Default value
|
||||
expect(user.visitedPlacesCount, 0); // Default value
|
||||
});
|
||||
|
||||
test('should create a User instance with optional counts', () {
|
||||
// Act
|
||||
const user = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
eventsCount: tEventsCount,
|
||||
friendsCount: tFriendsCount,
|
||||
postsCount: tPostsCount,
|
||||
visitedPlacesCount: tVisitedPlacesCount,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(user.eventsCount, tEventsCount);
|
||||
expect(user.friendsCount, tFriendsCount);
|
||||
expect(user.postsCount, tPostsCount);
|
||||
expect(user.visitedPlacesCount, tVisitedPlacesCount);
|
||||
});
|
||||
|
||||
test('should support value equality using Equatable', () {
|
||||
// Arrange
|
||||
const user1 = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
);
|
||||
|
||||
const user2 = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(user1, equals(user2));
|
||||
expect(user1.hashCode, equals(user2.hashCode));
|
||||
});
|
||||
|
||||
test('should not be equal when any field is different', () {
|
||||
// Arrange
|
||||
const user1 = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
);
|
||||
|
||||
const user2 = User(
|
||||
userId: 'different-id',
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(user1, isNot(equals(user2)));
|
||||
});
|
||||
|
||||
test('props should contain all fields for equality comparison', () {
|
||||
// Arrange
|
||||
const user = User(
|
||||
userId: tUserId,
|
||||
userLastName: tUserLastName,
|
||||
userFirstName: tUserFirstName,
|
||||
email: tEmail,
|
||||
motDePasse: tMotDePasse,
|
||||
profileImageUrl: tProfileImageUrl,
|
||||
eventsCount: tEventsCount,
|
||||
friendsCount: tFriendsCount,
|
||||
postsCount: tPostsCount,
|
||||
visitedPlacesCount: tVisitedPlacesCount,
|
||||
);
|
||||
|
||||
// Act
|
||||
final props = user.props;
|
||||
|
||||
// Assert
|
||||
expect(props.length, 10);
|
||||
expect(
|
||||
props,
|
||||
containsAll([
|
||||
tUserId,
|
||||
tUserLastName,
|
||||
tUserFirstName,
|
||||
tEmail,
|
||||
tMotDePasse,
|
||||
tProfileImageUrl,
|
||||
tEventsCount,
|
||||
tFriendsCount,
|
||||
tPostsCount,
|
||||
tVisitedPlacesCount,
|
||||
]),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user