From 12fb4774d52b1b49478abdf930d652730ea0e99d Mon Sep 17 00:00:00 2001 From: Paulina Kujawa Date: Thu, 31 Oct 2024 15:18:41 +0100 Subject: [PATCH 01/10] add all fields to country endpoint, modify tests --- src/hct_mis_api/api/endpoints/serializers.py | 2 +- tests/unit/api/test_lookups.py | 55 +++++++++----------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/hct_mis_api/api/endpoints/serializers.py b/src/hct_mis_api/api/endpoints/serializers.py index 163262a532..347933951e 100644 --- a/src/hct_mis_api/api/endpoints/serializers.py +++ b/src/hct_mis_api/api/endpoints/serializers.py @@ -14,4 +14,4 @@ class RejectPolicy(models.TextChoices): class CountrySerializer(serializers.ModelSerializer): class Meta: model = Country - fields = ("name", "short_name", "iso_code2", "iso_code3", "iso_num") + fields = "__all__" diff --git a/tests/unit/api/test_lookups.py b/tests/unit/api/test_lookups.py index f42ceef126..977262428a 100644 --- a/tests/unit/api/test_lookups.py +++ b/tests/unit/api/test_lookups.py @@ -6,7 +6,7 @@ from hct_mis_api.api.models import Grant from hct_mis_api.apps.geo.fixtures import AreaFactory, AreaTypeFactory, CountryFactory -from hct_mis_api.apps.geo.models import Area, AreaType +from hct_mis_api.apps.geo.models import Area, AreaType, Country from hct_mis_api.apps.program.models import Program from tests.unit.api.base import HOPEApiTestCase, token_grant_permission @@ -53,6 +53,27 @@ def setUpTestData(cls) -> None: cls.country_afghanistan.save(update_fields=["valid_from", "valid_until"]) cls.url = reverse("api:country-list") + def get_response(self, country: Country) -> dict: + return { + "id": str(country.id), + "name": country.name, + "short_name": country.short_name, + "iso_code2": country.iso_code2, + "iso_code3": country.iso_code3, + "iso_num": country.iso_num, + "created_at": country.created_at.strftime("%Y-%m-%dT%H:%M:%S.%fZ"), + "updated_at": country.updated_at.strftime("%Y-%m-%dT%H:%M:%S.%fZ"), + "original_id": country.original_id, + "valid_from": country.valid_from.strftime("%Y-%m-%dT%H:%M:%SZ"), + "valid_until": country.valid_until.strftime("%Y-%m-%dT%H:%M:%SZ"), + "extras": country.extras, + "lft": country.lft, + "rght": country.rght, + "tree_id": country.tree_id, + "level": country.level, + "parent": country.parent, + } + def test_get_countries(self) -> None: with token_grant_permission(self.token, Grant.API_READ_ONLY): response = self.client.get(self.url) @@ -60,20 +81,8 @@ def test_get_countries(self) -> None: self.assertEqual( response.json()["results"], [ - { - "name": self.country_afghanistan.name, - "short_name": self.country_afghanistan.short_name, - "iso_code2": self.country_afghanistan.iso_code2, - "iso_code3": self.country_afghanistan.iso_code3, - "iso_num": self.country_afghanistan.iso_num, - }, - { - "name": self.country_poland.name, - "short_name": self.country_poland.short_name, - "iso_code2": self.country_poland.iso_code2, - "iso_code3": self.country_poland.iso_code3, - "iso_num": self.country_poland.iso_num, - }, + self.get_response(self.country_afghanistan), + self.get_response(self.country_poland), ], ) self.assertIn("count", response.json()) @@ -93,13 +102,7 @@ def test_get_countries_filter_valid_from_until(self) -> None: self.assertEqual(len(response.json()["results"]), len(expected_result), filter_data) for result in expected_result: self.assertIn( - { - "name": result.name, - "short_name": result.short_name, - "iso_code2": result.iso_code2, - "iso_code3": result.iso_code3, - "iso_num": result.iso_num, - }, + self.get_response(result), response.json()["results"], filter_data, ) @@ -117,13 +120,7 @@ def test_get_countries_search(self) -> None: self.assertEqual(response.status_code, status.HTTP_200_OK, filter_data) self.assertEqual(len(response.json()["results"]), 1, filter_data) self.assertIn( - { - "name": expected_result.name, - "short_name": expected_result.short_name, - "iso_code2": expected_result.iso_code2, - "iso_code3": expected_result.iso_code3, - "iso_num": expected_result.iso_num, - }, + self.get_response(expected_result), response.json()["results"], filter_data, ) From 0bc1efedfe4c514aee25fa452fca99ffbf6926f4 Mon Sep 17 00:00:00 2001 From: szymon-kellton <130459593+szymon-kellton@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:50:09 +0100 Subject: [PATCH 02/10] Selenium: Payment Verification tests (#4318) * Init * Fix test_payment_plan_delete * Fixtures * Added tests * Black * Add tests * Add tests * Fix test_payment_verification_edit * Add tests * Add tests * Add tests * Add tests * Add tests * black * black * Fix test_grievance_tickets_create_new_ticket_Data_Change_Add_Individual_Mandatory_Fields * Fix test_grievance_tickets_create_new_ticket_Data_Change_Add_Individual_Mandatory_Fields * yarn test -u * yarn test -u * yarn lint --fix * Fix test_payment_verification_xlsx_partially_successful * Fix test_smoke_new_payment_plan * Fixes after review --- .../PaymentGrievanceDetails.tsx | 1 + .../PaymentGrievanceDetails.test.tsx.snap | 1 + .../VerifyPaymentGrievance.tsx | 1 + .../VerifyPaymentGrievance.test.tsx.snap | 1 + .../payments/CreateVerificationPlan.tsx | 19 +- .../payments/EditVerificationPlan.tsx | 16 +- .../payments/VerificationPlanActions.tsx | 5 +- .../payments/VerificationPlanDetails.tsx | 2 +- .../src/components/payments/VerifyManual.tsx | 4 +- .../FormikRadioGroup/FormikRadioGroup.tsx | 2 + tests/selenium/filters/test_filters.py | 8 + tests/selenium/helpers/helper.py | 22 +- tests/selenium/page_object/base_components.py | 9 + .../grievance/details_grievance_page.py | 16 + .../payment_module/payment_module.py | 2 + .../payment_verification/payment_record.py | 11 + .../payment_verification.py | 68 ++ .../payment_verification_details.py | 35 + .../payment_module/test_payment_plans.py | 60 +- .../test_payment_verification.py | 618 +++++++++++++++++- 20 files changed, 862 insertions(+), 39 deletions(-) diff --git a/src/frontend/src/components/grievances/PaymentGrievance/PaymentGrievanceDetails/PaymentGrievanceDetails.tsx b/src/frontend/src/components/grievances/PaymentGrievance/PaymentGrievanceDetails/PaymentGrievanceDetails.tsx index 8d8985fa26..63191cde72 100644 --- a/src/frontend/src/components/grievances/PaymentGrievance/PaymentGrievanceDetails/PaymentGrievanceDetails.tsx +++ b/src/frontend/src/components/grievances/PaymentGrievance/PaymentGrievanceDetails/PaymentGrievanceDetails.tsx @@ -76,6 +76,7 @@ export function PaymentGrievanceDetails({ {canApprovePaymentVerification && ticket.status === GRIEVANCE_TICKET_STATES.FOR_APPROVAL ? ( + - - + + @@ -351,9 +351,9 @@ export const EditVerificationPlan = ({ label={t('Verification Channel')} style={{ flexDirection: 'row', alignItems: 'center' }} choices={[ - { value: 'RAPIDPRO', name: 'RAPIDPRO' }, - { value: 'XLSX', name: 'XLSX' }, - { value: 'MANUAL', name: 'MANUAL' }, + { value: 'RAPIDPRO', name: 'RAPIDPRO', dataCy: 'radio-rapidpro' }, + { value: 'XLSX', name: 'XLSX', dataCy: 'radio-xlsx' }, + { value: 'MANUAL', name: 'MANUAL', dataCy: 'radio-manual' }, ]} component={FormikRadioGroup} alignItems="center" @@ -500,9 +500,9 @@ export const EditVerificationPlan = ({ }} alignItems="center" choices={[ - { value: 'RAPIDPRO', name: 'RAPIDPRO' }, - { value: 'XLSX', name: 'XLSX' }, - { value: 'MANUAL', name: 'MANUAL' }, + { value: 'RAPIDPRO', name: 'RAPIDPRO', dataCy: 'radio-rapidpro' }, + { value: 'XLSX', name: 'XLSX', dataCy: 'radio-xlsx' }, + { value: 'MANUAL', name: 'MANUAL', dataCy: 'radio-manual' }, ]} component={FormikRadioGroup} /> diff --git a/src/frontend/src/components/payments/VerificationPlanActions.tsx b/src/frontend/src/components/payments/VerificationPlanActions.tsx index e25f1dc6f6..d7099f4ce7 100644 --- a/src/frontend/src/components/payments/VerificationPlanActions.tsx +++ b/src/frontend/src/components/payments/VerificationPlanActions.tsx @@ -138,6 +138,7 @@ export function VerificationPlanActions({ color="primary" variant="outlined" startIcon={} + data-cy="export-xlsx" onClick={async () => { try { await mutateExport({ @@ -171,6 +172,7 @@ export function VerificationPlanActions({