diff --git a/pubspec.lock b/pubspec.lock index 22365c68..0a49eafd 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -472,6 +472,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" markdown: dependency: transitive description: @@ -484,26 +508,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" mime: dependency: transitive description: @@ -572,10 +596,10 @@ packages: dependency: "direct main" description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -1007,6 +1031,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.3" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" web: dependency: transitive description: diff --git a/test/choose_projects_test.dart b/test/choose_projects_test.dart index 6ba0b402..6cb63805 100644 --- a/test/choose_projects_test.dart +++ b/test/choose_projects_test.dart @@ -8,7 +8,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'api_service_mock.dart'; void main() { - testWidgets('Projects are visible', (t) async { + TestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('Page building test', (t) async { final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: StorageServiceInherited( @@ -25,15 +27,10 @@ void main() { await t.pumpWidget(app); - final pageTitle = find.textContaining('Choose projects'); - expect(pageTitle, findsOneWidget); - - await t.pumpAndSettle(); + await t.pump(); - final firstProject = find.textContaining('p1'); - expect(firstProject, findsOneWidget); + expect(find.byType(ChooseProjectsPage), findsOneWidget); }); - testWidgets('All projects are selected by default', (t) async { final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), diff --git a/test/commit_detail_test.dart b/test/commit_detail_test.dart index db4c6dcd..f4c437ad 100644 --- a/test/commit_detail_test.dart +++ b/test/commit_detail_test.dart @@ -7,10 +7,12 @@ import 'api_service_mock.dart'; /// Mock commit is taken from [AzureApiServiceMock.getCommitDetail] void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( - 'Commit detail page shows all the details', + 'Page building test', (t) async { - final detailPage = AzureApiServiceInherited( + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( onGenerateRoute: (_) => MaterialPageRoute( @@ -22,19 +24,10 @@ void main() { ), ); - await t.pumpWidget(detailPage); + await t.pumpWidget(app); await t.pump(); - // commit info - expect(find.text('TestProject'), findsOneWidget); - expect(find.text('test_repo'), findsOneWidget); - expect(find.text('Test commit message'), findsOneWidget); - expect(find.text('123456789'), findsOneWidget); - - // edited files details - expect(find.text('5 edited files'), findsOneWidget); - expect(find.text('3 added files'), findsOneWidget); - expect(find.text('1 deleted file'), findsOneWidget); + expect(find.byType(CommitDetailPage), findsOneWidget); }, ); } diff --git a/test/commits_test.dart b/test/commits_test.dart index b98495be..bdaf35fb 100644 --- a/test/commits_test.dart +++ b/test/commits_test.dart @@ -9,6 +9,27 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( + 'Page building test', + (t) async { + final app = MaterialApp( + home: AzureApiServiceInherited( + apiService: AzureApiServiceMock(), + child: StorageServiceInherited( + storageService: StorageServiceMock(), + child: CommitsPage(), + ), + ), + ); + + await t.pumpWidget(app); + + await t.pump(); + + expect(find.byType(CommitsPage), findsOneWidget); + }, + ); + testWidgets( 'Commits are sorted by date descending', (t) async { diff --git a/test/file_detail_test.dart b/test/file_detail_test.dart index e8df457a..5bff894d 100644 --- a/test/file_detail_test.dart +++ b/test/file_detail_test.dart @@ -9,8 +9,8 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('File detail page showing correcly file content', (t) async { - final detailPage = AzureApiServiceInherited( + testWidgets('Page building test', (t) async { + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( onGenerateRoute: (_) => MaterialPageRoute( @@ -27,9 +27,9 @@ void main() { ), ); - await t.pumpWidget(detailPage); + await t.pumpWidget(app); await t.pumpAndSettle(); - expect(find.text('body test', findRichText: true), findsOneWidget); + expect(find.byType(FileDetailPage), findsOneWidget); }); } diff --git a/test/login_test.dart b/test/login_test.dart index ab7872e8..9044af5a 100644 --- a/test/login_test.dart +++ b/test/login_test.dart @@ -8,6 +8,27 @@ import 'package:flutter_test/flutter_test.dart'; import 'api_service_mock.dart'; void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + + testWidgets('Page building test', (t) async { + final app = AzureApiServiceInherited( + apiService: AzureApiServiceMock(), + child: StorageServiceInherited( + storageService: StorageServiceMock(), + child: MaterialApp( + navigatorKey: AppRouter.navigatorKey, + routes: AppRouter.routes, + home: LoginPage(), + ), + ), + ); + + await t.pumpWidget(app); + + await t.pump(); + + expect(find.byType(LoginPage), findsOneWidget); + }); testWidgets('Login with invalid token shows error alert', (t) async { final app = MaterialApp( navigatorKey: AppRouter.navigatorKey, diff --git a/test/member_detail_test.dart b/test/member_detail_test.dart index 44f441bd..784a66a0 100644 --- a/test/member_detail_test.dart +++ b/test/member_detail_test.dart @@ -9,7 +9,7 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('Member detail page shows all details', (t) async { + testWidgets('Page building test', (t) async { final memberPage = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( @@ -25,6 +25,6 @@ void main() { await t.pumpWidget(memberPage); await t.pumpAndSettle(); - expect(find.text('Name: name test', findRichText: true), findsWidgets); + expect(find.byType(MemberDetailPage), findsOneWidget); }); } diff --git a/test/pipeline_detail_test.dart b/test/pipeline_detail_test.dart index 68503fb1..a47457e5 100644 --- a/test/pipeline_detail_test.dart +++ b/test/pipeline_detail_test.dart @@ -10,10 +10,12 @@ import 'api_service_mock.dart'; void main() { setUp(() => VisibilityDetectorController.instance.updateInterval = Duration.zero); + TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( - 'Pipeline detail page shows all the details', + 'Page building test', (t) async { - final detailPage = AzureApiServiceInherited( + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( onGenerateRoute: (_) => MaterialPageRoute( @@ -25,24 +27,11 @@ void main() { ), ); - await t.pumpWidget(detailPage); + await t.pumpWidget(app); await t.pump(); - // pipeline info - expect(find.text('Test User'), findsOneWidget); - expect(find.text('now'), findsOneWidget); - expect(find.text('TestProject'), findsOneWidget); - expect(find.text('test_repo'), findsOneWidget); - - // commit info - expect(find.text('Test commit message'), findsOneWidget); - expect(find.text('123456789'), findsOneWidget); - expect(find.text('Branch: test_branch', findRichText: true), findsOneWidget); - - // build info - expect(find.text('Id: 1234', findRichText: true), findsOneWidget); - expect(find.text('Number: 5678', findRichText: true), findsOneWidget); + expect(find.byType(PipelineDetailPage), findsOneWidget); }, ); } diff --git a/test/pipeline_logs_test.dart b/test/pipeline_logs_test.dart index 39c27595..fe285b6c 100644 --- a/test/pipeline_logs_test.dart +++ b/test/pipeline_logs_test.dart @@ -9,7 +9,7 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('Pipeline logs page shows all logs', (t) async { + testWidgets('Page building test', (t) async { final pipelineLogsPage = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( @@ -31,6 +31,6 @@ void main() { await t.pumpWidget(pipelineLogsPage); await t.pump(); - expect(find.text('log test', findRichText: true), findsOneWidget); + expect(find.byType(PipelineLogsPage), findsOneWidget); }); } diff --git a/test/pipelines_test.dart b/test/pipelines_test.dart index d0b449a1..73a5a4a8 100644 --- a/test/pipelines_test.dart +++ b/test/pipelines_test.dart @@ -12,6 +12,27 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( + 'Page building test', + (t) async { + final app = MaterialApp( + home: StorageServiceInherited( + storageService: StorageServiceMock(), + child: AzureApiServiceInherited( + apiService: AzureApiServiceMock(), + child: PipelinesPage(), + ), + ), + ); + + await t.pumpWidget(app); + + await t.pump(); + + expect(find.byType(PipelinesPage), findsOneWidget); + }, + ); + testWidgets( 'Pipelines are sorted by status', (t) async { diff --git a/test/project_detail_test.dart b/test/project_detail_test.dart index 2106d6f8..84948670 100644 --- a/test/project_detail_test.dart +++ b/test/project_detail_test.dart @@ -9,8 +9,8 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets("Project detail page shows all project's informations", (t) async { - final projectPage = AzureApiServiceInherited( + testWidgets('Page building test', (t) async { + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( onGenerateRoute: (_) => MaterialPageRoute( @@ -22,9 +22,9 @@ void main() { ), ); - await t.pumpWidget(projectPage); + await t.pumpWidget(app); await t.pumpAndSettle(); - expect(find.text('member_2_name', findRichText: true), findsOneWidget); + expect(find.byType(ProjectDetailPage), findsOneWidget); }); } diff --git a/test/pull_request_detail_test.dart b/test/pull_request_detail_test.dart index 26281fdc..0aeb2784 100644 --- a/test/pull_request_detail_test.dart +++ b/test/pull_request_detail_test.dart @@ -11,10 +11,12 @@ import 'api_service_mock.dart'; void main() { setUp(() => VisibilityDetectorController.instance.updateInterval = Duration.zero); + TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( - 'Pull request detail page shows all the details', + 'Page building test', (t) async { - final detailPage = AzureApiServiceInherited( + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: StorageServiceInherited( storageService: StorageServiceMock(), @@ -29,18 +31,11 @@ void main() { ), ); - await t.pumpWidget(detailPage); + await t.pumpWidget(app); await t.pump(); - expect(find.text('Id: 1234', findRichText: true), findsOneWidget); - expect(find.text('Created by: Test User Creator', findRichText: true), findsOneWidget); - expect(find.text('Active'), findsOneWidget); - expect(find.text('now'), findsOneWidget); - expect(find.text('TestProject'), findsOneWidget); - expect(find.text('Test pull request title'), findsOneWidget); - expect(find.text('From: dev', findRichText: true), findsOneWidget); - expect(find.text('To: main', findRichText: true), findsOneWidget); + expect(find.byType(PullRequestDetailPage), findsOneWidget); }, ); } diff --git a/test/pull_requests_test.dart b/test/pull_requests_test.dart index d3433770..03fde6a1 100644 --- a/test/pull_requests_test.dart +++ b/test/pull_requests_test.dart @@ -11,6 +11,28 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( + 'Page building test', + (t) async { + final app = MaterialApp( + navigatorKey: AppRouter.navigatorKey, + home: StorageServiceInherited( + storageService: StorageServiceMock(), + child: AzureApiServiceInherited( + apiService: AzureApiServiceMock(), + child: PullRequestsPage(), + ), + ), + ); + + await t.pumpWidget(app); + + await t.pump(); + + expect(find.byType(PullRequestsPage), findsOneWidget); + }, + ); + testWidgets( 'Pull requests are visible, with their title, creator and repository and are sorted by creation date', (t) async { diff --git a/test/repository_detail_test.dart b/test/repository_detail_test.dart index 72625de7..37a8e54d 100644 --- a/test/repository_detail_test.dart +++ b/test/repository_detail_test.dart @@ -9,8 +9,8 @@ import 'api_service_mock.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('Repository detail page showing all items', (t) async { - final repoDetailPage = AzureApiServiceInherited( + testWidgets('Page building test', (t) async { + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: MaterialApp( onGenerateRoute: (_) => MaterialPageRoute( @@ -25,9 +25,9 @@ void main() { ), ); - await t.pumpWidget(repoDetailPage); + await t.pumpWidget(app); await t.pump(); - expect(find.text('item 2', findRichText: true), findsWidgets); + expect(find.byType(RepositoryDetailPage), findsOneWidget); }); } diff --git a/test/work_item_detail_test.dart b/test/work_item_detail_test.dart index 746b3ad0..59fdec0d 100644 --- a/test/work_item_detail_test.dart +++ b/test/work_item_detail_test.dart @@ -11,10 +11,12 @@ import 'api_service_mock.dart'; void main() { setUp(() => VisibilityDetectorController.instance.updateInterval = Duration.zero); + TestWidgetsFlutterBinding.ensureInitialized(); + testWidgets( - 'Work item detail page shows all the details', + 'Page building test', (t) async { - final detailPage = AzureApiServiceInherited( + final app = AzureApiServiceInherited( apiService: AzureApiServiceMock(), child: StorageServiceInherited( storageService: StorageServiceMock(), @@ -29,18 +31,11 @@ void main() { ), ); - await t.pumpWidget(detailPage); + await t.pumpWidget(app); await t.pump(); - expect(find.text('TestType'), findsOneWidget); - expect(find.text('1234'), findsOneWidget); - expect(find.text('Test User Creator'), findsOneWidget); - expect(find.text('Active'), findsOneWidget); - expect(find.text('now'), findsOneWidget); - expect(find.text('TestProject'), findsOneWidget); - expect(find.text('Test work item title'), findsOneWidget); - expect(find.text('Assigned to: Test User Assignee', findRichText: true), findsOneWidget); + expect(find.byType(WorkItemDetailPage), findsOneWidget); }, ); } diff --git a/test/work_items_test.dart b/test/work_items_test.dart index 7e82ffee..07f7f6cd 100644 --- a/test/work_items_test.dart +++ b/test/work_items_test.dart @@ -11,9 +11,9 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); testWidgets( - 'Work items are visible, with their title, id and project', + 'Page building test', (t) async { - final workitemsPage = MaterialApp( + final app = MaterialApp( navigatorKey: AppRouter.navigatorKey, home: StorageServiceInherited( storageService: StorageServiceMock(), @@ -24,28 +24,11 @@ void main() { ), ); - await t.pumpWidget(workitemsPage); + await t.pumpWidget(app); await t.pump(); - final titles = find.textContaining('Work item title'); - final ids = find.textContaining('#'); - final projects = find.textContaining('Project '); - - // first work item - expect((t.widget(titles.at(0)) as Text).data, 'Work item title 1'); - expect((t.widget(ids.at(0)) as Text).data, '#1'); - expect((t.widget(projects.at(0)) as Text).data, 'Project 1'); - - // second work item - expect((t.widget(titles.at(1)) as Text).data, 'Work item title 2'); - expect((t.widget(ids.at(1)) as Text).data, '#2'); - expect((t.widget(projects.at(1)) as Text).data, 'Project 2'); - - // third work item - expect((t.widget(titles.at(2)) as Text).data, 'Work item title 3'); - expect((t.widget(ids.at(2)) as Text).data, '#3'); - expect((t.widget(projects.at(2)) as Text).data, 'Project 3'); + expect(find.byType(WorkItemsPage), findsOneWidget); }, ); }