Skip to content

Commit

Permalink
test: adicionar testes para a UserProfilePage
Browse files Browse the repository at this point in the history
  • Loading branch information
shonorio committed Jan 13, 2025
1 parent 274c73b commit 7aa16ea
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions test/app/features/users/presentation/user_profile_page_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:penhas/app/features/chat/domain/usecases/get_chat_channel_token_usecase.dart';
import 'package:penhas/app/features/users/domain/entities/user_detail_entity.dart';
import 'package:penhas/app/features/users/domain/entities/user_detail_profile_entity.dart';
import 'package:penhas/app/features/users/domain/usecases/block_user_usecase.dart';
import 'package:penhas/app/features/users/domain/usecases/report_user_usecase.dart';
import 'package:penhas/app/features/users/presentation/user_profile_controller.dart';
import 'package:penhas/app/features/users/presentation/user_profile_page.dart';

import '../../../../utils/golden_tests.dart';
import '../../../../utils/widget_test_steps.dart';

class GetChatChannelTokenUseCaseMock extends Mock
implements GetChatChannelTokenUseCase {}

class ReportUserUseCaseMock extends Mock implements ReportUserUseCase {}

class BlockUserUseCaseMock extends Mock implements BlockUserUseCase {}

void main() {
late UserProfileController controller;
late GetChatChannelTokenUseCaseMock getChatChannelToken;
late ReportUserUseCaseMock reportUser;
late BlockUserUseCaseMock blockUser;

setUp(() {
getChatChannelToken = GetChatChannelTokenUseCaseMock();
reportUser = ReportUserUseCaseMock();
blockUser = BlockUserUseCaseMock();

final person = UserDetailEntity(
isMyself: false,
profile: UserDetailProfileEntity(
activity: 'all activities',
skills: 'all skills',
miniBio: 'Test Bio',
clientId: 123,
nickname: 'test',
avatar: null,
),
);

controller = UserProfileController(
person: person,
getChatChannelToken: getChatChannelToken,
reportUser: reportUser,
blockUser: blockUser,
);
});

group(UserProfilePage, () {
testWidgets(
'should display user profile page',
(tester) async {
await theAppIsRunning(tester, UserProfilePage(controller: controller));
},
);

screenshotTest(
'should display user profile page',
fileName: 'user_profile_page',
pageBuilder: () => Scaffold(
body: UserProfilePage(controller: controller),
),
);
});
}

0 comments on commit 7aa16ea

Please sign in to comment.