Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium: People - Smoke Tests #3963

Merged
merged 27 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a05ff0c
Init
szymon-kellton Jun 12, 2024
cce7542
Init
szymon-kellton Jun 12, 2024
47e9f34
fix init fixtures
pavlo-mk Jun 13, 2024
8efbf79
Merge branch 'develop' into selenium/people_smoke_tests
szymon-kellton Jun 14, 2024
b70dbb2
Added test_smoke_page_people
szymon-kellton Jun 14, 2024
51de34b
Merge remote-tracking branch 'origin/selenium/people_smoke_tests' int…
szymon-kellton Jun 14, 2024
2bc880a
Black
szymon-kellton Jun 14, 2024
434901f
Added test_smoke_page_people
szymon-kellton Jun 17, 2024
37fd4ef
Added test_smoke_page_people
szymon-kellton Jun 17, 2024
343c980
Merge remote-tracking branch 'origin/develop' into selenium/people_sm…
szymon-kellton Jun 17, 2024
2985644
Merge remote-tracking branch 'origin/develop' into selenium/people_sm…
szymon-kellton Jun 17, 2024
1a32b0f
More fixes
szymon-kellton Jun 17, 2024
df6e0a6
Fixed
szymon-kellton Jun 17, 2024
a6cfd8a
Isort
szymon-kellton Jun 17, 2024
d1a046e
add fixtures for people
pavlo-mk Jun 24, 2024
1f86dd5
people
pavlo-mk Jun 24, 2024
c1c68be
fix program status
pavlo-mk Jun 24, 2024
46356c4
Unskip and fix test_smoke_page_details_people
szymon-kellton Jun 25, 2024
c880706
Black
szymon-kellton Jun 25, 2024
867009c
Merge remote-tracking branch 'origin/develop' into selenium/people_sm…
szymon-kellton Jul 8, 2024
dafef10
Merge remote-tracking branch 'origin/develop' into selenium/people_sm…
szymon-kellton Jul 8, 2024
91b97bd
Test
szymon-kellton Jul 8, 2024
e05117e
Merge remote-tracking branch 'origin/develop' into selenium/people_sm…
szymon-kellton Jul 9, 2024
221dbaa
Fix test_smoke_page_details_people
szymon-kellton Jul 9, 2024
0833860
Merge branch 'develop' into selenium/people_smoke_tests
szymon-kellton Jul 9, 2024
98af710
In progress test_smoke_registration_data_import_happy_path
szymon-kellton Jul 9, 2024
cac5e70
Merge remote-tracking branch 'origin/selenium/people_smoke_tests' int…
szymon-kellton Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

szymon-kellton marked this conversation as resolved.
Show resolved Hide resolved
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
Loading