diff --git a/backend/hct_mis_api/apps/household/fixtures.py b/backend/hct_mis_api/apps/household/fixtures.py index 7df8c92656..f0de6f51fa 100644 --- a/backend/hct_mis_api/apps/household/fixtures.py +++ b/backend/hct_mis_api/apps/household/fixtures.py @@ -248,6 +248,7 @@ class Meta: django_get_or_create = ("key",) key = factory.fuzzy.FuzzyChoice([value.lower() for value, _ in IDENTIFICATION_TYPE_CHOICE]) + label = factory.LazyAttribute(lambda o: o.key.replace("_", " ").title()) class DocumentFactory(DjangoModelFactory): diff --git a/backend/selenium_tests/conftest.py b/backend/selenium_tests/conftest.py index ac8fd8bef5..855081a5d9 100644 --- a/backend/selenium_tests/conftest.py +++ b/backend/selenium_tests/conftest.py @@ -33,6 +33,8 @@ from page_object.payment_verification.payment_verification_details import ( PaymentVerificationDetails, ) +from page_object.people.people import People +from page_object.people.people_details import PeopleDetails from page_object.program_log.payment_log import ProgramLog from page_object.programme_details.programme_details import ProgrammeDetails from page_object.programme_management.programme_management import ProgrammeManagement @@ -64,6 +66,8 @@ DataCollectingType, ) from hct_mis_api.apps.geo.models import Country +from hct_mis_api.apps.household.fixtures import DocumentTypeFactory +from hct_mis_api.apps.household.models import DocumentType def pytest_addoption(parser) -> None: # type: ignore @@ -253,6 +257,16 @@ def pageHouseholds(request: FixtureRequest, browser: Chrome) -> Households: yield Households(browser) +@pytest.fixture +def pagePeople(request: FixtureRequest, browser: Chrome) -> People: + yield People(browser) + + +@pytest.fixture +def pagePeopleDetails(request: FixtureRequest, browser: Chrome) -> PeopleDetails: + yield PeopleDetails(browser) + + @pytest.fixture def pageHouseholdsDetails(request: FixtureRequest, browser: Chrome) -> HouseholdsDetails: yield HouseholdsDetails(browser) @@ -418,7 +432,7 @@ def create_super_user(business_area: BusinessArea) -> User: UserRole.objects.create( user=user, role=Role.objects.get(name="Role"), - business_area=BusinessArea.objects.get(name="Afghanistan"), + business_area=business_area, ) for partner in Partner.objects.exclude(name="UNICEF"): @@ -428,21 +442,50 @@ def create_super_user(business_area: BusinessArea) -> User: assert user.is_superuser dct_list = [ - {"label": "Full", "code": "full", "description": "Full individual collected", "active": True}, - {"label": "Size only", "code": "size_only", "description": "Size only collected", "active": True}, - {"label": "WASH", "code": "wash", "description": "WASH", "active": True}, - {"label": "Partial", "code": "partial", "description": "Partial individuals collected", "active": True}, + { + "label": "Full", + "code": "full", + "description": "Full individual collected", + "active": True, + "type": DataCollectingType.Type.STANDARD, + }, + { + "label": "Size only", + "code": "size_only", + "description": "Size only collected", + "active": True, + "type": DataCollectingType.Type.STANDARD, + }, + { + "label": "WASH", + "code": "wash", + "description": "WASH", + "active": True, + "type": DataCollectingType.Type.STANDARD, + }, + { + "label": "Partial", + "code": "partial", + "description": "Partial individuals collected", + "active": True, + "type": DataCollectingType.Type.STANDARD, + }, { "label": "size/age/gender disaggregated", "code": "size_age_gender_disaggregated", "description": "No individual data", "active": True, + "type": DataCollectingType.Type.STANDARD, }, ] for dct in dct_list: data_collecting_type = DataCollectingType.objects.create( - label=dct["label"], code=dct["code"], description=dct["description"], active=dct["active"] + label=dct["label"], + code=dct["code"], + description=dct["description"], + active=dct["active"], + type=dct["type"], ) data_collecting_type.limit_to.add(business_area) data_collecting_type.save() @@ -450,6 +493,23 @@ def create_super_user(business_area: BusinessArea) -> User: business_area=business_area, partner=partner ) ba_partner_through.roles.set([role]) + + # add document types + doc_type_keys = ( + "birth_certificate", + "drivers_license", + "electoral_card", + "tax_id", + "residence_permit_no", + "bank_statement", + "disability_certificate", + "other_id", + "foster_child", + ) + for key in doc_type_keys: + DocumentTypeFactory(key=key) + DocumentType.objects.update_or_create(key="national_id", pk="227fcbc0-297a-4d85-8390-7de189278321") + DocumentType.objects.update_or_create(key="national_passport", pk="012a3ecb-0d6e-440f-9c68-83e5bf1ccddf") return user diff --git a/backend/selenium_tests/grievance/feedback/test_feedback.py b/backend/selenium_tests/grievance/feedback/test_feedback.py index 173f801881..aec38b6c53 100644 --- a/backend/selenium_tests/grievance/feedback/test_feedback.py +++ b/backend/selenium_tests/grievance/feedback/test_feedback.py @@ -25,7 +25,6 @@ def add_feedbacks(django_db_setup: Generator[None, None, None], django_db_blocke def add_households(django_db_setup: Generator[None, None, None], django_db_blocker: DjangoDbBlocker) -> None: with django_db_blocker.unblock(): call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/registration_data/fixtures/data-cypress.json") - call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/documenttype.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data-cypress.json") return diff --git a/backend/selenium_tests/grievance/grievance_tickets/test_grievance_tickets.py b/backend/selenium_tests/grievance/grievance_tickets/test_grievance_tickets.py index 959dc5ecdd..5635646e12 100644 --- a/backend/selenium_tests/grievance/grievance_tickets/test_grievance_tickets.py +++ b/backend/selenium_tests/grievance/grievance_tickets/test_grievance_tickets.py @@ -23,7 +23,6 @@ def add_grievance(django_db_setup: Generator[None, None, None], django_db_blocke def add_households(django_db_setup: Generator[None, None, None], django_db_blocker: DjangoDbBlocker) -> None: with django_db_blocker.unblock(): call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/registration_data/fixtures/data-cypress.json") - call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/documenttype.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data-cypress.json") return diff --git a/backend/selenium_tests/page_object/base_components.py b/backend/selenium_tests/page_object/base_components.py index e71199903f..29e74e4428 100644 --- a/backend/selenium_tests/page_object/base_components.py +++ b/backend/selenium_tests/page_object/base_components.py @@ -16,6 +16,7 @@ class BaseComponents(Common): navProgrammePopulation = 'a[data-cy="nav-Program Population"]' navHouseholds = 'a[data-cy="nav-Households"]' navIndividuals = 'a[data-cy="nav-Individuals"]' + navPeople = 'a[data-cy="nav-People"]' navProgrammeManagement = 'a[data-cy="nav-Programs"]' navManagerialConsole = 'a[data-cy="nav-Managerial Console"]' navProgrammeDetails = 'a[data-cy="nav-Program Details"]' @@ -84,6 +85,9 @@ def getNavHouseholds(self) -> WebElement: def getNavIndividuals(self) -> WebElement: return self.wait_for(self.navIndividuals) + def getNavPeople(self) -> WebElement: + return self.wait_for(self.navPeople) + def getNavProgrammeManagement(self) -> WebElement: return self.wait_for(self.navProgrammeManagement) diff --git a/backend/selenium_tests/page_object/people/people.py b/backend/selenium_tests/page_object/people/people.py new file mode 100644 index 0000000000..abf115f0bb --- /dev/null +++ b/backend/selenium_tests/page_object/people/people.py @@ -0,0 +1,134 @@ +from page_object.base_components import BaseComponents +from selenium.webdriver.remote.webelement import WebElement + + +class People(BaseComponents): + pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + indFiltersSearch = 'div[data-cy="ind-filters-search"]' + selectFilter = 'div[data-cy="select-filter"]' + filtersDocumentType = 'div[data-cy="filters-document-type"]' + filtersDocumentNumber = 'div[data-cy="filters-document-number"]' + indFiltersAdmin1 = 'div[data-cy="ind-filters-admin1"]' + adminLevel1Input = 'div[data-cy="Admin Level 1-input"]' + indFiltersAdmin2 = 'div[data-cy="ind-filters-admin2"]' + adminLevel2Input = 'div[data-cy="Admin Level 2-input"]' + indFiltersGender = 'div[data-cy="ind-filters-gender"]' + indFiltersAgeFrom = 'div[data-cy="ind-filters-age-from"]' + indFiltersAgeTo = 'div[data-cy="ind-filters-age-to"]' + indFiltersFlags = 'div[data-cy="ind-filters-flags"]' + indFiltersOrderBy = 'div[data-cy="ind-filters-order-by"]' + indFiltersStatus = 'div[data-cy="ind-filters-status"]' + indFiltersRegDateFrom = 'div[data-cy="ind-filters-reg-date-from"]' + indFiltersRegDateTo = 'div[data-cy="ind-filters-reg-date-to"]' + buttonFiltersClear = 'button[data-cy="button-filters-clear"]' + buttonFiltersApply = 'button[data-cy="button-filters-apply"]' + pageDetailsContainer = 'div[data-cy="page-details-container"]' + tableTitle = 'h6[data-cy="table-title"]' + sanctionListPossibleMatch = 'th[data-cy="sanction-list-possible-match"]' + tableLabel = 'span[data-cy="table-label"]' + individualId = 'th[data-cy="individual-id"]' + individualName = 'th[data-cy="individual-name"]' + individualAge = 'th[data-cy="individual-age"]' + individualSex = 'th[data-cy="individual-sex"]' + individualLocation = 'th[data-cy="individual-location"]' + tableRow = 'tr[data-cy="table-row"]' + tablePagination = 'div[data-cy="table-pagination"]' + individualTableRow = 'tr[data-cy="individual-table-row"]' + + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) + + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) + + def getIndFiltersSearch(self) -> WebElement: + return self.wait_for(self.indFiltersSearch) + + def getSelectFilter(self) -> WebElement: + return self.wait_for(self.selectFilter) + + def getFiltersDocumentType(self) -> WebElement: + return self.wait_for(self.filtersDocumentType) + + def getFiltersDocumentNumber(self) -> WebElement: + return self.wait_for(self.filtersDocumentNumber) + + def getIndFiltersAdmin1(self) -> WebElement: + return self.wait_for(self.indFiltersAdmin1) + + def getAdminLevel1Input(self) -> WebElement: + return self.wait_for(self.adminLevel1Input) + + def getIndFiltersAdmin2(self) -> WebElement: + return self.wait_for(self.indFiltersAdmin2) + + def getAdminLevel2Input(self) -> WebElement: + return self.wait_for(self.adminLevel2Input) + + def getIndFiltersGender(self) -> WebElement: + return self.wait_for(self.indFiltersGender) + + def getIndFiltersAgeFrom(self) -> WebElement: + return self.wait_for(self.indFiltersAgeFrom) + + def getIndFiltersAgeTo(self) -> WebElement: + return self.wait_for(self.indFiltersAgeTo) + + def getIndFiltersFlags(self) -> WebElement: + return self.wait_for(self.indFiltersFlags) + + def getIndFiltersOrderBy(self) -> WebElement: + return self.wait_for(self.indFiltersOrderBy) + + def getIndFiltersStatus(self) -> WebElement: + return self.wait_for(self.indFiltersStatus) + + def getIndFiltersRegDateFrom(self) -> WebElement: + return self.wait_for(self.indFiltersRegDateFrom) + + def getIndFiltersRegDateTo(self) -> WebElement: + return self.wait_for(self.indFiltersRegDateTo) + + def getButtonFiltersClear(self) -> WebElement: + return self.wait_for(self.buttonFiltersClear) + + def getButtonFiltersApply(self) -> WebElement: + return self.wait_for(self.buttonFiltersApply) + + def getPageDetailsContainer(self) -> WebElement: + return self.wait_for(self.pageDetailsContainer) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getSanctionListPossibleMatch(self) -> WebElement: + return self.wait_for(self.sanctionListPossibleMatch) + + def getTableLabel(self) -> WebElement: + return self.wait_for(self.tableLabel) + + def getIndividualId(self) -> WebElement: + return self.wait_for(self.individualId) + + def getIndividualName(self) -> WebElement: + return self.wait_for(self.individualName) + + def getIndividualAge(self) -> WebElement: + return self.wait_for(self.individualAge) + + def getIndividualSex(self) -> WebElement: + return self.wait_for(self.individualSex) + + def getIndividualLocation(self) -> WebElement: + return self.wait_for(self.individualLocation) + + def getTableRow(self) -> WebElement: + return self.wait_for(self.tableRow) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getIndividualTableRow(self, number: int) -> WebElement: + self.wait_for(self.individualTableRow) + return self.get_elements(self.individualTableRow)[number] diff --git a/backend/selenium_tests/page_object/people/people_details.py b/backend/selenium_tests/page_object/people/people_details.py new file mode 100644 index 0000000000..5bbf7b1318 --- /dev/null +++ b/backend/selenium_tests/page_object/people/people_details.py @@ -0,0 +1,252 @@ +from selenium.webdriver.remote.webelement import WebElement + +from selenium_tests.page_object.base_components import BaseComponents + + +class PeopleDetails(BaseComponents): + pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + labelFullName = 'div[data-cy="label-Full Name"]' + labelGivenName = 'div[data-cy="label-Given Name"]' + labelMiddleName = 'div[data-cy="label-Middle Name"]' + labelFamilyName = 'div[data-cy="label-Family Name"]' + labelGender = 'div[data-cy="label-Gender"]' + labelAge = 'div[data-cy="label-Age"]' + labelDateOfBirth = 'div[data-cy="label-Date of Birth"]' + labelEstimatedDateOfBirth = 'div[data-cy="label-Estimated Date of Birth"]' + labelMaritalStatus = 'div[data-cy="label-Marital Status"]' + labelWorkStatus = 'div[data-cy="label-Work Status"]' + labelPregnant = 'div[data-cy="label-Pregnant"]' + labelRole = 'div[data-cy="label-Role"]' + labelPreferredLanguage = 'div[data-cy="label-Preferred language"]' + labelResidenceStatus = 'div[data-cy="label-Residence Status"]' + labelCountry = 'div[data-cy="label-Country"]' + labelCountryOfOrigin = 'div[data-cy="label-Country of Origin"]' + labelAddress = 'div[data-cy="label-Address"]' + labelVilage = 'div[data-cy="label-Vilage"]' + labelZipCode = 'div[data-cy="label-Zip Code"]' + labelAdministrativeLevel1 = 'div[data-cy="label-Administrative Level 1"]' + labelAdministrativeLevel2 = 'div[data-cy="label-Administrative Level 2"]' + labelAdministrativeLevel3 = 'div[data-cy="label-Administrative Level 3"]' + labelAdministrativeLevel4 = 'div[data-cy="label-Administrative Level 4"]' + labelGeolocation = 'div[data-cy="label-Geolocation"]' + labelDataCollectingType = 'div[data-cy="label-Data Collecting Type"]' + labelObservedDisabilities = 'div[data-cy="label-Observed disabilities"]' + labelSeeingDisabilitySeverity = 'div[data-cy="label-Seeing disability severity"]' + labelHearingDisabilitySeverity = 'div[data-cy="label-Hearing disability severity"]' + labelPhysicalDisabilitySeverity = 'div[data-cy="label-Physical disability severity"]' + labelRememberingOrConcentratingDisabilitySeverity = ( + 'div[data-cy="label-Remembering or concentrating disability severity"]' + ) + labelSelfCareDisabilitySeverity = 'div[data-cy="label-Self-care disability severity"]' + labelCommunicatingDisabilitySeverity = 'div[data-cy="label-Communicating disability severity"]' + labelDisability = 'div[data-cy="label-Disability"]' + labelBirthCertificate = 'div[data-cy="label-Birth Certificate"]' + labelIssued = 'div[data-cy="label-issued"]' + labelDriverLicense = 'div[data-cy = "label-DriverLicense"]' + labelElectoralCard = 'div[data-cy="label-Electoral Card"]' + labelNationalPassport = 'div[data-cy="label-National Passport"]' + labelNationalId = 'div[data-cy="label-National ID"]' + labelUnhcrId = 'div[data-cy="label-UNHCR ID"]' + labelWfpId = 'div[data-cy="label-WFP ID"]' + labelEmail = 'div[data-cy="label-Email"]' + labelPhoneNumber = 'div[data-cy="label-Phone Number"]' + labelAlternativePhoneNumber = 'div[data-cy="label-Alternative Phone Number"]' + labelDateOfLastScreeningAgainstSanctionsList = 'div[data-cy="label-Date of last screening against sanctions list"]' + labelLinkedGrievances = 'div[data-cy="label-Linked Grievances"]' + labelWalletName = 'div[data-cy="label-Wallet Name"]' + labelBlockchainName = 'div[data-cy="label-Blockchain Name"]' + labelWalletAddress = 'div[data-cy="label-Wallet Address"]' + labelCashReceived = 'div[data-cy="label-Cash received"]' + labelTotalCashReceived = 'div[data-cy="label-Total Cash Received"]' + tableTitle = 'h6[data-cy="table-title"]' + tableLabel = 'span[data-cy="table-label"]' + statusContainer = 'div[data-cy="status-container"]' + tablePagination = 'div[data-cy="table-pagination"]' + labelSource = 'div[data-cy="label-Source"]' + labelImportName = 'div[data-cy="label-Import name"]' + labelRegistrationDate = 'div[data-cy="label-Registration Date"]' + labelUserName = 'div[data-cy="label-User name"]' + + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) + + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) + + def getLabelFullName(self) -> WebElement: + return self.wait_for(self.labelFullName) + + def getLabelGivenName(self) -> WebElement: + return self.wait_for(self.labelGivenName) + + def getLabelMiddleName(self) -> WebElement: + return self.wait_for(self.labelMiddleName) + + def getLabelFamilyName(self) -> WebElement: + return self.wait_for(self.labelFamilyName) + + def getLabelGender(self) -> WebElement: + return self.wait_for(self.labelGender) + + def getLabelAge(self) -> WebElement: + return self.wait_for(self.labelAge) + + def getLabelDateOfBirth(self) -> WebElement: + return self.wait_for(self.labelDateOfBirth) + + def getLabelEstimatedDateOfBirth(self) -> WebElement: + return self.wait_for(self.labelEstimatedDateOfBirth) + + def getLabelMaritalStatus(self) -> WebElement: + return self.wait_for(self.labelMaritalStatus) + + def getLabelWorkStatus(self) -> WebElement: + return self.wait_for(self.labelWorkStatus) + + def getLabelPregnant(self) -> WebElement: + return self.wait_for(self.labelPregnant) + + def getLabelRole(self) -> WebElement: + return self.wait_for(self.labelRole) + + def getLabelPreferredLanguage(self) -> WebElement: + return self.wait_for(self.labelPreferredLanguage) + + def getLabelResidenceStatus(self) -> WebElement: + return self.wait_for(self.labelResidenceStatus) + + def getLabelCountry(self) -> WebElement: + return self.wait_for(self.labelCountry) + + def getLabelCountryOfOrigin(self) -> WebElement: + return self.wait_for(self.labelCountryOfOrigin) + + def getLabelAddress(self) -> WebElement: + return self.wait_for(self.labelAddress) + + def getLabelVilage(self) -> WebElement: + return self.wait_for(self.labelVilage) + + def getLabelZipCode(self) -> WebElement: + return self.wait_for(self.labelZipCode) + + def getLabelAdministrativeLevel1(self) -> WebElement: + return self.wait_for(self.labelAdministrativeLevel1) + + def getLabelAdministrativeLevel2(self) -> WebElement: + return self.wait_for(self.labelAdministrativeLevel2) + + def getLabelAdministrativeLevel3(self) -> WebElement: + return self.wait_for(self.labelAdministrativeLevel3) + + def getLabelAdministrativeLevel4(self) -> WebElement: + return self.wait_for(self.labelAdministrativeLevel4) + + def getLabelGeolocation(self) -> WebElement: + return self.wait_for(self.labelGeolocation) + + def getLabelDataCollectingType(self) -> WebElement: + return self.wait_for(self.labelDataCollectingType) + + def getLabelObservedDisabilities(self) -> WebElement: + return self.wait_for(self.labelObservedDisabilities) + + def getLabelSeeingDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelSeeingDisabilitySeverity) + + def getLabelHearingDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelHearingDisabilitySeverity) + + def getLabelPhysicalDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelPhysicalDisabilitySeverity) + + def getLabelRememberingOrConcentratingDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelRememberingOrConcentratingDisabilitySeverity) + + def getLabelSelfCareDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelSelfCareDisabilitySeverity) + + def getLabelCommunicatingDisabilitySeverity(self) -> WebElement: + return self.wait_for(self.labelCommunicatingDisabilitySeverity) + + def getLabelDisability(self) -> WebElement: + return self.wait_for(self.labelDisability) + + def getLabelBirthCertificate(self) -> WebElement: + return self.wait_for(self.labelBirthCertificate) + + def getLabelIssued(self) -> WebElement: + return self.wait_for(self.labelIssued) + + def getLabelDriverLicense(self) -> WebElement: + return self.wait_for(self.labelDriverLicense) + + def getLabelElectoralCard(self) -> WebElement: + return self.wait_for(self.labelElectoralCard) + + def getLabelNationalPassport(self) -> WebElement: + return self.wait_for(self.labelNationalPassport) + + def getLabelNationalId(self) -> WebElement: + return self.wait_for(self.labelNationalId) + + def getLabelUnhcrId(self) -> WebElement: + return self.wait_for(self.labelUnhcrId) + + def getLabelWfpId(self) -> WebElement: + return self.wait_for(self.labelWfpId) + + def getLabelEmail(self) -> WebElement: + return self.wait_for(self.labelEmail) + + def getLabelPhoneNumber(self) -> WebElement: + return self.wait_for(self.labelPhoneNumber) + + def getLabelAlternativePhoneNumber(self) -> WebElement: + return self.wait_for(self.labelAlternativePhoneNumber) + + def getLabelDateOfLastScreeningAgainstSanctionsList(self) -> WebElement: + return self.wait_for(self.labelDateOfLastScreeningAgainstSanctionsList) + + def getLabelLinkedGrievances(self) -> WebElement: + return self.wait_for(self.labelLinkedGrievances) + + def getLabelWalletName(self) -> WebElement: + return self.wait_for(self.labelWalletName) + + def getLabelBlockchainName(self) -> WebElement: + return self.wait_for(self.labelBlockchainName) + + def getLabelWalletAddress(self) -> WebElement: + return self.wait_for(self.labelWalletAddress) + + def getLabelCashReceived(self) -> WebElement: + return self.wait_for(self.labelCashReceived) + + def getLabelTotalCashReceived(self) -> WebElement: + return self.wait_for(self.labelTotalCashReceived) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getTableLabel(self) -> WebElement: + return self.wait_for(self.tableLabel) + + def getStatusContainer(self) -> WebElement: + return self.wait_for(self.statusContainer) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getLabelSource(self) -> WebElement: + return self.wait_for(self.labelSource) + + def getLabelImportName(self) -> WebElement: + return self.wait_for(self.labelImportName) + + def getLabelRegistrationDate(self) -> WebElement: + return self.wait_for(self.labelRegistrationDate) + + def getLabelUserName(self) -> WebElement: + return self.wait_for(self.labelUserName) diff --git a/backend/selenium_tests/page_object/registration_data_import/registration_data_import.py b/backend/selenium_tests/page_object/registration_data_import/registration_data_import.py index fd0972af0b..5fefab77fc 100644 --- a/backend/selenium_tests/page_object/registration_data_import/registration_data_import.py +++ b/backend/selenium_tests/page_object/registration_data_import/registration_data_import.py @@ -110,7 +110,7 @@ def getButtonImportFile(self) -> WebElement: return self.wait_for(self.buttonImportRDI) def disappearButtonImportFile(self) -> None: - self.wait_for_disappear(self.buttonImportRDI, timeout=20) + self.wait_for_disappear(self.buttonImportRDI, timeout=30) def getExcelItem(self) -> WebElement: return self.wait_for(self.excelItem) diff --git a/backend/selenium_tests/people/test_people.py b/backend/selenium_tests/people/test_people.py new file mode 100644 index 0000000000..d185f155ca --- /dev/null +++ b/backend/selenium_tests/people/test_people.py @@ -0,0 +1,177 @@ +from datetime import datetime + +from django.db import transaction + +import pytest +from dateutil.relativedelta import relativedelta +from page_object.people.people import People + +from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory +from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType +from hct_mis_api.apps.household.fixtures import ( + create_household, + create_individual_document, +) +from hct_mis_api.apps.household.models import HOST, SEEING, Individual +from hct_mis_api.apps.program.fixtures import ProgramFactory +from hct_mis_api.apps.program.models import Program +from selenium_tests.page_object.people.people_details import PeopleDetails + +pytestmark = pytest.mark.django_db(transaction=True) + + +@pytest.fixture +def social_worker_program() -> Program: + return get_program_with_dct_type_and_name("Worker Program", "WORK", DataCollectingType.Type.SOCIAL, Program.ACTIVE) + + +@pytest.fixture +def add_people(social_worker_program: Program) -> None: + ba = social_worker_program.business_area + with transaction.atomic(): + household, individuals = create_household( + household_args={"business_area": ba, "program": social_worker_program, "residence_status": HOST}, + individual_args={ + "full_name": "Stacey Freeman", + "given_name": "Stacey", + "middle_name": "", + "family_name": "Freeman", + "business_area": ba, + "observed_disability": [SEEING], + }, + ) + individual = individuals[0] + create_individual_document(individual) + + +def get_program_with_dct_type_and_name( + name: str, programme_code: str, dct_type: str = DataCollectingType.Type.STANDARD, status: str = Program.DRAFT +) -> Program: + BusinessArea.objects.filter(slug="afghanistan").update(is_payment_plan_applicable=True) + dct = DataCollectingTypeFactory(type=dct_type) + program = ProgramFactory( + name=name, + programme_code=programme_code, + start_date=datetime.now() - relativedelta(months=1), + end_date=datetime.now() + relativedelta(months=1), + data_collecting_type=dct, + status=status, + ) + return program + + +@pytest.mark.usefixtures("login") +class TestSmokePeople: + def test_smoke_page_people(self, social_worker_program: Program, pagePeople: People) -> None: + pagePeople.selectGlobalProgramFilter("Worker Program").click() + pagePeople.getNavPeople().click() + assert "People" in pagePeople.getTableTitle().text + assert "Individual ID" in pagePeople.getIndividualId().text + assert "Individual" in pagePeople.getIndividualName().text + assert "Type" in pagePeople.getIndividualAge().text + assert "Gender" in pagePeople.getIndividualSex().text + assert "Administrative Level 2" in pagePeople.getIndividualLocation().text + assert "Rows per page: 10 0–0 of 0" in pagePeople.getTablePagination().text.replace("\n", " ") + + def test_smoke_page_details_people( + self, + add_people: None, + pagePeople: People, + pagePeopleDetails: PeopleDetails, + ) -> None: + pagePeople.selectGlobalProgramFilter("Worker Program").click() + pagePeople.getNavPeople().click() + unicef_id = pagePeople.getIndividualTableRow(0).text.split(" ")[0] + pagePeople.getIndividualTableRow(0).click() + individual = Individual.objects.filter(unicef_id=unicef_id).first() + assert f"Individual ID: {individual.unicef_id}" in pagePeopleDetails.getPageHeaderTitle().text + assert "Stacey Freeman" in pagePeopleDetails.getLabelFullName().text + assert "Stacey" in pagePeopleDetails.getLabelGivenName().text + assert "-" in pagePeopleDetails.getLabelMiddleName().text + assert "Freeman" in pagePeopleDetails.getLabelFamilyName().text + assert individual.sex.lower() in pagePeopleDetails.getLabelGender().text.lower() + assert pagePeopleDetails.getLabelAge().text + assert individual.birth_date.strftime("%-d %b %Y") in pagePeopleDetails.getLabelDateOfBirth().text + assert pagePeopleDetails.getLabelEstimatedDateOfBirth().text + assert individual.marital_status.lower() in pagePeopleDetails.getLabelMaritalStatus().text.lower() + assert "Not provided" in pagePeopleDetails.getLabelWorkStatus().text + assert pagePeopleDetails.getLabelPregnant().text + assert pagePeopleDetails.getLabelRole().text + assert ( + individual.preferred_language + if individual.preferred_language + else "-" in pagePeopleDetails.getLabelPreferredLanguage().text + ) + assert "Non-displaced | Host" in pagePeopleDetails.getLabelResidenceStatus().text + assert ( + individual.household.country + if individual.household.country + else "-" in pagePeopleDetails.getLabelCountry().text + ) + assert ( + individual.household.country_origin + if individual.household.country_origin + else "-" in pagePeopleDetails.getLabelCountryOfOrigin().text + ) + assert ( + individual.household.address + if individual.household.address + else "-" in pagePeopleDetails.getLabelAddress().text + ) + assert ( + individual.household.village + if individual.household.village + else "-" in pagePeopleDetails.getLabelVilage().text + ) + assert ( + individual.household.zip_code + if individual.household.zip_code + else "-" in pagePeopleDetails.getLabelZipCode().text + ) + assert ( + individual.household.admin1 + if individual.household.admin1 + else "-" in pagePeopleDetails.getLabelAdministrativeLevel1().text + ) + assert ( + individual.household.admin2 + if individual.household.admin2 + else "-" in pagePeopleDetails.getLabelAdministrativeLevel2().text + ) + assert ( + individual.household.admin3 + if individual.household.admin3 + else "-" in pagePeopleDetails.getLabelAdministrativeLevel3().text + ) + assert ( + individual.household.admin4 + if individual.household.admin4 + else "-" in pagePeopleDetails.getLabelAdministrativeLevel4().text + ) + assert ( + individual.household.geopoint + if individual.household.geopoint + else "-" in pagePeopleDetails.getLabelGeolocation().text + ) + assert pagePeopleDetails.getLabelDataCollectingType().text + assert pagePeopleDetails.getLabelObservedDisabilities().text + assert pagePeopleDetails.getLabelSeeingDisabilitySeverity().text + assert pagePeopleDetails.getLabelHearingDisabilitySeverity().text + assert pagePeopleDetails.getLabelPhysicalDisabilitySeverity().text + assert pagePeopleDetails.getLabelRememberingOrConcentratingDisabilitySeverity().text + assert pagePeopleDetails.getLabelCommunicatingDisabilitySeverity().text + assert "Not Disabled" in pagePeopleDetails.getLabelDisability().text + assert pagePeopleDetails.getLabelIssued().text + assert pagePeopleDetails.getLabelEmail().text + assert pagePeopleDetails.getLabelPhoneNumber().text + assert pagePeopleDetails.getLabelAlternativePhoneNumber().text + assert pagePeopleDetails.getLabelDateOfLastScreeningAgainstSanctionsList().text + assert pagePeopleDetails.getLabelLinkedGrievances().text + assert pagePeopleDetails.getLabelWalletName().text + assert pagePeopleDetails.getLabelBlockchainName().text + assert pagePeopleDetails.getLabelWalletAddress().text + assert "Rows per page: 5 0–0 of 0" in pagePeopleDetails.getTablePagination().text.replace("\n", " ") + assert pagePeopleDetails.getLabelSource().text + assert pagePeopleDetails.getLabelImportName().text + assert pagePeopleDetails.getLabelRegistrationDate().text + assert pagePeopleDetails.getLabelUserName().text diff --git a/backend/selenium_tests/program_details/test_program_details.py b/backend/selenium_tests/program_details/test_program_details.py index ae4365d3cd..dcaf0c3793 100644 --- a/backend/selenium_tests/program_details/test_program_details.py +++ b/backend/selenium_tests/program_details/test_program_details.py @@ -83,7 +83,7 @@ def test_program_details(self, standard_program: Program, pageProgrammeDetails: ) assert program.administrative_areas_of_implementation in pageProgrammeDetails.getLabelAdministrativeAreas().text assert program.description in pageProgrammeDetails.getLabelDescription().text - assert "No" in pageProgrammeDetails.getLabelCashPlus().text + assert "Yes" if program.cash_plus else "No" in pageProgrammeDetails.getLabelCashPlus().text assert "Only selected partners within the business area" in pageProgrammeDetails.getLabelPartnerAccess().text assert "0" in pageProgrammeDetails.getLabelProgramSize().text diff --git a/backend/selenium_tests/programme_population/test_households.py b/backend/selenium_tests/programme_population/test_households.py index fa3f06d0f5..7d79b8dd1f 100644 --- a/backend/selenium_tests/programme_population/test_households.py +++ b/backend/selenium_tests/programme_population/test_households.py @@ -18,7 +18,6 @@ def create_programs() -> None: @pytest.fixture def add_households() -> None: call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/registration_data/fixtures/data-cypress.json") - call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/documenttype.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data-cypress.json") return diff --git a/backend/selenium_tests/programme_population/test_individuals.py b/backend/selenium_tests/programme_population/test_individuals.py index 4a3547bf10..c552891623 100644 --- a/backend/selenium_tests/programme_population/test_individuals.py +++ b/backend/selenium_tests/programme_population/test_individuals.py @@ -18,7 +18,6 @@ def create_programs() -> None: @pytest.fixture def add_households() -> None: call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/registration_data/fixtures/data-cypress.json") - call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/documenttype.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data-cypress.json") return diff --git a/backend/selenium_tests/registration_data_import/test_registration_data_import.py b/backend/selenium_tests/registration_data_import/test_registration_data_import.py index 274c10aec7..a196e8ab20 100644 --- a/backend/selenium_tests/registration_data_import/test_registration_data_import.py +++ b/backend/selenium_tests/registration_data_import/test_registration_data_import.py @@ -165,6 +165,7 @@ def test_smoke_registration_data_import_happy_path( pageDetailsRegistrationDataImport.getButtonMergeRdi().click() pageDetailsRegistrationDataImport.getButtonMerge().click() pageDetailsRegistrationDataImport.waitForStatus("MERGED") + assert "MERGED" == pageDetailsRegistrationDataImport.getStatusContainer().text assert "VIEW TICKETS" in pageDetailsRegistrationDataImport.getButtonViewTickets().text pageDetailsRegistrationDataImport.getButtonIndividuals().click() pageDetailsRegistrationDataImport.getButtonHouseholds().click() diff --git a/backend/selenium_tests/targeting/test_targeting.py b/backend/selenium_tests/targeting/test_targeting.py index 467d213380..25fd27fbc1 100644 --- a/backend/selenium_tests/targeting/test_targeting.py +++ b/backend/selenium_tests/targeting/test_targeting.py @@ -18,7 +18,7 @@ from hct_mis_api.apps.program.fixtures import ProgramFactory from hct_mis_api.apps.program.models import Program -pytestmark = pytest.mark.django_db(transaction=True) +pytestmark = pytest.mark.django_db(transaction=True, databases=["registration_datahub", "default"]) @pytest.fixture @@ -98,7 +98,6 @@ def create_programs() -> None: @pytest.fixture def add_targeting() -> None: - call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/documenttype.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/registration_data/fixtures/data-cypress.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/household/fixtures/data-cypress.json") call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/targeting/fixtures/data-cypress.json") diff --git a/backend/selenium_tests/tools/tag_name_finder.py b/backend/selenium_tests/tools/tag_name_finder.py index d44fce2e68..d59929a53c 100644 --- a/backend/selenium_tests/tools/tag_name_finder.py +++ b/backend/selenium_tests/tools/tag_name_finder.py @@ -50,6 +50,8 @@ def printing(what: str, web_driver: WebDriver, label: str = "data-cy", page_obje exit_loop = "" while exit_loop != "exit": exit_loop = input("Open the page and press Enter or write exit") - printing("Labels", driver) + printing("Mapping", driver) print("\n") printing("Methods", driver) + print("\n") + printing("Assert", driver)