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: Targeting smoke tests #3822

Merged
merged 20 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: E2E tests
continue-on-error: true
wozniakpl marked this conversation as resolved.
Show resolved Hide resolved
run: |
dist_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist dev_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev docker compose \
-f ./deployment/docker-compose.selenium.yml \
Expand Down
18 changes: 18 additions & 0 deletions backend/selenium_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from page_object.registration_data_import.registration_data_import import (
RegistrationDataImport,
)
from page_object.targeting.create_new import CreateNew
from page_object.targeting.t_details_page import DetailsTargeting
from page_object.targeting.targeting import Targeting
from pytest_django.live_server_helper import LiveServer
from requests import Session
from selenium import webdriver
Expand Down Expand Up @@ -225,6 +228,21 @@ def pageIndividualsDetails(request: FixtureRequest, browser: Chrome) -> Individu
yield IndividualsDetails(browser)


@pytest.fixture
def pageTargeting(request: FixtureRequest, browser: Chrome) -> Targeting:
yield Targeting(browser)


@pytest.fixture
def pageDetailsTargeting(request: FixtureRequest, browser: Chrome) -> DetailsTargeting:
yield DetailsTargeting(browser)


@pytest.fixture
def pageCreateTargeting(request: FixtureRequest, browser: Chrome) -> CreateNew:
yield CreateNew(browser)


@pytest.fixture
def business_area() -> BusinessArea:
business_area, _ = BusinessArea.objects.get_or_create(
Expand Down
2 changes: 1 addition & 1 deletion backend/selenium_tests/helpers/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class Common:
DEFAULT_TIMEOUT = 100
DEFAULT_TIMEOUT = 50

def __init__(self, driver: Chrome):
self.driver = driver
Expand Down
90 changes: 82 additions & 8 deletions backend/selenium_tests/page_object/targeting/create_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,85 @@


class CreateNew(BaseComponents):
# Locators
targetingCriteria = 'h6[data-cy="title-targeting-criteria"]'
# Texts
textTargetingCriteria = "Targeting Criteria"
# Elements

def getTargetingCriteria(self) -> WebElement:
return self.wait_for(self.targetingCriteria)
pageHeaderContainer = 'div[data-cy="page-header-container"]'
pageHeaderTitle = 'h5[data-cy="page-header-title"]'
buttonTargetPopulationCreate = 'button[data-cy="button-target-population-create"]'
inputDivName = 'div[data-cy="input-name"]'
inputIncludedHouseholdIds = 'div[data-cy="input-included-household-ids"]'
inputHouseholdids = 'input[data-cy="input-householdIds"]'
inputIncludedIndividualIds = 'div[data-cy="input-included-individual-ids"]'
inputIndividualids = 'input[data-cy="input-individualIds"]'
inputFlagexcludeifactiveadjudicationticket = 'span[data-cy="input-flagExcludeIfActiveAdjudicationTicket"]'
inputName = 'input[data-cy="input-name"]'

pageHeaderContainer = 'div[data-cy="page-header-container"]'
pageHeaderTitle = 'h5[data-cy="page-header-title"]'
buttonTargetPopulationCreate = 'button[data-cy="button-target-population-create"]'
divTargetPopulationAddCriteria = 'div[data-cy="button-target-population-add-criteria"]'
inputFlagexcludeifactiveadjudicationticket = 'span[data-cy="input-flagExcludeIfActiveAdjudicationTicket"]'
titleExcludedEntries = 'h6[data-cy="title-excluded-entries"]'
buttonShowHideExclusions = 'button[data-cy="button-show-hide-exclusions"]'
inputExcludedIds = 'div[data-cy="input-excluded-ids"]'
inputExcludedids = 'input[data-cy="input-excludedIds"]'
inputExclusionReason = 'div[data-cy="input-exclusion-reason"]'
titleAddFilter = 'h6[data-cy="title-add-filter"]'
autocompleteTargetCriteria = 'div[data-cy="autocomplete-target-criteria"]'
fieldChooserFilters = 'div[data-cy="field-chooser-filters[0]"]'
autocompleteTargetCriteriaOption = 'input[data-cy="autocomplete-target-criteria-option-0"]'
buttonHouseholdRule = 'button[data-cy="button-household-rule"]'
buttonIndividualRule = 'button[data-cy="button-individual-rule"]'
buttonTargetPopulationAddCriteria = 'button[data-cy="button-target-population-add-criteria"]'

def getPageHeaderTitle(self) -> WebElement:
return self.wait_for(self.pageHeaderTitle)

def getButtonTargetPopulationCreate(self) -> WebElement:
return self.wait_for(self.buttonTargetPopulationCreate)

def getInputName(self) -> WebElement:
return self.wait_for(self.inputName)

def getInputIncludedHouseholdIds(self) -> WebElement:
return self.wait_for(self.inputIncludedHouseholdIds)

def getInputHouseholdids(self) -> WebElement:
return self.wait_for(self.inputHouseholdids)

def getInputIncludedIndividualIds(self) -> WebElement:
return self.wait_for(self.inputIncludedIndividualIds)

def getInputIndividualids(self) -> WebElement:
return self.wait_for(self.inputIndividualids)

def getInputFlagexcludeifactiveadjudicationticket(self) -> WebElement:
return self.wait_for(self.inputFlagexcludeifactiveadjudicationticket)

def getButtonTargetPopulationAddCriteria(self) -> WebElement:
return self.wait_for(self.buttonTargetPopulationAddCriteria)

def getDivTargetPopulationAddCriteria(self) -> WebElement:
return self.wait_for(self.divTargetPopulationAddCriteria)

def getTitleExcludedEntries(self) -> WebElement:
return self.wait_for(self.titleExcludedEntries)

def getButtonShowHideExclusions(self) -> WebElement:
return self.wait_for(self.buttonShowHideExclusions)

def getInputExcludedIds(self) -> WebElement:
return self.wait_for(self.inputExcludedIds)

def getInputExcludedids(self) -> WebElement:
return self.wait_for(self.inputExcludedids)

def getInputExclusionReason(self) -> WebElement:
return self.wait_for(self.inputExclusionReason)

def getButtonHouseholdRule(self) -> WebElement:
return self.wait_for(self.buttonHouseholdRule)

def getButtonIndividualRule(self) -> WebElement:
return self.wait_for(self.buttonIndividualRule)

def getAutocompleteTargetCriteriaOption(self) -> WebElement:
return self.wait_for(self.autocompleteTargetCriteriaOption)
138 changes: 126 additions & 12 deletions backend/selenium_tests/page_object/targeting/t_details_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,129 @@
from selenium.webdriver.remote.webelement import WebElement


class TDetailsPage(BaseComponents):
# Locators
titlePage = 'h5[data-cy="page-header-title"]'
status = 'div[data-cy="target-population-status"]'
# Texts
# Elements

def getTitlePage(self) -> WebElement:
return self.wait_for(self.titlePage)

def getStatus(self) -> WebElement:
return self.wait_for(self.status)
class DetailsTargeting(BaseComponents):
pageHeaderContainer = 'div[data-cy="page-header-container"]'
pageHeaderTitle = 'h5[data-cy="page-header-title"]'
buttonTargetPopulationDuplicate = 'button[data-cy="button-target-population-duplicate"]'
buttonDelete = 'button[data-cy="button-delete"]'
buttonEdit = 'a[data-cy="button-edit"]'
buttonRebuild = 'button[data-cy="button-rebuild"]'
buttonTargetPopulationLock = 'button[data-cy="button-target-population-lock"]'
detailsTitle = 'div[data-cy="details-title"]'
detailsGrid = 'div[data-cy="details-grid"]'
labelStatus = 'div[data-cy="label-Status"]'
targetPopulationStatus = 'div[data-cy="target-population-status"]'
labelizedFieldContainerCreatedBy = 'div[data-cy="labelized-field-container-created-by"]'
labelCreatedBy = 'div[data-cy="label-created by"]'
labelizedFieldContainerCloseDate = 'div[data-cy="labelized-field-container-close-date"]'
labelProgrammePopulationCloseDate = 'div[data-cy="label-Programme population close date"]'
labelizedFieldContainerProgramName = 'div[data-cy="labelized-field-container-program-name"]'
labelProgramme = 'div[data-cy="label-Programme"]'
labelizedFieldContainerSendBy = 'div[data-cy="labelized-field-container-send-by"]'
labelSendBy = 'div[data-cy="label-Send by"]'
labelizedFieldContainerSendDate = 'div[data-cy="labelized-field-container-send-date"]'
labelSendDate = 'div[data-cy="label-Send date"]'
criteriaContainer = 'div[data-cy="criteria-container"]'
checkboxExcludeIfActiveAdjudicationTicket = 'span[data-cy="checkbox-exclude-if-active-adjudication-ticket"]'
labelFemaleChildren = 'div[data-cy="label-Female Children"]'
labelFemaleAdults = 'div[data-cy="label-Female Adults"]'
labelMaleChildren = 'div[data-cy="label-Male Children"]'
labelMaleAdults = 'div[data-cy="label-Male Adults"]'
labelTotalNumberOfHouseholds = 'div[data-cy="label-Total Number of Households"]'
labelTargetedIndividuals = 'div[data-cy="label-Targeted Individuals"]'
tableTitle = 'h6[data-cy="table-title"]'
tableLabel = 'span[data-cy="table-label"]'
tablePagination = 'div[data-cy="table-pagination"]'

def getPageHeaderTitle(self) -> WebElement:
return self.wait_for(self.pageHeaderTitle)

def getButtonTargetPopulationDuplicate(self) -> WebElement:
return self.wait_for(self.buttonTargetPopulationDuplicate)

def getButtonDelete(self) -> WebElement:
return self.wait_for(self.buttonDelete)

def getButtonEdit(self) -> WebElement:
return self.wait_for(self.buttonEdit)

def getButtonRebuild(self) -> WebElement:
return self.wait_for(self.buttonRebuild)

def getButtonTargetPopulationLock(self) -> WebElement:
return self.wait_for(self.buttonTargetPopulationLock)

def getDetailsTitle(self) -> WebElement:
return self.wait_for(self.detailsTitle)

def getDetailsGrid(self) -> WebElement:
return self.wait_for(self.detailsGrid)

def getLabelStatus(self) -> WebElement:
return self.wait_for(self.labelStatus)

def getTargetPopulationStatus(self) -> WebElement:
return self.wait_for(self.targetPopulationStatus)

def getLabelizedFieldContainerCreatedBy(self) -> WebElement:
return self.wait_for(self.labelizedFieldContainerCreatedBy)

def getLabelCreatedBy(self) -> WebElement:
return self.wait_for(self.labelCreatedBy)

def getLabelizedFieldContainerCloseDate(self) -> WebElement:
return self.wait_for(self.labelizedFieldContainerCloseDate)

def getLabelProgrammePopulationCloseDate(self) -> WebElement:
return self.wait_for(self.labelProgrammePopulationCloseDate)

def getLabelizedFieldContainerProgramName(self) -> WebElement:
return self.wait_for(self.labelizedFieldContainerProgramName)

def getLabelProgramme(self) -> WebElement:
return self.wait_for(self.labelProgramme)

def getLabelizedFieldContainerSendBy(self) -> WebElement:
return self.wait_for(self.labelizedFieldContainerSendBy)

def getLabelSendBy(self) -> WebElement:
return self.wait_for(self.labelSendBy)

def getLabelizedFieldContainerSendDate(self) -> WebElement:
return self.wait_for(self.labelizedFieldContainerSendDate)

def getLabelSendDate(self) -> WebElement:
return self.wait_for(self.labelSendDate)

def getCriteriaContainer(self) -> WebElement:
return self.wait_for(self.criteriaContainer)

def getCheckboxExcludeIfActiveAdjudicationTicket(self) -> WebElement:
return self.wait_for(self.checkboxExcludeIfActiveAdjudicationTicket)

def getLabelFemaleChildren(self) -> WebElement:
return self.wait_for(self.labelFemaleChildren)

def getLabelFemaleAdults(self) -> WebElement:
return self.wait_for(self.labelFemaleAdults)

def getLabelMaleChildren(self) -> WebElement:
return self.wait_for(self.labelMaleChildren)

def getLabelMaleAdults(self) -> WebElement:
return self.wait_for(self.labelMaleAdults)

def getLabelTotalNumberOfHouseholds(self) -> WebElement:
return self.wait_for(self.labelTotalNumberOfHouseholds)

def getLabelTargetedIndividuals(self) -> WebElement:
return self.wait_for(self.labelTargetedIndividuals)

def getTableTitle(self) -> WebElement:
return self.wait_for(self.tableTitle)

def getTableLabel(self) -> WebElement:
return self.get_elements(self.tableLabel)

def getTablePagination(self) -> WebElement:
return self.wait_for(self.tablePagination)
68 changes: 23 additions & 45 deletions backend/selenium_tests/page_object/targeting/targeting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from time import sleep

from page_object.base_components import BaseComponents
from selenium.webdriver.remote.webelement import WebElement

Expand All @@ -10,11 +12,13 @@ class Targeting(BaseComponents):
programFilter = 'div[data-cy="filters-program"]'
minNumberOfHouseholds = 'div[data-cy="filters-total-households-count-min"]'
maxNumberOfHouseholds = 'div[data-cy="filters-total-households-count-max"]'
buttonCreateNew = 'a[data-cy="button-target-population-create-new"]'
buttonCreateNew = 'button[data-cy="button-new-tp"]'
tabTitle = 'h6[data-cy="table-title"]'
tabColumnLabel = 'span[data-cy="table-label"]'
statusOptions = 'li[role="option"]'
rows = 'tr[role="checkbox"]'
createUserFilters = 'div[data-cy="menu-item-filters-text"]'
createUseIDs = 'div[data-cy="menu-item-ids-text"]'

# Texts

Expand Down Expand Up @@ -57,23 +61,8 @@ def getButtonCreateNew(self) -> WebElement:
def getTabTitle(self) -> WebElement:
return self.wait_for(self.tabTitle)

def getTabColumnName(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(0)

def getTabColumnStatus(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(1)

def getTabColumnNOHouseholds(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(2)

def getTabColumnDateCreated(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(3)

def getTabColumnLastEdited(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(4)

def getTabColumnCreatedBy(self) -> WebElement:
return self.wait_for(self.tabColumnLabel).eq(5)
def getTabColumnLabel(self) -> list[WebElement]:
return self.get_elements(self.tabColumnLabel)

def getStatusOption(self) -> WebElement:
return self.wait_for(self.statusOptions)
Expand All @@ -84,30 +73,19 @@ def getApply(self) -> WebElement:
def getClear(self) -> WebElement:
return self.wait_for(self.buttonClear)

def getTargetPopulationsRows(self) -> WebElement:
return self.wait_for(self.rows)

def checkElementsOnPage(self) -> None:
self.getTitlePage().should("be.visible").contains(self.textTitlePage)
# self.getButtonFiltersExpand().click()
self.getSearchFilter().should("be.visible")
self.getStatusFilter().should("be.visible")
self.getMinNumberOfHouseholdsFilter().should("be.visible")
self.getMaxNumberOfHouseholdsFilter().should("be.visible")
self.getButtonCreateNew().should("be.visible").contains(self.textCreateNew)
self.getTabTitle().should("be.visible").contains(self.textTabTitle)
self.getTabColumnName().should("be.visible").contains(self.textTabName)
self.getTabColumnStatus().should("be.visible").contains(self.textTabStatus)
self.getTabColumnNOHouseholds()
self.getTabColumnDateCreated()
self.getTabColumnLastEdited()
self.getTabColumnCreatedBy()

def selectStatus(self, status: str) -> None:
self.getStatusFilter().click()
self.getStatusOption().contains(status).click()
self.pressEscapeFromElement(self.getStatusOption().contains(status))
self.getApply().click()

def chooseTargetPopulationRow(self, row: int) -> WebElement:
return self.getTargetPopulationsRows().eq(row)
def getTargetPopulationsRows(self) -> list[WebElement]:
return self.get_elements(self.rows)

def chooseTargetPopulations(self, number: int) -> WebElement:
try:
self.wait_for(self.rows)
return self.get_elements(self.rows)[number]
except IndexError:
sleep(1)
return self.get_elements(self.rows)[number]

def getCreateUseFilters(self) -> WebElement:
return self.wait_for(self.createUserFilters)

def getCreateUseIDs(self) -> WebElement:
return self.wait_for(self.createUseIDs)
Loading
Loading