From 70be31b15a00418a85dd42a11ab98f456f70a08e Mon Sep 17 00:00:00 2001 From: Patryk Dabrowski Date: Tue, 9 Jul 2024 12:07:50 +0200 Subject: [PATCH 1/3] Rename migration (#4023) --- .../migrations/{0002_migration.py => 0018_migration.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename backend/hct_mis_api/apps/erp_datahub/migrations/{0002_migration.py => 0018_migration.py} (100%) diff --git a/backend/hct_mis_api/apps/erp_datahub/migrations/0002_migration.py b/backend/hct_mis_api/apps/erp_datahub/migrations/0018_migration.py similarity index 100% rename from backend/hct_mis_api/apps/erp_datahub/migrations/0002_migration.py rename to backend/hct_mis_api/apps/erp_datahub/migrations/0018_migration.py From fd677045814b114f173d884dc19424ded186d77f Mon Sep 17 00:00:00 2001 From: szymon-kellton <130459593+szymon-kellton@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:20:45 +0200 Subject: [PATCH 2/3] Selenium: People - Smoke Tests (#3963) * Init * Init * fix init fixtures * Added test_smoke_page_people * Black * Added test_smoke_page_people * Added test_smoke_page_people * More fixes * Fixed * Isort * add fixtures for people * people * fix program status * Unskip and fix test_smoke_page_details_people * Black * Test * Fix test_smoke_page_details_people * In progress test_smoke_registration_data_import_happy_path --------- Co-authored-by: Pavlo Mokiichuk --- .../hct_mis_api/apps/household/fixtures.py | 1 + backend/selenium_tests/conftest.py | 72 ++++- .../grievance/feedback/test_feedback.py | 1 - .../test_grievance_tickets.py | 1 - .../page_object/base_components.py | 4 + .../page_object/people/people.py | 134 ++++++++++ .../page_object/people/people_details.py | 252 ++++++++++++++++++ .../registration_data_import.py | 2 +- backend/selenium_tests/people/test_people.py | 177 ++++++++++++ .../program_details/test_program_details.py | 2 +- .../programme_population/test_households.py | 1 - .../programme_population/test_individuals.py | 1 - .../test_registration_data_import.py | 1 + .../targeting/test_targeting.py | 3 +- .../selenium_tests/tools/tag_name_finder.py | 4 +- 15 files changed, 641 insertions(+), 15 deletions(-) create mode 100644 backend/selenium_tests/page_object/people/people.py create mode 100644 backend/selenium_tests/page_object/people/people_details.py create mode 100644 backend/selenium_tests/people/test_people.py 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) From 46d5ff1ce1fba4487446940c52289007f96c9de2 Mon Sep 17 00:00:00 2001 From: szymon-kellton <130459593+szymon-kellton@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:44:51 +0200 Subject: [PATCH 3/3] Selenium Accountability Surveys - Smoke tests (#3997) * Init * Test * Added add_accountability_surveys_message * Added test_smoke_accountability_surveys_details * Isort --- .../accountability/test_surveys.py | 134 ++++++++++++++++++ backend/selenium_tests/conftest.py | 12 ++ .../page_object/accountability/surveys.py | 95 +++++++++++-- .../accountability/surveys_details.py | 86 +++++++++++ 4 files changed, 313 insertions(+), 14 deletions(-) create mode 100644 backend/selenium_tests/accountability/test_surveys.py create mode 100644 backend/selenium_tests/page_object/accountability/surveys_details.py diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py new file mode 100644 index 0000000000..7723c1b6f7 --- /dev/null +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -0,0 +1,134 @@ +from django.db import transaction + +import pytest +from helpers.fixtures import get_program_with_dct_type_and_name +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails + +from hct_mis_api.apps.account.models import User +from hct_mis_api.apps.accountability.fixtures import SurveyFactory +from hct_mis_api.apps.accountability.models import Survey +from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType +from hct_mis_api.apps.household.fixtures import create_household_and_individuals +from hct_mis_api.apps.household.models import REFUGEE, Household +from hct_mis_api.apps.program.models import Program +from hct_mis_api.apps.targeting.fixtures import ( + TargetingCriteriaFactory, + TargetPopulationFactory, +) + +pytestmark = pytest.mark.django_db(transaction=True) + + +@pytest.fixture +def test_program() -> Program: + return get_program_with_dct_type_and_name("Test Program", "NORM", DataCollectingType.Type.STANDARD) + + +@pytest.fixture +def add_household() -> Household: + program = Program.objects.first() + with transaction.atomic(): + household, individuals = create_household_and_individuals( + household_data={"business_area": program.business_area, "program": program, "residence_status": REFUGEE}, + individuals_data=[ + {"business_area": program.business_area, "observed_disability": []}, + ], + ) + return household + + +@pytest.fixture +def add_accountability_surveys_message() -> Survey: + targeting_criteria = TargetingCriteriaFactory() + + target_population = TargetPopulationFactory( + created_by=User.objects.first(), + targeting_criteria=targeting_criteria, + business_area=BusinessArea.objects.first(), + ) + return SurveyFactory( + title="Test survey", + category="MANUAL", + unicef_id="SUR-24-0005", + target_population=target_population, + created_by=User.objects.first(), + ) + + +@pytest.mark.usefixtures("login") +class TestSmokeAccountabilitySurveys: + def test_smoke_accountability_surveys( + self, + test_program: Program, + add_accountability_surveys_message: Survey, + pageAccountabilitySurveys: AccountabilitySurveys, + ) -> None: + pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() + pageAccountabilitySurveys.getNavAccountability().click() + pageAccountabilitySurveys.getNavSurveys().click() + + assert "Surveys" in pageAccountabilitySurveys.getPageHeaderTitle().text + assert "NEW SURVEY" in pageAccountabilitySurveys.getButtonNewSurvey().text + assert "Search" in pageAccountabilitySurveys.getFiltersSearch().text + assert "Target Population" in pageAccountabilitySurveys.getTargetPopulationInput().text + assert "Created by" in pageAccountabilitySurveys.getFiltersCreatedByAutocomplete().text + assert "Created by" in pageAccountabilitySurveys.getCreatedByInput().text + assert "From" in pageAccountabilitySurveys.getFiltersCreationDateFrom().text + assert "To" in pageAccountabilitySurveys.getFiltersCreationDateTo().text + assert "CLEAR" in pageAccountabilitySurveys.getButtonFiltersClear().text + assert "APPLY" in pageAccountabilitySurveys.getButtonFiltersApply().text + assert "Surveys List" in pageAccountabilitySurveys.getTableTitle().text + assert "Survey ID" in pageAccountabilitySurveys.getTableLabel()[0].text + assert "Survey Title" in pageAccountabilitySurveys.getTableLabel()[1].text + assert "Category" in pageAccountabilitySurveys.getTableLabel()[2].text + assert "Number of Recipients" in pageAccountabilitySurveys.getTableLabel()[3].text + assert "Created by" in pageAccountabilitySurveys.getTableLabel()[4].text + assert "Creation Date" in pageAccountabilitySurveys.getTableLabel()[5].text + assert "10 1–1 of 1" in pageAccountabilitySurveys.getTablePagination().text.replace("\n", " ") + assert 1 == len(pageAccountabilitySurveys.getRows()) + assert "SUR-24-0005" in pageAccountabilitySurveys.getRows()[0].text + assert "Test survey" in pageAccountabilitySurveys.getRows()[0].text + + def test_smoke_accountability_surveys_details( + self, + test_program: Program, + add_accountability_surveys_message: Survey, + add_household: Household, + pageAccountabilitySurveys: AccountabilitySurveys, + pageAccountabilitySurveysDetails: AccountabilitySurveysDetails, + ) -> None: + add_accountability_surveys_message.recipients.set([Household.objects.first()]) + pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() + pageAccountabilitySurveys.getNavAccountability().click() + pageAccountabilitySurveys.getNavSurveys().click() + pageAccountabilitySurveys.getRows()[0].click() + + assert "SUR-24-0005" in pageAccountabilitySurveysDetails.getPageHeaderTitle().text + assert "Survey with manual process" in pageAccountabilitySurveysDetails.getLabelCategory().text + assert "Test survey" in pageAccountabilitySurveysDetails.getLabelSurveyTitle().text + created_by = add_accountability_surveys_message.created_by + assert ( + f"{created_by.first_name} {created_by.last_name}" + in pageAccountabilitySurveysDetails.getLabelCreatedBy().text + ) + assert ( + add_accountability_surveys_message.created_at.strftime("%-d %b %Y") + in pageAccountabilitySurveysDetails.getLabelDateCreated().text + ) + assert "Test Program" in pageAccountabilitySurveysDetails.getLabelProgramme().text + assert "Household Id" in pageAccountabilitySurveysDetails.getHouseholdId().text + assert "Status" in pageAccountabilitySurveysDetails.getStatus().text + assert "Head of Household" in pageAccountabilitySurveysDetails.getHouseholdHeadName().text + assert "Household Size" in pageAccountabilitySurveysDetails.getHouseholdSize().text + assert "Administrative Level 2" in pageAccountabilitySurveysDetails.getHouseholdLocation().text + assert "Residence Status" in pageAccountabilitySurveysDetails.getHouseholdResidenceStatus().text + assert "Registration Date" in pageAccountabilitySurveysDetails.getHouseholdRegistrationDate().text + assert "Rows per page: 10 1–1 of 1" in pageAccountabilitySurveysDetails.getTablePagination().text.replace( + "\n", " " + ) + assert 1 == len(pageAccountabilitySurveys.getRows()) + assert ( + add_accountability_surveys_message.recipients.all()[0].unicef_id + in pageAccountabilitySurveys.getRows()[0].text + ) diff --git a/backend/selenium_tests/conftest.py b/backend/selenium_tests/conftest.py index 855081a5d9..06a91c2c28 100644 --- a/backend/selenium_tests/conftest.py +++ b/backend/selenium_tests/conftest.py @@ -14,6 +14,8 @@ from page_object.accountability.comunication_details import ( AccountabilityCommunicationDetails, ) +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails from page_object.admin_panel.admin_panel import AdminPanel from page_object.country_dashboard.country_dashboard import CountryDashboard from page_object.filters import Filters @@ -347,6 +349,16 @@ def pageNewPaymentPlan(request: FixtureRequest, browser: Chrome) -> NewPaymentPl yield NewPaymentPlan(browser) +@pytest.fixture +def pageAccountabilitySurveys(request: FixtureRequest, browser: Chrome) -> AccountabilitySurveys: + yield AccountabilitySurveys(browser) + + +@pytest.fixture +def pageAccountabilitySurveysDetails(request: FixtureRequest, browser: Chrome) -> AccountabilitySurveysDetails: + yield AccountabilitySurveysDetails(browser) + + @pytest.fixture def pageProgrammeUsers(request: FixtureRequest, browser: Chrome) -> ProgrammeUsers: yield ProgrammeUsers(browser) diff --git a/backend/selenium_tests/page_object/accountability/surveys.py b/backend/selenium_tests/page_object/accountability/surveys.py index d10dbec612..555ba9db16 100644 --- a/backend/selenium_tests/page_object/accountability/surveys.py +++ b/backend/selenium_tests/page_object/accountability/surveys.py @@ -2,12 +2,29 @@ from selenium.webdriver.remote.webelement import WebElement -class SurveysPage(BaseComponents): +class AccountabilitySurveys(BaseComponents): # Locators - titlePage = 'h5[data-cy="page-header-title"]' + pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + buttonNewSurvey = 'button[data-cy="button-new-survey"]' + filtersSearch = 'div[data-cy="filters-search"]' + filtersTargetPopulationAutocomplete = 'div[data-cy="filters-target-population-autocomplete"]' + targetPopulationInput = 'div[data-cy="Target Population-input"]' + filtersCreatedByAutocomplete = 'div[data-cy="filters-created-by-autocomplete"]' + createdByInput = 'div[data-cy="Created by-input"]' + filtersCreationDateFrom = 'div[data-cy="filters-creation-date-from"]' + filtersCreationDateTo = 'div[data-cy="filters-creation-date-to"]' + buttonFiltersClear = 'button[data-cy="button-filters-clear"]' + buttonFiltersApply = 'button[data-cy="button-filters-apply"]' + tableTitle = 'h6[data-cy="table-title"]' + tableLabel = 'span[data-cy="table-label"]' + tablePagination = 'div[data-cy="table-pagination"]' + menuItemRapidPro = 'li[data-cy="menu-item-rapid-pro"]' + menuItemRapidProText = 'div[data-cy="menu-item-rapid-pro-text"]' + menuItemSmsText = 'li[data-cy="menu-item-sms-text"]' + menuItemManual = 'li[data-cy="menu-item-manual"]' + menuItemManualText = 'div[data-cy="menu-item-manual-text"]' rows = 'tr[role="checkbox"]' - buttonApply = 'button[data-cy="button-filters-apply"]' - buttonClear = 'button[data-cy="button-filters-clear"]' # Texts textTitlePage = "Surveys" @@ -16,17 +33,67 @@ class SurveysPage(BaseComponents): textTabCreatedBy = "Created by" # Elements - def getTitlePage(self) -> WebElement: - return self.wait_for(self.titlePage) + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) - def getMessageID(self) -> WebElement: - return self.wait_for(self.tabColumnLabel).eq(0) + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) - def getApply(self) -> WebElement: - return self.wait_for(self.buttonApply) + def getButtonNewSurvey(self) -> WebElement: + return self.wait_for(self.buttonNewSurvey) - def getClear(self) -> WebElement: - return self.wait_for(self.buttonClear) + def getFiltersSearch(self) -> WebElement: + return self.wait_for(self.filtersSearch) - def getTargetPopulationsRows(self) -> WebElement: - return self.wait_for(self.rows) + def getFiltersTargetPopulationAutocomplete(self) -> WebElement: + return self.wait_for(self.filtersTargetPopulationAutocomplete) + + def getTargetPopulationInput(self) -> WebElement: + return self.wait_for(self.targetPopulationInput) + + def getFiltersCreatedByAutocomplete(self) -> WebElement: + return self.wait_for(self.filtersCreatedByAutocomplete) + + def getCreatedByInput(self) -> WebElement: + return self.wait_for(self.createdByInput) + + def getFiltersCreationDateFrom(self) -> WebElement: + return self.wait_for(self.filtersCreationDateFrom) + + def getFiltersCreationDateTo(self) -> WebElement: + return self.wait_for(self.filtersCreationDateTo) + + def getButtonFiltersClear(self) -> WebElement: + return self.wait_for(self.buttonFiltersClear) + + def getButtonFiltersApply(self) -> WebElement: + return self.wait_for(self.buttonFiltersApply) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getTableLabel(self) -> [WebElement]: + self.wait_for(self.tableLabel) + return self.get_elements(self.tableLabel) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getMenuItemRapidPro(self) -> WebElement: + return self.wait_for(self.menuItemRapidPro) + + def getMenuItemRapidProText(self) -> WebElement: + return self.wait_for(self.menuItemRapidProText) + + def getMenuItemSmsText(self) -> WebElement: + return self.wait_for(self.menuItemSmsText) + + def getMenuItemManual(self) -> WebElement: + return self.wait_for(self.menuItemManual) + + def getMenuItemManualText(self) -> WebElement: + return self.wait_for(self.menuItemManualText) + + def getRows(self) -> [WebElement]: + self.wait_for(self.rows) + return self.get_elements(self.rows) diff --git a/backend/selenium_tests/page_object/accountability/surveys_details.py b/backend/selenium_tests/page_object/accountability/surveys_details.py new file mode 100644 index 0000000000..3e92a1bd61 --- /dev/null +++ b/backend/selenium_tests/page_object/accountability/surveys_details.py @@ -0,0 +1,86 @@ +from page_object.base_components import BaseComponents +from selenium.webdriver.remote.webelement import WebElement + + +class AccountabilitySurveysDetails(BaseComponents): + pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + labelCategory = 'div[data-cy="label-Category"]' + labelSurveyTitle = 'div[data-cy="label-Survey Title"]' + labelCreatedBy = 'div[data-cy="label-Created By"]' + labelDateCreated = 'div[data-cy="label-Date Created"]' + labelTargetPopulation = 'div[data-cy="label-Target Population"]' + labelProgramme = 'div[data-cy="label-Programme"]' + tableTitle = 'h6[data-cy="table-title"]' + householdId = 'th[data-cy="household-id"]' + tableLabel = 'span[data-cy="table-label"]' + status = 'th[data-cy="status"]' + householdHeadName = 'th[data-cy="household-head-name"]' + householdSize = 'th[data-cy="household-size"]' + householdLocation = 'th[data-cy="household-location"]' + householdResidenceStatus = 'th[data-cy="household-residence-status"]' + householdRegistrationDate = 'th[data-cy="household-registration-date"]' + tableRow = 'tr[data-cy="table-row"]' + tablePagination = 'div[data-cy="table-pagination"]' + rows = 'tr[role="checkbox"]' + + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) + + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) + + def getLabelCategory(self) -> WebElement: + return self.wait_for(self.labelCategory) + + def getLabelSurveyTitle(self) -> WebElement: + return self.wait_for(self.labelSurveyTitle) + + def getLabelCreatedBy(self) -> WebElement: + return self.wait_for(self.labelCreatedBy) + + def getLabelDateCreated(self) -> WebElement: + return self.wait_for(self.labelDateCreated) + + def getLabelTargetPopulation(self) -> WebElement: + return self.wait_for(self.labelTargetPopulation) + + def getLabelProgramme(self) -> WebElement: + return self.wait_for(self.labelProgramme) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getHouseholdId(self) -> WebElement: + return self.wait_for(self.householdId) + + def getTableLabel(self) -> WebElement: + return self.wait_for(self.tableLabel) + + def getStatus(self) -> WebElement: + return self.wait_for(self.status) + + def getHouseholdHeadName(self) -> WebElement: + return self.wait_for(self.householdHeadName) + + def getHouseholdSize(self) -> WebElement: + return self.wait_for(self.householdSize) + + def getHouseholdLocation(self) -> WebElement: + return self.wait_for(self.householdLocation) + + def getHouseholdResidenceStatus(self) -> WebElement: + return self.wait_for(self.householdResidenceStatus) + + def getHouseholdRegistrationDate(self) -> WebElement: + return self.wait_for(self.householdRegistrationDate) + + def getTableRow(self) -> WebElement: + return self.wait_for(self.tableRow) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getRows(self) -> [WebElement]: + self.wait_for(self.rows) + return self.get_elements(self.rows)