diff --git a/data/data.py b/data/data.py index efe8b49d..31e4f3e3 100644 --- a/data/data.py +++ b/data/data.py @@ -6,4 +6,17 @@ class BaseConfigurationPageData: class ManageJenkinsData: STATUS_INFORMATION = ["System Information", "System Log", "Load Statistics", "About Jenkins"] - TOOLS_AND_ACTIONS = ["Reload Configuration from Disk", "Jenkins CLI", "Script Console", "Prepare for Shutdown"] \ No newline at end of file + TOOLS_AND_ACTIONS = ["Reload Configuration from Disk", "Jenkins CLI", "Script Console", "Prepare for Shutdown"] + +class ItemTypesData: + ITEM_TYPES = [ + "Freestyle project", + "Pipeline", + "Multi-configuration project", + "Folder", + "Multibranch Pipeline", + "Organization Folder", + ] + +class NewItemPageData: + EMPTY_ITEM_NAME_VALIDATION_TEXT = "ยป This field cannot be empty, please enter a valid name" diff --git a/data/endpoints.py b/data/endpoints.py index 1caacd9c..0d6d8824 100644 --- a/data/endpoints.py +++ b/data/endpoints.py @@ -5,4 +5,5 @@ class Endpoints: JOB_STATUS_PAGE_URL = lambda self, job_name: f"/job/{job_name}" MANAGE_URL = "/manage" SECURITY_REALM_URL = "/securityRealm/" - VIEW_ALL_PAGE_URL = "/view/all/" \ No newline at end of file + VIEW_ALL_PAGE_URL = "/view/all/" + ALL_NEW_JOB_URL = "/view/all/newJob" \ No newline at end of file diff --git a/tests/new_item/test_blank_item_name_field_validation_rf_tn.py b/tests/new_item/test_blank_item_name_field_validation_rf_tn.py new file mode 100644 index 00000000..1e8bd489 --- /dev/null +++ b/tests/new_item/test_blank_item_name_field_validation_rf_tn.py @@ -0,0 +1,25 @@ +from playwright.sync_api import expect +from locators.base_locators import BaseLocators +from locators.new_item_locators import NewItemLocators +from data.endpoints import Endpoints +from conftest import open_page +from pages.base_page import BasePage +from data.data import NewItemPageData +from data.data import ItemTypesData +import pytest + + + +class TestBlankFieldValidation: + locators = BaseLocators(), NewItemLocators() + endpoints = Endpoints() + + + @pytest.mark.parametrize("item_type", ItemTypesData.ITEM_TYPES) + def test_tc_01_001_04_blank_item_name_validation_1(self, open_page, page, item_type): + """TC_01.001.04 | New Item > Create a new item > Validation error when "Enter an item name" field is blank""" + + open_page(BasePage, self.endpoints.ALL_NEW_JOB_URL) + page.get_by_text(item_type, exact=True).click() + expect(page.get_by_text(NewItemPageData.EMPTY_ITEM_NAME_VALIDATION_TEXT, exact=True)).to_be_visible() + expect(page.locator(BaseLocators.OK_BUTTON)).to_be_disabled() \ No newline at end of file diff --git a/tests/old_tests/test_blank_item_name_field_validation_yc.py b/tests/old_tests/test_blank_item_name_field_validation_yc.py index 561b1f70..b9f47864 100644 --- a/tests/old_tests/test_blank_item_name_field_validation_yc.py +++ b/tests/old_tests/test_blank_item_name_field_validation_yc.py @@ -16,7 +16,6 @@ def test_tc_01_001_04(page): ok_btn_loc = "button[id='ok-button']" validation_message = "#itemname-required" - page.locator(new_item_btn_loc).click() page.get_by_text(item_type_text_freestyle_project, exact=True).click() @@ -46,9 +45,4 @@ def test_tc_01_001_04(page): page.get_by_text(item_type_text_organization_folder, exact=True).click() expect(page.locator(validation_message)).to_be_visible() - expect(page.locator(ok_btn_loc)).to_be_disabled() - - - - - + expect(page.locator(ok_btn_loc)).to_be_disabled() \ No newline at end of file