Skip to content

Commit

Permalink
Selenium: People module tests (#4164)
Browse files Browse the repository at this point in the history
* Test people module

* In progress PDU tests to people

* Selenium: Fix tests (#4206)

* Fixing login tests; RDI test; seatch filter tests;

* Fixing tests

* Fixing test_create_programme_check_empty_mandatory_fields

* Added People module tests

---------

Co-authored-by: Jan Romaniak <[email protected]>
Co-authored-by: Marek Biczysko <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2024
1 parent 43c91f7 commit e31a731
Show file tree
Hide file tree
Showing 4 changed files with 416 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from time import sleep

from page_object.base_components import BaseComponents
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement


Expand Down Expand Up @@ -87,7 +88,9 @@ class GrievanceDetailsPage(BaseComponents):
labelPartner = 'div[data-cy="label-Partner"]'
labelAdministrativeLevel2 = 'div[data-cy="label-Administrative Level 2"]'
checkboxHouseholdData = 'span[data-cy="checkbox-household-data"]'
checkboxApprove = '//*[contains(@data, "checkbox")]'
checkboxIndividualData = 'span[data-cy="checkbox-requested-data-change"]'
checkboxRequestedDataChange = 'span[data-cy="checkbox-requested-data-change"]'
approveBoxNeedsAdjudicationTitle = 'h6[data-cy="approve-box-needs-adjudication-title"]'
buttonCreateLinkedTicket = 'button[data-cy="button-create-linked-ticket"]'
buttonMarkDistinct = 'button[data-cy="button-mark-distinct"]'
Expand Down Expand Up @@ -458,9 +461,17 @@ def getApproveBoxNeedsAdjudicationTitle(self) -> WebElement:
def getCheckboxHouseholdData(self) -> WebElement:
return self.wait_for(self.checkboxHouseholdData)

def getCheckboxApprove(self) -> [WebElement]:
self.wait_for(self.checkboxApprove, By.XPATH)
return self.get_elements(self.checkboxApprove, By.XPATH)

def getCheckboxIndividualData(self) -> WebElement:
return self.wait_for(self.checkboxIndividualData)

def getCheckboxRequestedDataChange(self) -> [WebElement]:
self.wait_for(self.checkboxRequestedDataChange)
return self.get_elements(self.checkboxRequestedDataChange)

def getButtonCreateLinkedTicket(self) -> WebElement:
return self.wait_for(self.buttonCreateLinkedTicket)

Expand Down
86 changes: 83 additions & 3 deletions backend/selenium_tests/people/test_people.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
from dateutil.relativedelta import relativedelta
from page_object.people.people import People
from selenium.webdriver.common.by import By

from hct_mis_api.apps.account.models import User
from hct_mis_api.apps.core.fixtures import DataCollectingTypeFactory
Expand All @@ -24,6 +25,11 @@
TargetPopulationFactory,
)
from selenium_tests.page_object.filters import Filters
from selenium_tests.page_object.grievance.details_grievance_page import (
GrievanceDetailsPage,
)
from selenium_tests.page_object.grievance.grievance_tickets import GrievanceTickets
from selenium_tests.page_object.grievance.new_ticket import NewTicket
from selenium_tests.page_object.people.people_details import PeopleDetails

pytestmark = pytest.mark.django_db(transaction=True)
Expand Down Expand Up @@ -237,6 +243,80 @@ def test_people_happy_path(
assert "DELIVERED FULLY" in pagePeopleDetails.getRows()[0].text
assert add_people_with_payment_record.unicef_id in pagePeopleDetails.getRows()[0].text

@pytest.mark.skip(reason="ToDo")
def test_check_data_after_grievance_ticket_processed(self) -> None:
pass

@pytest.mark.usefixtures("login")
class TestPeople:
@pytest.mark.parametrize(
"test_data",
[
pytest.param(
{"category": "Data Change", "type": "Individual Data Update"},
id="Data Change People Data Update",
)
],
)
def test_check_people_data_after_grievance_ticket_processed(
self,
pageGrievanceTickets: GrievanceTickets,
pageGrievanceNewTicket: NewTicket,
pageGrievanceDetailsPage: GrievanceDetailsPage,
add_people: List,
test_data: dict,
pagePeople: People,
pagePeopleDetails: PeopleDetails,
) -> None:
pageGrievanceTickets.getNavGrievance().click()
assert "Grievance Tickets" in pageGrievanceTickets.getGrievanceTitle().text
pageGrievanceTickets.getButtonNewTicket().click()
pageGrievanceNewTicket.getSelectCategory().click()
pageGrievanceNewTicket.select_option_by_name(str(test_data["category"]))
pageGrievanceNewTicket.getIssueType().click()
pageGrievanceNewTicket.element_clickable(f'li[data-cy="select-option-{test_data["type"]}"]')
pageGrievanceNewTicket.select_listbox_element(str(test_data["type"]))
assert test_data["category"] in pageGrievanceNewTicket.getSelectCategory().text
assert test_data["type"] in pageGrievanceNewTicket.getIssueType().text
pageGrievanceNewTicket.getButtonNext().click()
pageGrievanceNewTicket.getHouseholdTab()
pageGrievanceNewTicket.getIndividualTab().click()
pageGrievanceNewTicket.getIndividualTableRows(0).click()
pageGrievanceDetailsPage.screenshot("0")
pageGrievanceNewTicket.getButtonNext().click()
pageGrievanceNewTicket.getReceivedConsent().click()
pageGrievanceNewTicket.getButtonNext().click()

pageGrievanceNewTicket.getDescription().send_keys("Add Individual - TEST")
pageGrievanceNewTicket.getButtonAddNewField().click()
pageGrievanceNewTicket.getIndividualFieldName(0).click()
pageGrievanceNewTicket.select_option_by_name("Gender")
pageGrievanceNewTicket.getInputIndividualData("Gender").click()
pageGrievanceNewTicket.select_listbox_element("Female")
pageGrievanceNewTicket.getIndividualFieldName(1).click()
pageGrievanceNewTicket.select_option_by_name("Preferred language")
pageGrievanceNewTicket.getInputIndividualData("Preferred language").click()
pageGrievanceNewTicket.select_listbox_element("English | English")

pageGrievanceNewTicket.getButtonNext().click()
pageGrievanceDetailsPage.getCheckboxIndividualData()
row0 = pageGrievanceDetailsPage.getRows()[0].text.split(" ")
assert "Gender" in row0[0]
assert "Female" in row0[-1]

row1 = pageGrievanceDetailsPage.getRows()[1].text.split(" ")
assert "Preferred Language" in f"{row1[0]} {row1[1]}"
assert "English" in row1[-1]

pageGrievanceDetailsPage.getButtonAssignToMe().click()
pageGrievanceDetailsPage.getButtonSetInProgress().click()
pageGrievanceDetailsPage.getButtonSendForApproval().click()
pageGrievanceDetailsPage.getButtonCloseTicket()
pageGrievanceDetailsPage.getCheckboxRequestedDataChange()
pageGrievanceDetailsPage.getCheckboxRequestedDataChange()[0].find_element(By.TAG_NAME, "input").click()
pageGrievanceDetailsPage.getCheckboxRequestedDataChange()[1].find_element(By.TAG_NAME, "input").click()
pageGrievanceDetailsPage.getButtonApproval().click()
pageGrievanceDetailsPage.getButtonConfirm().click()
pageGrievanceDetailsPage.getButtonCloseTicket().click()
pageGrievanceDetailsPage.getButtonConfirm().click()
assert "Ticket ID" in pageGrievanceDetailsPage.getTitle().text
pagePeople.selectGlobalProgramFilter("Worker Program")
pagePeople.getNavPeople().click()
pagePeople.getIndividualTableRow(0).click()
Loading

0 comments on commit e31a731

Please sign in to comment.