Skip to content

Commit

Permalink
Selenium - filters smoke tests (#3861)
Browse files Browse the repository at this point in the history
* Filters init

* Mapping filters

* add data cy filters reporting

* add unique data-cy to date picker filter

* fix if no label

* Test

* Test filters - all_programs

* Test filters - program selected

* Test filters - program selected

* Test filters - program selected

* Test filters - program selected

* add data cy for users fliters

* remove default data cy for search text field

* Test filters - program selected

* Fix for drawer tests and feedback tests

* Black

* Black

* Fix frontend tests

---------

Co-authored-by: Maciej Szewczyk <[email protected]>
  • Loading branch information
szymon-kellton and Maciej Szewczyk authored May 17, 2024
1 parent f55879e commit b8fbb3c
Show file tree
Hide file tree
Showing 21 changed files with 530 additions and 49 deletions.
13 changes: 12 additions & 1 deletion backend/selenium_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from _pytest.fixtures import FixtureRequest
from _pytest.nodes import Item
from _pytest.runner import CallInfo
from flags.models import FlagState
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 page_object.grievance.details_grievance_page import GrievanceDetailsPage
from page_object.grievance.feedback import Feedback
Expand Down Expand Up @@ -182,6 +184,11 @@ def login(browser: Chrome) -> Chrome:
return browser


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


@pytest.fixture
def pageProgrammeManagement(request: FixtureRequest, browser: Chrome) -> ProgrammeManagement:
yield ProgrammeManagement(browser)
Expand Down Expand Up @@ -284,10 +291,14 @@ def business_area() -> BusinessArea:
"region_name": "SAR",
"slug": "afghanistan",
"has_data_sharing_agreement": True,
"is_payment_plan_applicable": False,
"is_payment_plan_applicable": True,
"is_accountability_applicable": True,
"kobo_token": "XXX",
},
)
FlagState.objects.get_or_create(
**{"name": "ALLOW_ACCOUNTABILITY_MODULE", "condition": "boolean", "value": "True", "required": False}
)
return business_area


Expand Down
2 changes: 2 additions & 0 deletions backend/selenium_tests/drawer/test_drawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def test_social_worker_program_drawer_order(
"Payment Module",
"Payment Verification",
"Grievance",
"Accountability",
"Programme Users",
"Program Log",
]
Expand All @@ -95,6 +96,7 @@ def test_normal_program_drawer_order(
"Payment Module",
"Payment Verification",
"Grievance",
"Accountability",
"Programme Users",
"Program Log",
]
Expand Down
234 changes: 234 additions & 0 deletions backend/selenium_tests/filters/test_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
from django.conf import settings
from django.core.management import call_command

import pytest
from page_object.filters import Filters

pytestmark = pytest.mark.django_db(transaction=True)


@pytest.fixture
def create_programs() -> None:
call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/core/fixtures/data-selenium.json")
call_command("loaddata", f"{settings.PROJECT_ROOT}/apps/program/fixtures/data-cypress.json")
return


@pytest.mark.usefixtures("login")
class TestSmokeFilters:
def test_filters_all_programs(self, create_programs: None, filters: Filters) -> None:
all_programs = {
"Country Dashboard": [filters.globalProgramFilter, filters.globalProgramFilterContainer],
"Programs": [
filters.filtersDataCollectingType,
filters.filtersBudgetMax,
filters.filtersBudgetMin,
filters.filtersNumberOfHouseholdsMin,
filters.filtersNumberOfHouseholdsMax,
filters.filtersSector,
filters.filtersStartDate,
filters.filtersEndDate,
filters.filtersStatus,
filters.filtersSearch,
],
"Grievance": [
filters.filtersSearch,
filters.selectFilter,
filters.filtersDocumentType,
filters.filtersDocumentNumber,
filters.filtersProgram,
filters.programmeInput,
filters.selectFilter,
filters.filtersStatus,
filters.filtersFsp,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
filters.selectFilter,
filters.filtersCategory,
filters.filtersAdminLevel,
filters.filtersAssignee,
filters.assignedToInput,
filters.filtersCreatedByAutocomplete,
filters.filtersRegistrationDataImport,
filters.filtersPreferredLanguage,
filters.filtersPriority,
filters.filtersUrgency,
filters.filtersActiveTickets,
filters.filtersProgramState,
],
"Feedback": [
filters.filtersSearch,
filters.filtersProgram,
filters.programmeInput,
filters.selectFilter,
filters.filtersIssueType,
filters.filtersCreatedByAutocomplete,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
filters.selectFilter,
filters.filtersProgramState,
],
"Reporting": [
filters.reportOnlyMyFilter,
filters.reportStatusFilter,
filters.reportCreatedToFilter,
filters.reportCreatedFromFilter,
filters.reportTypeFilter,
],
"Activity Log": [
filters.filtersResidenceStatus,
filters.filtersSearch,
filters.userInput,
filters.selectFilter,
],
}

for nav_menu in all_programs:
if nav_menu == "Feedback":
filters.wait_for('[data-cy="nav-Grievance"]').click()
filters.wait_for(f'[data-cy="nav-{nav_menu}"]').click()
for locator in all_programs[nav_menu]:
try:
filters.wait_for(locator, timeout=20)
except BaseException:
raise Exception(f"Element {locator} not found on the {nav_menu} page.")

def test_filters_selected_program(self, create_programs: None, filters: Filters) -> None:
filters.selectGlobalProgramFilter("Test Programm").click()

programs = {
"Registration Data Import": [
filters.filterSearch,
filters.importedByInput,
filters.selectFilter,
filters.filterStatus,
filters.filterSizeMin,
filters.filterSizeMax,
filters.filterImportDateRangeMin,
filters.filterImportDateRangeMax,
],
"Program Population": [
filters.selectFilter,
filters.filtersDocumentType,
filters.filtersDocumentNumber,
filters.selectFilter,
filters.hhFiltersResidenceStatus,
filters.hhFiltersAdmin2,
filters.hhFiltersHouseholdSizeFrom,
filters.hhFiltersHouseholdSizeTo,
filters.selectFilter,
filters.hhFiltersOrderBy,
filters.selectFilter,
filters.hhFiltersStatus,
],
"Individuals": [
filters.indFiltersSearch,
filters.selectFilter,
filters.filtersDocumentType,
filters.filtersDocumentNumber,
filters.selectFilter,
filters.indFiltersGender,
filters.indFiltersAgeFrom,
filters.indFiltersAgeTo,
filters.selectFilter,
filters.indFiltersFlags,
filters.selectFilter,
filters.indFiltersOrderBy,
filters.selectFilter,
filters.indFiltersStatus,
filters.indFiltersRegDateFrom,
filters.indFiltersRegDateTo,
],
"Targeting": [
filters.filtersSearch,
filters.selectFilter,
filters.filtersStatus,
filters.filtersTotalHouseholdsCountMin,
filters.filtersTotalHouseholdsCountMax,
filters.datePickerFilterFrom,
filters.datePickerFilterTo,
],
"Payment Module": [
filters.selectFilter,
filters.filtersTotalEntitledQuantityFrom,
filters.filtersTotalEntitledQuantityTo,
filters.datePickerFilterFrom,
filters.datePickerFilterTo,
],
"Payment Verification": [
filters.filterSearch,
filters.selectFilter,
filters.filterStatus,
filters.filterFsp,
filters.selectFilter,
filters.filterModality,
filters.filterStartDate,
filters.filterEndDate,
],
"Grievance": [
filters.filtersSearch,
filters.selectFilter,
filters.filtersDocumentType,
filters.filtersDocumentNumber,
filters.selectFilter,
filters.filtersStatus,
filters.filtersFsp,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
filters.selectFilter,
filters.filtersCategory,
filters.filtersAdminLevel,
filters.filtersAssignee,
filters.assignedToInput,
filters.filtersCreatedByAutocomplete,
filters.filtersRegistrationDataImport,
filters.filtersPreferredLanguage,
filters.filtersPriority,
filters.filtersUrgency,
filters.filtersActiveTickets,
],
"Feedback": [
filters.filtersSearch,
filters.selectFilter,
filters.filtersIssueType,
filters.filtersCreatedByAutocomplete,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
],
"Accountability": [
filters.filtersTargetPopulationAutocomplete,
filters.targetPopulationInput,
filters.createdByInput,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
],
"Surveys": [
filters.filtersSearch,
filters.filtersTargetPopulationAutocomplete,
filters.targetPopulationInput,
filters.createdByInput,
filters.filtersCreationDateFrom,
filters.filtersCreationDateTo,
],
"Programme Users": [],
"Program Log": [
filters.filtersSearch,
filters.selectFilter,
filters.filtersResidenceStatus,
filters.userInput,
],
}

for nav_menu in programs:
if nav_menu == "Feedback":
filters.wait_for('[data-cy="nav-Grievance"]').click()
if nav_menu == "Individuals":
filters.wait_for('[data-cy="nav-Program Population"]').click()
if nav_menu == "Surveys":
filters.wait_for('[data-cy="nav-Accountability"]').click()
filters.wait_for(f'[data-cy="nav-{nav_menu}"]').click()
for locator in programs[nav_menu]:
try:
filters.wait_for(locator, timeout=20)
except BaseException:
raise Exception(f"Element {locator} not found on the {nav_menu} page.")
Loading

0 comments on commit b8fbb3c

Please sign in to comment.