Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-mk committed Dec 23, 2024
1 parent eba4ebd commit a6dd17c
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 126 deletions.
31 changes: 16 additions & 15 deletions tests/selenium/filters/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@
from hct_mis_api.apps.program.models import BeneficiaryGroup, Program
from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory
from hct_mis_api.apps.registration_data.models import ImportData, RegistrationDataImport
from hct_mis_api.apps.targeting.fixtures import (
TargetingCriteriaFactory,
TargetPopulationFactory,
)
from hct_mis_api.apps.targeting.models import TargetPopulation
from hct_mis_api.apps.targeting.fixtures import TargetingCriteriaFactory
from tests.selenium.page_object.filters import Filters
from tests.selenium.page_object.grievance.details_grievance_page import (
GrievanceDetailsPage,
Expand All @@ -44,14 +40,17 @@

@pytest.fixture
def create_payment_plan() -> None:
tp = TargetPopulation.objects.all()[0]
tp2 = TargetPopulation.objects.all()[1]
ba = BusinessArea.objects.get(slug="afghanistan")
targeting_criteria = TargetingCriteriaFactory()
targeting_criteria_2 = TargetingCriteriaFactory()
program_1 = ProgramFactory(business_area=ba)
program_2 = ProgramFactory(business_area=ba)

pp = PaymentPlan.objects.update_or_create(
name="Test Payment Plan 1",
unicef_id="PP-0060-22-11223344",
business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"),
target_population=tp,
business_area=ba,
targeting_criteria=targeting_criteria,
start_date=datetime.now(),
end_date=datetime.now() + relativedelta(days=30),
currency="USD",
Expand All @@ -63,15 +62,15 @@ def create_payment_plan() -> None:
total_delivered_quantity=999,
total_entitled_quantity=2999,
is_follow_up=False,
program_cycle=tp.program.cycles.first(),
program_cycle=program_1.cycles.first(),
)
pp[0].unicef_id = "PP-0060-22-11223344"
pp[0].save()

PaymentPlan.objects.update_or_create(
name="Test Payment Plan 2",
business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"),
target_population=tp2,
business_area=ba,
targeting_criteria=targeting_criteria_2,
start_date=datetime.now(),
end_date=datetime.now() + relativedelta(days=30),
currency="USD",
Expand All @@ -83,7 +82,7 @@ def create_payment_plan() -> None:
total_delivered_quantity=999,
total_entitled_quantity=2999,
is_follow_up=False,
program_cycle=tp2.program.cycles.first(),
program_cycle=program_2.cycles.first(),
)


Expand Down Expand Up @@ -222,17 +221,19 @@ def add_payment_verification() -> None:
def create_targeting() -> None:
user = User.objects.first()
business_area = BusinessArea.objects.get(slug="afghanistan")
TargetPopulationFactory(
PaymentPlanFactory(
name="Test",
created_by=user,
targeting_criteria=TargetingCriteriaFactory(),
business_area=business_area,
status=PaymentPlan.Status.TP_OPEN,
)
TargetPopulationFactory(
PaymentPlanFactory(
name="Targeting 2",
created_by=user,
targeting_criteria=TargetingCriteriaFactory(),
business_area=business_area,
status=PaymentPlan.Status.TP_OPEN,
)


Expand Down
19 changes: 4 additions & 15 deletions tests/selenium/managerial_console/test_managerial_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
from hct_mis_api.apps.payment.models import PaymentPlan
from hct_mis_api.apps.program.fixtures import ProgramCycleFactory, ProgramFactory
from hct_mis_api.apps.program.models import BeneficiaryGroup, Program
from hct_mis_api.apps.targeting.fixtures import (
TargetingCriteriaFactory,
TargetPopulationFactory,
)
from hct_mis_api.apps.targeting.models import TargetPopulation
from hct_mis_api.apps.targeting.fixtures import TargetingCriteriaFactory
from tests.selenium.page_object.managerial_console.managerial_console import (
ManagerialConsole,
)
Expand Down Expand Up @@ -63,29 +59,22 @@ def create_program(
def create_payment_plan(create_active_test_program: Program, second_test_program: Program) -> PaymentPlan:
program_cycle_second = ProgramCycleFactory(program=second_test_program)
PaymentPlanFactory(
target_population=TargetPopulationFactory(program=second_test_program),
program_cycle=program_cycle_second,
status=PaymentPlan.Status.IN_APPROVAL,
business_area=BusinessArea.objects.filter(slug="afghanistan").first(),
)
targeting_criteria = TargetingCriteriaFactory()
TargetPopulationFactory(
program=create_active_test_program,
status=TargetPopulation.STATUS_OPEN,
targeting_criteria=targeting_criteria,
)
tp = TargetPopulation.objects.get(program__name="Test Programm")

payment_plan = PaymentPlan.objects.update_or_create(
name="Test Payment Plan",
business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"),
target_population=tp,
targeting_criteria=TargetingCriteriaFactory(),
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_cycle=tp.program.cycles.first(),
program_cycle=create_active_test_program.cycles.first(),
total_delivered_quantity=999,
total_entitled_quantity=2999,
is_follow_up=False,
Expand Down
2 changes: 1 addition & 1 deletion tests/selenium/payment_module/test_payment_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_smoke_payment_plan(self, create_payment_plan: PaymentPlan, pagePaymentM
assert "Dispersion End Date" in pagePaymentModule.getTableLabel()[9].text
assert "Follow-up Payment Plans" in pagePaymentModule.getTableLabel()[10].text
assert "ACCEPTED" in pagePaymentModule.getStatusContainer().text
assert "Rows per page: 5 1–2 of 2" in pagePaymentModule.getTablePagination().text.replace("\n", " ")
assert "Rows per page: 5 1–1 of 1" in pagePaymentModule.getTablePagination().text.replace("\n", " ")

def test_smoke_new_payment_plan(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ def add_payment_verification_xlsx() -> PV:

def payment_verification_creator(channel: str = PaymentVerificationPlan.VERIFICATION_CHANNEL_MANUAL) -> PV:
user = User.objects.first()
registration_data_import = RegistrationDataImportFactory(
imported_by=user, business_area=BusinessArea.objects.first()
)
business_area = BusinessArea.objects.first()
registration_data_import = RegistrationDataImportFactory(imported_by=user, business_area=business_area)
program = Program.objects.filter(name="Active Program").first()
household, individuals = create_household(
{
Expand All @@ -212,7 +211,7 @@ def payment_verification_creator(channel: str = PaymentVerificationPlan.VERIFICA
name="TEST",
status=PaymentPlan.Status.FINISHED,
program_cycle=program.cycles.first(),
business_area=BusinessArea.objects.first(),
business_area=business_area,
start_date=datetime.now() - relativedelta(months=1),
end_date=datetime.now() + relativedelta(months=1),
created_by=user,
Expand Down Expand Up @@ -363,7 +362,7 @@ def test_happy_path_payment_verification(
assert "DELIVERED FULLY" in pagePaymentRecord.getLabelStatus()[0].text
assert "DELIVERED FULLY" in pagePaymentRecord.getStatusContainer().text
assert payment_record.household.unicef_id in pagePaymentRecord.getLabelHousehold().text
assert payment_record.parent.target_population.name in pagePaymentRecord.getLabelTargetPopulation().text
assert payment_record.parent.name in pagePaymentRecord.getLabelTargetPopulation().text
assert payment_record.parent.unicef_id in pagePaymentRecord.getLabelDistributionModality().text
assert payment_record.payment_verifications.first().status in pagePaymentRecord.getLabelStatus()[1].text
assert "PLN 0.00" in pagePaymentRecord.getLabelAmountReceived().text
Expand Down
16 changes: 3 additions & 13 deletions tests/selenium/program_details/test_program_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
from hct_mis_api.apps.program.fixtures import ProgramCycleFactory, ProgramFactory
from hct_mis_api.apps.program.models import BeneficiaryGroup, Program, ProgramCycle
from hct_mis_api.apps.registration_data.fixtures import RegistrationDataImportFactory
from hct_mis_api.apps.targeting.fixtures import (
TargetingCriteriaFactory,
TargetPopulationFactory,
)
from hct_mis_api.apps.targeting.models import TargetPopulation
from hct_mis_api.apps.targeting.fixtures import TargetingCriteriaFactory
from tests.selenium.helpers.date_time_format import FormatTime
from tests.selenium.page_object.programme_details.programme_details import (
ProgrammeDetails,
Expand Down Expand Up @@ -205,16 +201,10 @@ def create_custom_household() -> Household:
def create_payment_plan(standard_program: Program) -> PaymentPlan:
targeting_criteria = TargetingCriteriaFactory()
cycle = standard_program.cycles.first()
tp = TargetPopulationFactory(
program=standard_program,
status=TargetPopulation.STATUS_OPEN,
targeting_criteria=targeting_criteria,
program_cycle=cycle,
)
payment_plan = PaymentPlan.objects.update_or_create(
name="Test Payment Plan",
business_area=BusinessArea.objects.only("is_payment_plan_applicable").get(slug="afghanistan"),
target_population=tp,
business_area=BusinessArea.objects.get(slug="afghanistan"),
targeting_criteria=targeting_criteria,
start_date=datetime.now(),
end_date=datetime.now() + relativedelta(days=30),
currency="USD",
Expand Down
Loading

0 comments on commit a6dd17c

Please sign in to comment.