From 5bef4399eceb1b0eb3e7d148825c7cce5f2b1acf Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Thu, 27 Jun 2024 08:23:46 +0200 Subject: [PATCH 1/6] Init --- .../managerial_console/test_managerial_console.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/selenium_tests/managerial_console/test_managerial_console.py b/backend/selenium_tests/managerial_console/test_managerial_console.py index 406db855a3..5f58580934 100644 --- a/backend/selenium_tests/managerial_console/test_managerial_console.py +++ b/backend/selenium_tests/managerial_console/test_managerial_console.py @@ -104,3 +104,8 @@ def test_managerial_console_smoke_test( pageManagerialConsole.getSelectAllRelease().click() pageManagerialConsole.getReleaseButton().click() pageManagerialConsole.getButtonCancel().click() + + def test_managerial_console_happy_path( + self, pageManagerialConsole: ManagerialConsole, create_active_test_program: Program + ) -> None: + pageManagerialConsole.getNavManagerialConsole().click() \ No newline at end of file From 9a9fd2b297d3b25c57eb468b30852a2a7de34536 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Thu, 27 Jun 2024 08:31:52 +0200 Subject: [PATCH 2/6] Black --- .../managerial_console/test_managerial_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/selenium_tests/managerial_console/test_managerial_console.py b/backend/selenium_tests/managerial_console/test_managerial_console.py index 5f58580934..3cc77b2eda 100644 --- a/backend/selenium_tests/managerial_console/test_managerial_console.py +++ b/backend/selenium_tests/managerial_console/test_managerial_console.py @@ -108,4 +108,4 @@ def test_managerial_console_smoke_test( def test_managerial_console_happy_path( self, pageManagerialConsole: ManagerialConsole, create_active_test_program: Program ) -> None: - pageManagerialConsole.getNavManagerialConsole().click() \ No newline at end of file + pageManagerialConsole.getNavManagerialConsole().click() From b224c7bd94c2a3af1b761c759c76de7143171f60 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Thu, 27 Jun 2024 13:56:24 +0200 Subject: [PATCH 3/6] Added test_managerial_console_happy_path --- .../test_managerial_console.py | 86 ++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/backend/selenium_tests/managerial_console/test_managerial_console.py b/backend/selenium_tests/managerial_console/test_managerial_console.py index 3cc77b2eda..b28cb47267 100644 --- a/backend/selenium_tests/managerial_console/test_managerial_console.py +++ b/backend/selenium_tests/managerial_console/test_managerial_console.py @@ -1,24 +1,39 @@ from datetime import datetime +from django.utils import timezone + import pytest from dateutil.relativedelta import relativedelta from page_object.managerial_console.managerial_console import ManagerialConsole +from selenium.webdriver.common.by import By +from hct_mis_api.apps.account.fixtures import UserFactory +from hct_mis_api.apps.account.models import User from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType -from hct_mis_api.apps.payment.fixtures import PaymentPlanFactory +from hct_mis_api.apps.payment.fixtures import ApprovalProcessFactory, PaymentPlanFactory from hct_mis_api.apps.payment.models import PaymentPlan from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program +from hct_mis_api.apps.targeting.fixtures import ( + TargetingCriteriaFactory, + TargetPopulationFactory, +) +from hct_mis_api.apps.targeting.models import TargetPopulation pytestmark = pytest.mark.django_db(transaction=True) @pytest.fixture -def create_active_test_program() -> Program: +def create_test_program() -> Program: return create_program("Test Programm") +@pytest.fixture +def second_test_program() -> Program: + return create_program("Do not test it") + + def create_program( name: str, dct_type: str = DataCollectingType.Type.STANDARD, status: str = Program.ACTIVE ) -> Program: @@ -34,10 +49,51 @@ def create_program( return program +@pytest.fixture +def create_payment_plan(create_test_program: Program, second_test_program: Program) -> PaymentPlan: + PaymentPlanFactory( + program=second_test_program, + status=PaymentPlan.Status.IN_APPROVAL, + business_area=BusinessArea.objects.filter(slug="afghanistan").first(), + ) + targeting_criteria = TargetingCriteriaFactory() + TargetPopulationFactory( + program=create_test_program, + status=TargetPopulation.STATUS_OPEN, + targeting_criteria=targeting_criteria, + ) + tp = TargetPopulation.objects.first() + payment_plan = PaymentPlan.objects.update_or_create( + business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"), + target_population=tp, + start_date=datetime.now(), + end_date=datetime.now() + relativedelta(days=30), + currency="USD", + dispersion_start_date=datetime.now(), + dispersion_end_date=datetime.now() + relativedelta(days=14), + status_date=datetime.now(), + status=PaymentPlan.Status.IN_APPROVAL, + created_by=User.objects.first(), + program=tp.program, + total_delivered_quantity=999, + total_entitled_quantity=2999, + is_follow_up=False, + program_id=tp.program.id, + )[0] + approval_user = UserFactory() + approval_date = timezone.datetime(2000, 10, 10, tzinfo=timezone.utc) + ApprovalProcessFactory( + payment_plan=payment_plan, + sent_for_approval_date=approval_date, + sent_for_approval_by=approval_user, + ) + return payment_plan + + @pytest.mark.usefixtures("login") class TestSmokeManagerialConsole: def test_managerial_console_smoke_test( - self, pageManagerialConsole: ManagerialConsole, create_active_test_program: Program + self, pageManagerialConsole: ManagerialConsole, create_test_program: Program ) -> None: pageManagerialConsole.getNavManagerialConsole().click() pageManagerialConsole.getSelectAllApproval() @@ -106,6 +162,28 @@ def test_managerial_console_smoke_test( pageManagerialConsole.getButtonCancel().click() def test_managerial_console_happy_path( - self, pageManagerialConsole: ManagerialConsole, create_active_test_program: Program + self, pageManagerialConsole: ManagerialConsole, create_payment_plan: PaymentPlan ) -> None: pageManagerialConsole.getNavManagerialConsole().click() + # Approve Payment Plan + pageManagerialConsole.getProgramSelectApproval().click() + pageManagerialConsole.select_listbox_element("Test Programm").click() + pageManagerialConsole.getColumnField() + pageManagerialConsole.getSelectApproval().click() + pageManagerialConsole.getApproveButton().click() + pageManagerialConsole.getCommentApprove().find_elements(By.TAG_NAME, "textarea")[0].send_keys("Test Test 123") + pageManagerialConsole.getButtonSave().click() + # Authorize Payment Plan + pageManagerialConsole.getProgramSelectAuthorization().click() + pageManagerialConsole.select_listbox_element("Test Programm").click() + pageManagerialConsole.getColumnFieldAuthorization() + pageManagerialConsole.getSelectAllAuthorization().click() + pageManagerialConsole.getAuthorizeButton().click() + pageManagerialConsole.getButtonSave().click() + # Release Payment Plan + pageManagerialConsole.getColumnFieldRelease() + pageManagerialConsole.getSelectAllRelease().click() + pageManagerialConsole.getReleaseButton().click() + pageManagerialConsole.getButtonSave().click() + # Check Released Payment Plans + assert create_payment_plan.unicef_id in pageManagerialConsole.getColumnFieldReleased().text From 44e6fd688c2a1cb4419e81bd0c71989f56563f36 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Thu, 27 Jun 2024 13:58:09 +0200 Subject: [PATCH 4/6] Fix test_managerial_console_happy_path --- .../managerial_console/test_managerial_console.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/selenium_tests/managerial_console/test_managerial_console.py b/backend/selenium_tests/managerial_console/test_managerial_console.py index b28cb47267..3365d23efd 100644 --- a/backend/selenium_tests/managerial_console/test_managerial_console.py +++ b/backend/selenium_tests/managerial_console/test_managerial_console.py @@ -165,6 +165,8 @@ def test_managerial_console_happy_path( self, pageManagerialConsole: ManagerialConsole, create_payment_plan: PaymentPlan ) -> None: pageManagerialConsole.getNavManagerialConsole().click() + pageManagerialConsole.getMenuUserProfile().click() + pageManagerialConsole.getMenuItemClearCache().click() # Approve Payment Plan pageManagerialConsole.getProgramSelectApproval().click() pageManagerialConsole.select_listbox_element("Test Programm").click() From 64661b04b8a5370a3320cb8dcdba7f369e34e39c Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 15 Jul 2024 14:07:17 +0200 Subject: [PATCH 5/6] Fixed date problem in test_managerial_console_happy_path --- .../managerial_console/test_managerial_console.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/selenium_tests/managerial_console/test_managerial_console.py b/backend/selenium_tests/managerial_console/test_managerial_console.py index 838f1a7ac8..e5fd871fd4 100644 --- a/backend/selenium_tests/managerial_console/test_managerial_console.py +++ b/backend/selenium_tests/managerial_console/test_managerial_console.py @@ -50,19 +50,20 @@ def create_program( @pytest.fixture -def create_payment_plan(create_test_program: Program, second_test_program: Program) -> PaymentPlan: +def create_payment_plan(create_active_test_program: Program, second_test_program: Program) -> PaymentPlan: PaymentPlanFactory( + target_population=TargetPopulationFactory(program=second_test_program), program=second_test_program, status=PaymentPlan.Status.IN_APPROVAL, business_area=BusinessArea.objects.filter(slug="afghanistan").first(), ) targeting_criteria = TargetingCriteriaFactory() TargetPopulationFactory( - program=create_test_program, + program=create_active_test_program, status=TargetPopulation.STATUS_OPEN, targeting_criteria=targeting_criteria, ) - tp = TargetPopulation.objects.first() + tp = TargetPopulation.objects.get(program__name="Test Programm") payment_plan = PaymentPlan.objects.update_or_create( business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"), target_population=tp, @@ -93,7 +94,7 @@ def create_payment_plan(create_test_program: Program, second_test_program: Progr @pytest.mark.usefixtures("login") class TestSmokeManagerialConsole: def test_managerial_console_smoke_test( - self, pageManagerialConsole: ManagerialConsole, create_test_program: Program + self, pageManagerialConsole: ManagerialConsole, create_active_test_program: Program ) -> None: pageManagerialConsole.getNavManagerialConsole().click() pageManagerialConsole.getSelectAllApproval() @@ -165,11 +166,10 @@ def test_managerial_console_happy_path( self, pageManagerialConsole: ManagerialConsole, create_payment_plan: PaymentPlan ) -> None: pageManagerialConsole.getNavManagerialConsole().click() - pageManagerialConsole.getMenuUserProfile().click() - pageManagerialConsole.getMenuItemClearCache().click() # Approve Payment Plan pageManagerialConsole.getProgramSelectApproval().click() pageManagerialConsole.select_listbox_element("Test Programm").click() + pageManagerialConsole.getColumnField() pageManagerialConsole.getSelectApproval().click() pageManagerialConsole.getApproveButton().click() From fc008853c54c5b51d80aec334d7ae6569a07e378 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 15 Jul 2024 16:07:18 +0200 Subject: [PATCH 6/6] Fix for test_grievance_dashboard_happy_path --- .../grievance/grievance_dashboard/test_grievance_dashboard.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/selenium_tests/grievance/grievance_dashboard/test_grievance_dashboard.py b/backend/selenium_tests/grievance/grievance_dashboard/test_grievance_dashboard.py index 76d3b0894a..8a9724446d 100644 --- a/backend/selenium_tests/grievance/grievance_dashboard/test_grievance_dashboard.py +++ b/backend/selenium_tests/grievance/grievance_dashboard/test_grievance_dashboard.py @@ -180,7 +180,6 @@ def test_grievance_dashboard_happy_path( pageGrievanceDetailsPage.getButtonCloseTicket().click() pageGrievanceTickets.getButtonConfirm().click() pageGrievanceTickets.getNavGrievance().click() - pageGrievanceTickets.getNavGrievance().click() pageGrievanceDashboard.getNavGrievanceDashboard().click() assert "3" in pageGrievanceDashboard.getTotalNumberOfTicketsTopNumber().text assert "1" in pageGrievanceDashboard.getLabelizedFieldContainerTotalNumberOfTicketsSystemGenerated().text