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 module tests #4164

Merged
merged 14 commits into from
Sep 12, 2024
Merged
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
Loading