Skip to content

Commit

Permalink
Selenium: People - Smoke Tests (#3963)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
szymon-kellton and pavlo-mk authored Jul 9, 2024
1 parent 1d42fad commit fd67704
Show file tree
Hide file tree
Showing 15 changed files with 641 additions and 15 deletions.
1 change: 1 addition & 0 deletions backend/hct_mis_api/apps/household/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
72 changes: 66 additions & 6 deletions backend/selenium_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"):
Expand All @@ -428,28 +442,74 @@ 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()
ba_partner_through, _ = BusinessAreaPartnerThrough.objects.get_or_create(
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


Expand Down
1 change: 0 additions & 1 deletion backend/selenium_tests/grievance/feedback/test_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions backend/selenium_tests/page_object/base_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]'
Expand Down Expand Up @@ -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)

Expand Down
134 changes: 134 additions & 0 deletions backend/selenium_tests/page_object/people/people.py
Original file line number Diff line number Diff line change
@@ -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]
Loading

0 comments on commit fd67704

Please sign in to comment.