From 7d4dd9534ae52042f63c46e3402d9c15b0494126 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Fri, 21 Jun 2024 14:51:19 +0200 Subject: [PATCH 1/8] Init --- .../accountability/test_surveys.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backend/selenium_tests/accountability/test_surveys.py diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py new file mode 100644 index 0000000000..43a2d3992c --- /dev/null +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -0,0 +1,51 @@ +import pytest +from helpers.fixtures import get_program_with_dct_type_and_name +from page_object.accountability.communication import AccountabilityCommunication +from page_object.accountability.comunication_details import ( + AccountabilityCommunicationDetails, +) + +from hct_mis_api.apps.account.models import User +from hct_mis_api.apps.accountability.fixtures import CommunicationMessageFactory +from hct_mis_api.apps.accountability.models import Message +from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType +from hct_mis_api.apps.program.models import Program +from hct_mis_api.apps.targeting.fixtures import ( + TargetingCriteriaFactory, + TargetPopulationFactory, +) +from hct_mis_api.apps.targeting.models import TargetPopulation + +pytestmark = pytest.mark.django_db(transaction=True) + + +@pytest.fixture +def test_program() -> Program: + return get_program_with_dct_type_and_name("Test Program", "NORM", DataCollectingType.Type.STANDARD) + + +@pytest.fixture +def add_accountability_surveys_message() -> None: + pass + + +@pytest.mark.usefixtures("login") +class TestSmokeAccountabilitySurveys: + def test_smoke_accountability_surveys( + self, + test_program: Program, + add_accountability_communication_message: Message, + pageAccountabilityCommunication: AccountabilityCommunication, + ) -> None: + pageAccountabilityCommunication.selectGlobalProgramFilter("Test Program").click() + pageAccountabilityCommunication.getNavAccountability().click() + + def test_smoke_accountability_surveys_details( + self, + test_program: Program, + add_accountability_communication_message: Message, + pageAccountabilityCommunication: AccountabilityCommunication, + pageAccountabilityCommunicationDetails: AccountabilityCommunicationDetails, + ) -> None: + pageAccountabilityCommunication.selectGlobalProgramFilter("Test Program").click() + pageAccountabilityCommunication.getNavAccountability().click() From 7a55594d36f7c264130575808a250a9e6e7de97d Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 24 Jun 2024 08:06:32 +0200 Subject: [PATCH 2/8] Test --- .../accountability/test_surveys.py | 24 ++++++++++++------- .../page_object/accountability/surveys.py | 2 +- .../accountability/surveys_details.py | 9 +++++++ 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 backend/selenium_tests/page_object/accountability/surveys_details.py diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index 43a2d3992c..28cafa045e 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -16,6 +16,9 @@ ) from hct_mis_api.apps.targeting.models import TargetPopulation +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails + pytestmark = pytest.mark.django_db(transaction=True) @@ -34,18 +37,21 @@ class TestSmokeAccountabilitySurveys: def test_smoke_accountability_surveys( self, test_program: Program, - add_accountability_communication_message: Message, - pageAccountabilityCommunication: AccountabilityCommunication, + add_accountability_surveys_message: Message, + pageAccountabilitySurveys: AccountabilitySurveys, ) -> None: - pageAccountabilityCommunication.selectGlobalProgramFilter("Test Program").click() - pageAccountabilityCommunication.getNavAccountability().click() + pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() + pageAccountabilitySurveys.getNavAccountability().click() + pageAccountabilitySurveys.getNavSurveys().click() def test_smoke_accountability_surveys_details( self, test_program: Program, - add_accountability_communication_message: Message, - pageAccountabilityCommunication: AccountabilityCommunication, - pageAccountabilityCommunicationDetails: AccountabilityCommunicationDetails, + add_accountability_surveys_message: Message, + pageAccountabilitySurveys: AccountabilitySurveys, + pageAccountabilitySurveysDetails: AccountabilitySurveysDetails, ) -> None: - pageAccountabilityCommunication.selectGlobalProgramFilter("Test Program").click() - pageAccountabilityCommunication.getNavAccountability().click() + pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() + pageAccountabilitySurveys.getNavAccountability().click() + pageAccountabilitySurveys.getNavSurveys().click() + pageAccountabilitySurveys.getRows()[0].click() diff --git a/backend/selenium_tests/page_object/accountability/surveys.py b/backend/selenium_tests/page_object/accountability/surveys.py index d10dbec612..94debb58f9 100644 --- a/backend/selenium_tests/page_object/accountability/surveys.py +++ b/backend/selenium_tests/page_object/accountability/surveys.py @@ -2,7 +2,7 @@ from selenium.webdriver.remote.webelement import WebElement -class SurveysPage(BaseComponents): +class AccountabilitySurveys(BaseComponents): # Locators titlePage = 'h5[data-cy="page-header-title"]' rows = 'tr[role="checkbox"]' diff --git a/backend/selenium_tests/page_object/accountability/surveys_details.py b/backend/selenium_tests/page_object/accountability/surveys_details.py new file mode 100644 index 0000000000..ed01da5bb0 --- /dev/null +++ b/backend/selenium_tests/page_object/accountability/surveys_details.py @@ -0,0 +1,9 @@ +from page_object.base_components import BaseComponents +from selenium.webdriver.remote.webelement import WebElement + + +class AccountabilitySurveysDetails(BaseComponents): + pageHeaderContainer = 'div[data-cy="page-header-container"]' + + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) From 7eeb9a61e3d5d6a3a9b25075d5592065d5be9a42 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 24 Jun 2024 09:04:40 +0200 Subject: [PATCH 3/8] Added add_accountability_surveys_message --- .../accountability/test_surveys.py | 31 ++++++++++++++----- backend/selenium_tests/conftest.py | 13 ++++++++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index 28cafa045e..3b3680c9d0 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -1,9 +1,5 @@ import pytest from helpers.fixtures import get_program_with_dct_type_and_name -from page_object.accountability.communication import AccountabilityCommunication -from page_object.accountability.comunication_details import ( - AccountabilityCommunicationDetails, -) from hct_mis_api.apps.account.models import User from hct_mis_api.apps.accountability.fixtures import CommunicationMessageFactory @@ -19,6 +15,9 @@ from page_object.accountability.surveys import AccountabilitySurveys from page_object.accountability.surveys_details import AccountabilitySurveysDetails +from hct_mis_api.apps.accountability.fixtures import SurveyFactory +from hct_mis_api.apps.accountability.models import Survey + pytestmark = pytest.mark.django_db(transaction=True) @@ -28,8 +27,17 @@ def test_program() -> Program: @pytest.fixture -def add_accountability_surveys_message() -> None: - pass +def add_accountability_surveys_message() -> Survey: + targeting_criteria = TargetingCriteriaFactory() + + target_population = TargetPopulationFactory( + created_by=User.objects.first(), + targeting_criteria=targeting_criteria, + business_area=BusinessArea.objects.first(), + ) + return SurveyFactory(title="Test survey", + target_population=target_population, + created_by=User.objects.first()) @pytest.mark.usefixtures("login") @@ -37,17 +45,24 @@ class TestSmokeAccountabilitySurveys: def test_smoke_accountability_surveys( self, test_program: Program, - add_accountability_surveys_message: Message, + add_accountability_surveys_message: Survey, pageAccountabilitySurveys: AccountabilitySurveys, ) -> None: pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() pageAccountabilitySurveys.getNavAccountability().click() pageAccountabilitySurveys.getNavSurveys().click() + pageAccountabilitySurveys.screenshot("AccountabilitySurveys") + from selenium_tests.tools.tag_name_finder import printing + printing("Mapping", pageAccountabilitySurveys.driver) + printing("Methods", pageAccountabilitySurveys.driver) + printing("Assert", pageAccountabilitySurveys.driver) + + @pytest.mark.skip() def test_smoke_accountability_surveys_details( self, test_program: Program, - add_accountability_surveys_message: Message, + add_accountability_surveys_message: Survey, pageAccountabilitySurveys: AccountabilitySurveys, pageAccountabilitySurveysDetails: AccountabilitySurveysDetails, ) -> None: diff --git a/backend/selenium_tests/conftest.py b/backend/selenium_tests/conftest.py index bf7e95917f..86d7c3438e 100644 --- a/backend/selenium_tests/conftest.py +++ b/backend/selenium_tests/conftest.py @@ -10,6 +10,9 @@ from _pytest.nodes import Item from _pytest.runner import CallInfo from flags.models import FlagState + +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails from page_object.admin_panel.admin_panel import AdminPanel from page_object.filters import Filters from page_object.grievance.details_feedback_page import FeedbackDetailsPage @@ -306,6 +309,16 @@ def pageNewPaymentPlan(request: FixtureRequest, browser: Chrome) -> NewPaymentPl yield NewPaymentPlan(browser) +@pytest.fixture +def pageAccountabilitySurveys(request: FixtureRequest, browser: Chrome) -> AccountabilitySurveys: + yield AccountabilitySurveys(browser) + + +@pytest.fixture +def pageAccountabilitySurveysDetails(request: FixtureRequest, browser: Chrome) -> AccountabilitySurveysDetails: + yield AccountabilitySurveysDetails(browser) + + @pytest.fixture def business_area() -> BusinessArea: business_area, _ = BusinessArea.objects.get_or_create( From 02f77639e4309cb3a2c9a13f2a96aeee6958424b Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 24 Jun 2024 10:29:49 +0200 Subject: [PATCH 4/8] Added test_smoke_accountability_surveys_details --- .../accountability/test_surveys.py | 95 +++++++++++++++---- backend/selenium_tests/conftest.py | 1 - .../page_object/accountability/surveys.py | 93 +++++++++++++++--- .../accountability/surveys_details.py | 77 +++++++++++++++ 4 files changed, 234 insertions(+), 32 deletions(-) diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index 3b3680c9d0..0377303834 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -1,22 +1,21 @@ +from django.db import transaction + import pytest from helpers.fixtures import get_program_with_dct_type_and_name +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails from hct_mis_api.apps.account.models import User -from hct_mis_api.apps.accountability.fixtures import CommunicationMessageFactory -from hct_mis_api.apps.accountability.models import Message +from hct_mis_api.apps.accountability.fixtures import SurveyFactory +from hct_mis_api.apps.accountability.models import Survey from hct_mis_api.apps.core.models import BusinessArea, DataCollectingType +from hct_mis_api.apps.household.fixtures import create_household_and_individuals +from hct_mis_api.apps.household.models import REFUGEE, Household from hct_mis_api.apps.program.models import Program from hct_mis_api.apps.targeting.fixtures import ( TargetingCriteriaFactory, TargetPopulationFactory, ) -from hct_mis_api.apps.targeting.models import TargetPopulation - -from page_object.accountability.surveys import AccountabilitySurveys -from page_object.accountability.surveys_details import AccountabilitySurveysDetails - -from hct_mis_api.apps.accountability.fixtures import SurveyFactory -from hct_mis_api.apps.accountability.models import Survey pytestmark = pytest.mark.django_db(transaction=True) @@ -26,6 +25,19 @@ def test_program() -> Program: return get_program_with_dct_type_and_name("Test Program", "NORM", DataCollectingType.Type.STANDARD) +@pytest.fixture +def add_household() -> Household: + program = Program.objects.first() + with transaction.atomic(): + household, individuals = create_household_and_individuals( + household_data={"business_area": program.business_area, "program": program, "residence_status": REFUGEE}, + individuals_data=[ + {"business_area": program.business_area, "observed_disability": []}, + ], + ) + return household + + @pytest.fixture def add_accountability_surveys_message() -> Survey: targeting_criteria = TargetingCriteriaFactory() @@ -35,9 +47,13 @@ def add_accountability_surveys_message() -> Survey: targeting_criteria=targeting_criteria, business_area=BusinessArea.objects.first(), ) - return SurveyFactory(title="Test survey", - target_population=target_population, - created_by=User.objects.first()) + return SurveyFactory( + title="Test survey", + category="MANUAL", + unicef_id="SUR-24-0005", + target_population=target_population, + created_by=User.objects.first(), + ) @pytest.mark.usefixtures("login") @@ -52,21 +68,64 @@ def test_smoke_accountability_surveys( pageAccountabilitySurveys.getNavAccountability().click() pageAccountabilitySurveys.getNavSurveys().click() - pageAccountabilitySurveys.screenshot("AccountabilitySurveys") - from selenium_tests.tools.tag_name_finder import printing - printing("Mapping", pageAccountabilitySurveys.driver) - printing("Methods", pageAccountabilitySurveys.driver) - printing("Assert", pageAccountabilitySurveys.driver) + assert "Surveys" in pageAccountabilitySurveys.getPageHeaderTitle().text + assert "NEW SURVEY" in pageAccountabilitySurveys.getButtonNewSurvey().text + assert "Search" in pageAccountabilitySurveys.getFiltersSearch().text + assert "Target Population" in pageAccountabilitySurveys.getTargetPopulationInput().text + assert "Created by" in pageAccountabilitySurveys.getFiltersCreatedByAutocomplete().text + assert "Created by" in pageAccountabilitySurveys.getCreatedByInput().text + assert "From" in pageAccountabilitySurveys.getFiltersCreationDateFrom().text + assert "To" in pageAccountabilitySurveys.getFiltersCreationDateTo().text + assert "CLEAR" in pageAccountabilitySurveys.getButtonFiltersClear().text + assert "APPLY" in pageAccountabilitySurveys.getButtonFiltersApply().text + assert "Surveys List" in pageAccountabilitySurveys.getTableTitle().text + assert "Survey ID" in pageAccountabilitySurveys.getTableLabel()[0].text + assert "Survey Title" in pageAccountabilitySurveys.getTableLabel()[1].text + assert "Category" in pageAccountabilitySurveys.getTableLabel()[2].text + assert "Number of Recipients" in pageAccountabilitySurveys.getTableLabel()[3].text + assert "Created by" in pageAccountabilitySurveys.getTableLabel()[4].text + assert "Creation Date" in pageAccountabilitySurveys.getTableLabel()[5].text + assert "10 1–1 of 1" in pageAccountabilitySurveys.getTablePagination().text.replace("\n", " ") + assert 1 == len(pageAccountabilitySurveys.getRows()) + assert "SUR-24-0005" in pageAccountabilitySurveys.getRows()[0].text + assert "Test survey" in pageAccountabilitySurveys.getRows()[0].text - @pytest.mark.skip() def test_smoke_accountability_surveys_details( self, test_program: Program, add_accountability_surveys_message: Survey, + add_household: Household, pageAccountabilitySurveys: AccountabilitySurveys, pageAccountabilitySurveysDetails: AccountabilitySurveysDetails, ) -> None: + add_accountability_surveys_message.recipients.set([Household.objects.first()]) pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() pageAccountabilitySurveys.getNavAccountability().click() pageAccountabilitySurveys.getNavSurveys().click() pageAccountabilitySurveys.getRows()[0].click() + + assert "SUR-24-0005" in pageAccountabilitySurveysDetails.getPageHeaderTitle().text + assert "Survey with manual process" in pageAccountabilitySurveysDetails.getLabelCategory().text + assert "Test survey" in pageAccountabilitySurveysDetails.getLabelSurveyTitle().text + created_by = add_accountability_surveys_message.created_by + assert ( + f"{created_by.first_name} {created_by.last_name}" + in pageAccountabilitySurveysDetails.getLabelCreatedBy().text + ) + assert ( + add_accountability_surveys_message.created_at.strftime("%-d %b %Y") + in pageAccountabilitySurveysDetails.getLabelDateCreated().text + ) + assert "Test Program" in pageAccountabilitySurveysDetails.getLabelProgramme().text + assert "Household Id" in pageAccountabilitySurveysDetails.getHouseholdId().text + assert "Status" in pageAccountabilitySurveysDetails.getStatus().text + assert "Head of Household" in pageAccountabilitySurveysDetails.getHouseholdHeadName().text + assert "Household Size" in pageAccountabilitySurveysDetails.getHouseholdSize().text + assert "Administrative Level 2" in pageAccountabilitySurveysDetails.getHouseholdLocation().text + assert "Residence Status" in pageAccountabilitySurveysDetails.getHouseholdResidenceStatus().text + assert "Registration Date" in pageAccountabilitySurveysDetails.getHouseholdRegistrationDate().text + assert "Rows per page: 10 1–1 of 1" in pageAccountabilitySurveysDetails.getTablePagination().text.replace( + "\n", " " + ) + assert 1 == len(pageAccountabilitySurveys.getRows()) + assert "HH-0" in pageAccountabilitySurveys.getRows()[0].text diff --git a/backend/selenium_tests/conftest.py b/backend/selenium_tests/conftest.py index 86d7c3438e..3ee87bf757 100644 --- a/backend/selenium_tests/conftest.py +++ b/backend/selenium_tests/conftest.py @@ -10,7 +10,6 @@ from _pytest.nodes import Item from _pytest.runner import CallInfo from flags.models import FlagState - from page_object.accountability.surveys import AccountabilitySurveys from page_object.accountability.surveys_details import AccountabilitySurveysDetails from page_object.admin_panel.admin_panel import AdminPanel diff --git a/backend/selenium_tests/page_object/accountability/surveys.py b/backend/selenium_tests/page_object/accountability/surveys.py index 94debb58f9..555ba9db16 100644 --- a/backend/selenium_tests/page_object/accountability/surveys.py +++ b/backend/selenium_tests/page_object/accountability/surveys.py @@ -4,10 +4,27 @@ class AccountabilitySurveys(BaseComponents): # Locators - titlePage = 'h5[data-cy="page-header-title"]' + pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + buttonNewSurvey = 'button[data-cy="button-new-survey"]' + filtersSearch = 'div[data-cy="filters-search"]' + filtersTargetPopulationAutocomplete = 'div[data-cy="filters-target-population-autocomplete"]' + targetPopulationInput = 'div[data-cy="Target Population-input"]' + filtersCreatedByAutocomplete = 'div[data-cy="filters-created-by-autocomplete"]' + createdByInput = 'div[data-cy="Created by-input"]' + filtersCreationDateFrom = 'div[data-cy="filters-creation-date-from"]' + filtersCreationDateTo = 'div[data-cy="filters-creation-date-to"]' + buttonFiltersClear = 'button[data-cy="button-filters-clear"]' + buttonFiltersApply = 'button[data-cy="button-filters-apply"]' + tableTitle = 'h6[data-cy="table-title"]' + tableLabel = 'span[data-cy="table-label"]' + tablePagination = 'div[data-cy="table-pagination"]' + menuItemRapidPro = 'li[data-cy="menu-item-rapid-pro"]' + menuItemRapidProText = 'div[data-cy="menu-item-rapid-pro-text"]' + menuItemSmsText = 'li[data-cy="menu-item-sms-text"]' + menuItemManual = 'li[data-cy="menu-item-manual"]' + menuItemManualText = 'div[data-cy="menu-item-manual-text"]' rows = 'tr[role="checkbox"]' - buttonApply = 'button[data-cy="button-filters-apply"]' - buttonClear = 'button[data-cy="button-filters-clear"]' # Texts textTitlePage = "Surveys" @@ -16,17 +33,67 @@ class AccountabilitySurveys(BaseComponents): textTabCreatedBy = "Created by" # Elements - def getTitlePage(self) -> WebElement: - return self.wait_for(self.titlePage) + def getPageHeaderContainer(self) -> WebElement: + return self.wait_for(self.pageHeaderContainer) - def getMessageID(self) -> WebElement: - return self.wait_for(self.tabColumnLabel).eq(0) + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) - def getApply(self) -> WebElement: - return self.wait_for(self.buttonApply) + def getButtonNewSurvey(self) -> WebElement: + return self.wait_for(self.buttonNewSurvey) - def getClear(self) -> WebElement: - return self.wait_for(self.buttonClear) + def getFiltersSearch(self) -> WebElement: + return self.wait_for(self.filtersSearch) - def getTargetPopulationsRows(self) -> WebElement: - return self.wait_for(self.rows) + def getFiltersTargetPopulationAutocomplete(self) -> WebElement: + return self.wait_for(self.filtersTargetPopulationAutocomplete) + + def getTargetPopulationInput(self) -> WebElement: + return self.wait_for(self.targetPopulationInput) + + def getFiltersCreatedByAutocomplete(self) -> WebElement: + return self.wait_for(self.filtersCreatedByAutocomplete) + + def getCreatedByInput(self) -> WebElement: + return self.wait_for(self.createdByInput) + + def getFiltersCreationDateFrom(self) -> WebElement: + return self.wait_for(self.filtersCreationDateFrom) + + def getFiltersCreationDateTo(self) -> WebElement: + return self.wait_for(self.filtersCreationDateTo) + + def getButtonFiltersClear(self) -> WebElement: + return self.wait_for(self.buttonFiltersClear) + + def getButtonFiltersApply(self) -> WebElement: + return self.wait_for(self.buttonFiltersApply) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getTableLabel(self) -> [WebElement]: + self.wait_for(self.tableLabel) + return self.get_elements(self.tableLabel) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getMenuItemRapidPro(self) -> WebElement: + return self.wait_for(self.menuItemRapidPro) + + def getMenuItemRapidProText(self) -> WebElement: + return self.wait_for(self.menuItemRapidProText) + + def getMenuItemSmsText(self) -> WebElement: + return self.wait_for(self.menuItemSmsText) + + def getMenuItemManual(self) -> WebElement: + return self.wait_for(self.menuItemManual) + + def getMenuItemManualText(self) -> WebElement: + return self.wait_for(self.menuItemManualText) + + def getRows(self) -> [WebElement]: + self.wait_for(self.rows) + return self.get_elements(self.rows) diff --git a/backend/selenium_tests/page_object/accountability/surveys_details.py b/backend/selenium_tests/page_object/accountability/surveys_details.py index ed01da5bb0..3e92a1bd61 100644 --- a/backend/selenium_tests/page_object/accountability/surveys_details.py +++ b/backend/selenium_tests/page_object/accountability/surveys_details.py @@ -4,6 +4,83 @@ class AccountabilitySurveysDetails(BaseComponents): pageHeaderContainer = 'div[data-cy="page-header-container"]' + pageHeaderTitle = 'h5[data-cy="page-header-title"]' + labelCategory = 'div[data-cy="label-Category"]' + labelSurveyTitle = 'div[data-cy="label-Survey Title"]' + labelCreatedBy = 'div[data-cy="label-Created By"]' + labelDateCreated = 'div[data-cy="label-Date Created"]' + labelTargetPopulation = 'div[data-cy="label-Target Population"]' + labelProgramme = 'div[data-cy="label-Programme"]' + tableTitle = 'h6[data-cy="table-title"]' + householdId = 'th[data-cy="household-id"]' + tableLabel = 'span[data-cy="table-label"]' + status = 'th[data-cy="status"]' + householdHeadName = 'th[data-cy="household-head-name"]' + householdSize = 'th[data-cy="household-size"]' + householdLocation = 'th[data-cy="household-location"]' + householdResidenceStatus = 'th[data-cy="household-residence-status"]' + householdRegistrationDate = 'th[data-cy="household-registration-date"]' + tableRow = 'tr[data-cy="table-row"]' + tablePagination = 'div[data-cy="table-pagination"]' + rows = 'tr[role="checkbox"]' def getPageHeaderContainer(self) -> WebElement: return self.wait_for(self.pageHeaderContainer) + + def getPageHeaderTitle(self) -> WebElement: + return self.wait_for(self.pageHeaderTitle) + + def getLabelCategory(self) -> WebElement: + return self.wait_for(self.labelCategory) + + def getLabelSurveyTitle(self) -> WebElement: + return self.wait_for(self.labelSurveyTitle) + + def getLabelCreatedBy(self) -> WebElement: + return self.wait_for(self.labelCreatedBy) + + def getLabelDateCreated(self) -> WebElement: + return self.wait_for(self.labelDateCreated) + + def getLabelTargetPopulation(self) -> WebElement: + return self.wait_for(self.labelTargetPopulation) + + def getLabelProgramme(self) -> WebElement: + return self.wait_for(self.labelProgramme) + + def getTableTitle(self) -> WebElement: + return self.wait_for(self.tableTitle) + + def getHouseholdId(self) -> WebElement: + return self.wait_for(self.householdId) + + def getTableLabel(self) -> WebElement: + return self.wait_for(self.tableLabel) + + def getStatus(self) -> WebElement: + return self.wait_for(self.status) + + def getHouseholdHeadName(self) -> WebElement: + return self.wait_for(self.householdHeadName) + + def getHouseholdSize(self) -> WebElement: + return self.wait_for(self.householdSize) + + def getHouseholdLocation(self) -> WebElement: + return self.wait_for(self.householdLocation) + + def getHouseholdResidenceStatus(self) -> WebElement: + return self.wait_for(self.householdResidenceStatus) + + def getHouseholdRegistrationDate(self) -> WebElement: + return self.wait_for(self.householdRegistrationDate) + + def getTableRow(self) -> WebElement: + return self.wait_for(self.tableRow) + + def getTablePagination(self) -> WebElement: + return self.wait_for(self.tablePagination) + + def getRows(self) -> [WebElement]: + self.wait_for(self.rows) + return self.get_elements(self.rows) From 08f1a528c2a95cf64eb5f088be65701ebb4ca6b2 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Mon, 8 Jul 2024 13:31:24 +0200 Subject: [PATCH 5/8] Isort --- backend/selenium_tests/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/selenium_tests/conftest.py b/backend/selenium_tests/conftest.py index 8b51c75de2..3d879165cd 100644 --- a/backend/selenium_tests/conftest.py +++ b/backend/selenium_tests/conftest.py @@ -10,12 +10,12 @@ from _pytest.nodes import Item from _pytest.runner import CallInfo from flags.models import FlagState -from page_object.accountability.surveys import AccountabilitySurveys -from page_object.accountability.surveys_details import AccountabilitySurveysDetails from page_object.accountability.communication import AccountabilityCommunication from page_object.accountability.comunication_details import ( AccountabilityCommunicationDetails, ) +from page_object.accountability.surveys import AccountabilitySurveys +from page_object.accountability.surveys_details import AccountabilitySurveysDetails from page_object.admin_panel.admin_panel import AdminPanel from page_object.filters import Filters from page_object.grievance.details_feedback_page import FeedbackDetailsPage From be6efdc6b6b7e9f21c36aa14d138d4551ee9e77c Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Tue, 9 Jul 2024 09:51:50 +0200 Subject: [PATCH 6/8] Fix test_smoke_accountability_surveys_details --- backend/selenium_tests/accountability/test_surveys.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index 0377303834..dc3da172f2 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -102,6 +102,7 @@ def test_smoke_accountability_surveys_details( pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() pageAccountabilitySurveys.getNavAccountability().click() pageAccountabilitySurveys.getNavSurveys().click() + hh_unicef_id = pageAccountabilitySurveys.getRows()[0].text pageAccountabilitySurveys.getRows()[0].click() assert "SUR-24-0005" in pageAccountabilitySurveysDetails.getPageHeaderTitle().text @@ -128,4 +129,4 @@ def test_smoke_accountability_surveys_details( "\n", " " ) assert 1 == len(pageAccountabilitySurveys.getRows()) - assert "HH-0" in pageAccountabilitySurveys.getRows()[0].text + assert hh_unicef_id in pageAccountabilitySurveys.getRows()[0].text From c3b0cf22d9cd80439c5b67697d7721c8a23adfb2 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Tue, 9 Jul 2024 10:28:42 +0200 Subject: [PATCH 7/8] Fix test_smoke_accountability_surveys_details --- backend/selenium_tests/accountability/test_surveys.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index dc3da172f2..3221471d1e 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -102,7 +102,6 @@ def test_smoke_accountability_surveys_details( pageAccountabilitySurveys.selectGlobalProgramFilter("Test Program").click() pageAccountabilitySurveys.getNavAccountability().click() pageAccountabilitySurveys.getNavSurveys().click() - hh_unicef_id = pageAccountabilitySurveys.getRows()[0].text pageAccountabilitySurveys.getRows()[0].click() assert "SUR-24-0005" in pageAccountabilitySurveysDetails.getPageHeaderTitle().text @@ -129,4 +128,4 @@ def test_smoke_accountability_surveys_details( "\n", " " ) assert 1 == len(pageAccountabilitySurveys.getRows()) - assert hh_unicef_id in pageAccountabilitySurveys.getRows()[0].text + assert add_accountability_surveys_message.recipients.all()[0].unicef_id in pageAccountabilitySurveys.getRows()[0].text From 3351c63ed2e46003a4c44eb31807b3698ef969a9 Mon Sep 17 00:00:00 2001 From: Szymon Wyderka Date: Tue, 9 Jul 2024 11:25:07 +0200 Subject: [PATCH 8/8] Black --- backend/selenium_tests/accountability/test_surveys.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/selenium_tests/accountability/test_surveys.py b/backend/selenium_tests/accountability/test_surveys.py index 3221471d1e..7723c1b6f7 100644 --- a/backend/selenium_tests/accountability/test_surveys.py +++ b/backend/selenium_tests/accountability/test_surveys.py @@ -128,4 +128,7 @@ def test_smoke_accountability_surveys_details( "\n", " " ) assert 1 == len(pageAccountabilitySurveys.getRows()) - assert add_accountability_surveys_message.recipients.all()[0].unicef_id in pageAccountabilitySurveys.getRows()[0].text + assert ( + add_accountability_surveys_message.recipients.all()[0].unicef_id + in pageAccountabilitySurveys.getRows()[0].text + )