diff --git a/test/views/after_auth_screens/join_organisation_after_auth_test.dart b/test/views/after_auth_screens/join_organisation_after_auth_test.dart index be2c6bc5e..53d67e89d 100644 --- a/test/views/after_auth_screens/join_organisation_after_auth_test.dart +++ b/test/views/after_auth_screens/join_organisation_after_auth_test.dart @@ -4,12 +4,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:talawa/enums/enums.dart'; +import 'package:talawa/models/organization/org_info.dart'; +import 'package:talawa/models/user/user_info.dart'; import 'package:talawa/services/graphql_config.dart'; import 'package:talawa/services/size_config.dart'; import 'package:talawa/utils/app_localization.dart'; import 'package:talawa/view_model/lang_view_model.dart'; +import 'package:talawa/view_model/pre_auth_view_models/select_organization_view_model.dart'; import 'package:talawa/views/after_auth_screens/join_org_after_auth/join_organisation_after_auth.dart'; import 'package:talawa/views/base_view.dart'; +import 'package:talawa/widgets/organization_search_list.dart'; import '../../helpers/test_helpers.dart'; import '../../helpers/test_locator.dart'; @@ -58,46 +63,46 @@ void main() { }, ); - // testWidgets( - // "Check if children show up correctly", - // (tester) async { - // await tester.pumpWidget(createJoinOrgAfterAuth()); - // await tester.pumpAndSettle(const Duration(seconds: 6)); - // - // expect( - // find.byWidgetPredicate( - // (widget) => widget is Scaffold && widget.body is Column, - // ), - // findsOneWidget, - // ); - // - // // expect( - // // find.byWidgetPredicate( - // // (widget) => - // // widget is Column && - // // widget.children[0] is Padding && - // // widget.children[1] is ColoredBox && - // // widget.children[2] is Padding && - // // widget.children[3] is Expanded && - // // widget.children[4] is SizedBox && - // // widget.children[5] is Column, - // // ), - // // findsOneWidget, - // // ); - // - // // expect( - // // find.byWidgetPredicate( - // // (widget) => - // // widget is Column && - // // widget.children[0] is RaisedRoundedButton && - // // (widget.children[0] as RaisedRoundedButton).buttonLabel == - // // "Join selected organisation" && - // // widget.children[1] is SizedBox, - // // ), - // // findsOneWidget, - // // ); - // }, - // ); + testWidgets( + "Check if children show up correctly", + (tester) async { + await tester.pumpWidget(createJoinOrgAfterAuth()); + await tester.pumpAndSettle(const Duration(seconds: 6)); + + expect( + find.byWidgetPredicate( + (widget) => widget is Scaffold && widget.body is Column, + ), + findsOneWidget, + ); + + // expect( + // find.byWidgetPredicate( + // (widget) => + // widget is Column && + // widget.children[0] is Padding && + // widget.children[1] is ColoredBox && + // widget.children[2] is Padding && + // widget.children[3] is Expanded && + // widget.children[4] is SizedBox && + // widget.children[5] is Column, + // ), + // findsOneWidget, + // ); + + // expect( + // find.byWidgetPredicate( + // (widget) => + // widget is Column && + // widget.children[0] is RaisedRoundedButton && + // (widget.children[0] as RaisedRoundedButton).buttonLabel == + // "Join selected organisation" && + // widget.children[1] is SizedBox, + // ), + // findsOneWidget, + // ); + }, + ); }); group("Tests for JoinOrganizationAfterAuth - widgets", () { @@ -123,67 +128,68 @@ void main() { // re-register SelectOrganizationViewModel in that test as it will // be disposed once this test ends, or better, write any new tests // before this one. + /// Search is No-Longer is a feature, if it gets implemented in future use this test /// Really good test to learn from so not deleting - // testWidgets("Check if model related functions work", (tester) async { - // // Registers a singleton, which means that every instance of - // // SelectOrganizationViewModel will be the same. - // locator.unregister(); - // locator.registerSingleton( - // SelectOrganizationViewModel(), - // ); - // - // final orgOne = OrgInfo( - // name: "org_one", - // creatorInfo: User( - // firstName: "ravidi", - // lastName: "shaikh", - // ), - // isPublic: false, - // ); - // final orgTwo = OrgInfo( - // name: "org_two", - // creatorInfo: User( - // firstName: "ravidi", - // lastName: "shaikh", - // ), - // isPublic: false, - // ); - // - // final selectOrgInfoVM = locator.get(); - // - // await tester.pumpWidget(createJoinOrgAfterAuth()); - // await tester.pumpAndSettle(const Duration(seconds: 6)); - // - // // This button comes from CupertinoSearchTextField - // // await tester.tap(find.byType(CupertinoButton)); - // // await tester.pumpAndSettle(const Duration(seconds: 6)); - // - // // Checking for text change - // selectOrgInfoVM.setState(ViewState.busy); - // selectOrgInfoVM.searchController.text = "tmmmext"; - // await tester.pumpAndSettle(const Duration(seconds: 6)); - // - // expect(find.text("tmmmext"), findsOneWidget); - // - // // Checking for Org selection - // - // expect(selectOrgInfoVM.organizations, []); - // - // selectOrgInfoVM.organizations = [ - // orgOne, - // orgTwo, - // ]; - // - // selectOrgInfoVM.selectedOrganization = orgOne; - // - // selectOrgInfoVM.notifyListeners(); - // await tester.pumpAndSettle(const Duration(seconds: 6)); - // - // selectOrgInfoVM.searching = true; - // selectOrgInfoVM.notifyListeners(); - // - // expect(find.byType(OrganizationSearchList), findsNothing); - // }); + testWidgets("Check if model related functions work", (tester) async { + // Registers a singleton, which means that every instance of + // SelectOrganizationViewModel will be the same. + locator.unregister(); + locator.registerSingleton( + SelectOrganizationViewModel(), + ); + + final orgOne = OrgInfo( + name: "org_one", + creatorInfo: User( + firstName: "ravidi", + lastName: "shaikh", + ), + isPublic: false, + ); + final orgTwo = OrgInfo( + name: "org_two", + creatorInfo: User( + firstName: "ravidi", + lastName: "shaikh", + ), + isPublic: false, + ); + + final selectOrgInfoVM = locator.get(); + + await tester.pumpWidget(createJoinOrgAfterAuth()); + await tester.pumpAndSettle(const Duration(seconds: 6)); + + // This button comes from CupertinoSearchTextField + // await tester.tap(find.byType(CupertinoButton)); + // await tester.pumpAndSettle(const Duration(seconds: 6)); + + // Checking for text change + selectOrgInfoVM.setState(ViewState.busy); + selectOrgInfoVM.searchController.text = "tmmmext"; + await tester.pumpAndSettle(const Duration(seconds: 6)); + + // expect(find.text("tmmmext"), findsOneWidget); + + // Checking for Org selection + + expect(selectOrgInfoVM.organizations, []); + + selectOrgInfoVM.organizations = [ + orgOne, + orgTwo, + ]; + + selectOrgInfoVM.selectedOrganization = orgOne; + + selectOrgInfoVM.notifyListeners(); + await tester.pumpAndSettle(const Duration(seconds: 6)); + + selectOrgInfoVM.searching = true; + selectOrgInfoVM.notifyListeners(); + + expect(find.byType(OrganizationSearchList), findsNothing); + }); }); }