Skip to content

Commit

Permalink
Test filters - program selected
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-kellton committed May 16, 2024
1 parent ce52f4c commit 423f4f5
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 91 deletions.
3 changes: 1 addition & 2 deletions backend/selenium_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
from _pytest.fixtures import FixtureRequest
from _pytest.nodes import Item
from _pytest.runner import CallInfo

from page_object.filters import Filters
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
185 changes: 98 additions & 87 deletions backend/selenium_tests/filters/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from time import sleep

from django.conf import settings
from django.core.management import call_command

import pytest
from page_object.filters import Filters
from selenium.webdriver.common.by import By
Expand All @@ -18,63 +20,70 @@ def create_programs() -> None:
class TestSmokeFilters:
@pytest.mark.skip()
def test_filters_all_programs(self, login, create_programs, filters: Filters):

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],
"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:
Expand All @@ -85,9 +94,9 @@ def test_filters_all_programs(self, login, create_programs, filters: Filters):
ids = filters.driver.find_elements(By.XPATH, f"//*[@data-cy]")
list_locators = []
for i in ids:
if 'button-filters-apply' == i.get_attribute("data-cy"):
if "button-filters-apply" == i.get_attribute("data-cy"):
break
list_locators.append(f'{i.tag_name}[data-cy=\"{i.get_attribute("data-cy")}\"]')
list_locators.append(f'{i.tag_name}[data-cy="{i.get_attribute("data-cy")}"]')
for locator in all_programs[nav_menu]:
assert locator in list_locators

Expand Down Expand Up @@ -157,34 +166,36 @@ def test_filters_selected_program(self, login, create_programs, filters: Filters
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
],
"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": [],
"Surveys": [],
"Programme Users": [],
Expand All @@ -204,13 +215,13 @@ def test_filters_selected_program(self, login, create_programs, filters: Filters
print(f"---------------{nav_menu}---------------")
list_locators = []
for i in ids:
if 'button-filters-clear' == i.get_attribute("data-cy"):
if "button-filters-clear" == i.get_attribute("data-cy"):
break
data_cy_attribute = i.get_attribute("data-cy") # type: ignore
var_name = [i.capitalize() for i in data_cy_attribute.lower().replace("-", " ").split(" ")]
var_name[0] = var_name[0].lower()
var_name = "".join(var_name) # type: ignore
print(f"filters.{var_name}, ")
list_locators.append(f'{i.tag_name}[data-cy=\"{i.get_attribute("data-cy")}\"]')
list_locators.append(f'{i.tag_name}[data-cy="{i.get_attribute("data-cy")}"]')
for locator in programs[nav_menu]:
assert locator in list_locators
3 changes: 1 addition & 2 deletions backend/selenium_tests/page_object/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from selenium.webdriver.remote.webelement import WebElement

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


class Filters(BaseComponents):
Expand Down

0 comments on commit 423f4f5

Please sign in to comment.