Skip to content

Commit

Permalink
Merge pull request #278 from RedHatProductSecurity/feature/OSIDB-2488
Browse files Browse the repository at this point in the history
Remove checkbox on flaw table
  • Loading branch information
tboyetteredhat authored Jun 17, 2024
2 parents e1f6e49 + ab7145c commit 6d3b729
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 171 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Add link to bugzilla tracker on Flaw form (`OSIDB-2897`)
* Set public date to current date on unembargo (`OSIDB-2829`)
* Add CVSSv3 score explanation input field (`OSIDB-2913`)
* Remove checkbox on IssueQueue (`OSIDB-2488`)

### Changed
* Switch Flaw.component to Flaw.components (`OSIDB-2777`)
Expand Down
26 changes: 13 additions & 13 deletions features/flaw_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ Feature: Flaw list testing
When I click the link of a flaw
Then I am able to view the flaw detail

Scenario: All flaws are selected when check-all checkbox is checked
When I check the check-all checkbox of flaw table
Then All flaws in flaw table are selected

Scenario: All flaws are unselected when check-all checkbox is unchecked
Given The check-all checkbox of flaw list is checked
When I uncheck the check-all checkbox
Then No flaw in flaw table is selected

@skip
Scenario: Bulk assign flaws to me
When I select some flaws from flaw list and click 'Assign to Me'
Then The owner of selected flaws is updated to me
# Scenario: All flaws are selected when check-all checkbox is checked
# When I check the check-all checkbox of flaw table
# Then All flaws in flaw table are selected
#
# Scenario: All flaws are unselected when check-all checkbox is unchecked
# Given The check-all checkbox of flaw list is checked
# When I uncheck the check-all checkbox
# Then No flaw in flaw table is selected
#
# @skip
# Scenario: Bulk assign flaws to me
# When I select some flaws from flaw list and click 'Assign to Me'
# Then The owner of selected flaws is updated to me

Scenario: Sort flaw list on home page
When I click the field header of flaw list table
Expand Down
12 changes: 6 additions & 6 deletions features/pages/advanced_search_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def __init__(self, driver):
"inputTextWindow": ("XPATH", "//details/form/div/input[@class='form-control']"),
"selectKeyList2": ("XPATH", "(//select[@class='form-select search-facet-field'])[2]"),
"selectValueList2": ("XPATH", "(//select[@class='form-select'])[2]"),
"cve_idText": ("XPATH", "//tr[1]/td[2]/a"),
"impactText": ("XPATH", "//tr[1]/td[3]"),
"sourceText": ("XPATH", "//tr[1]/td[4]"),
"titleText": ("XPATH", "//tr[1]/td[6]"),
"workflow_stateText": ("XPATH", "//tr[1]/td[7]"),
"ownerText": ("XPATH", "//tr[1]/td[8]"),
"cve_idText": ("XPATH", "//tr[1]/td[1]/a"),
"impactText": ("XPATH", "//tr[1]/td[2]"),
# "sourceText": ("XPATH", "//tr[1]/td[3]"), # TODO remove unused
"titleText": ("XPATH", "//tr[1]/td[4]"),
"workflow_stateText": ("XPATH", "//tr[1]/td[5]"),
"ownerText": ("XPATH", "//tr[1]/td[6]"),
"closeKeysetBtn": ("XPATH", "//button[@class='osim-toast-close-btn btn-close']"),
"closeSelBtn": ("XPATH", "//i[@class='bi-x']"),
"embargoedFlag": ("XPATH", "(//span[contains(text(), 'Embargoed')])[1]"),
Expand Down
96 changes: 48 additions & 48 deletions features/pages/home_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def __init__(self, driver):
"flawCheckBox": ("CSS", "input[class='form-check-input']"),
"loadMoreFlawsBtn": ("XPATH", "//button[contains(text(), 'Load More Flaws')]"),
"firstFlaw": ("XPATH", "//div[@class='osim-incident-list']/table/tbody/tr[1]"),
"firstFlawLink": ("XPATH", '//tbody[@class="table-group-divider"]/tr[1]/td[2]/a'),
"firstFlawLink": ("XPATH", '//tbody[@class="table-group-divider"]/tr[1]/td[1]/a'),
"settingsBtn": ("LINK_TEXT", "Settings"),
"flawIndexBtn": ("CSS", "ul[class='navbar-nav me-auto align-items-center'] li:nth-child(1) a"),
"flawFilterBox": ("CSS", "input[placeholder='Filter Issues/Flaws']"),
"advancedSearchDropDownBtn": ("XPATH", '//form[@role="search"]/div/button[2]'),
"advancedSearchBtn": ("XPATH", "//a[contains(text(), 'Advanced Search')]"),
"cve_idText": ("XPATH", "//tr[3]/td[2]/a"),
"cve_idText": ("XPATH", "//tr[3]/td[1]/a"),
"quickSearchBox": ("XPATH", "//form[@role='search']/div/input"),
"quickSearchBtn": ("XPATH", "//form[@role='search']/div/button"),
"myIssuesCheckbox": ("XPATH", "(//input[@class='d-inline-block form-check-input'])[1]"),
"openIssuesCheckbox": ("XPATH", "(//input[@class='d-inline-block form-check-input'])[2]"),
"defaultFilterCheckbox": ("XPATH", "(//input[@class='d-inline-block form-check-input'])[3]"),
"ownerText": ("XPATH", "//tr[1]/td[7]"),
"bulkActionBtn": ("XPATH", "//button[contains(text(), 'Bulk Action')]"),
"assignToMeBtn": ("XPATH", "//a[contains(text(), 'Assign to Me')]"),
"ownerText": ("XPATH", "//tr[1]/td[6]"),
# "bulkActionBtn": ("XPATH", "//button[contains(text(), 'Bulk Action')]"), # TODO remove unused
# "assignToMeBtn": ("XPATH", "//a[contains(text(), 'Assign to Me')]"), # TODO remove unused
"flawSavedMsg": ("XPATH", "//div[text()='Flaw saved']"),
"idBtn": ("XPATH", "//thead[@class='sticky-top']/tr/th[contains(text(), 'ID')]"),
"impactBtn": ("XPATH", "//thead[@class='sticky-top']/tr/th[contains(text(), 'Impact')]"),
Expand All @@ -58,21 +58,21 @@ def flaw_list_exist(self):
def first_flaw_exist(self):
self.firstFlaw.visibility_of_element_located()

def click_flaw_check_all_checkbox(self):
self.firstFlaw.visibility_of_element_located()
self.flawCheckAllCheckBox.click_button()

def check_is_all_flaw_selected(self):
flaw_rows = find_elements_in_page_factory(self, "flawRow")
flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
assert len(flaw_rows) + 1 == len(flaw_checkboxes), 'Incorrect checkbox count'
flaw_checked = [c for c in flaw_checkboxes if c.get_attribute('checked') == 'true']
assert len(flaw_checked) == len(flaw_checkboxes), 'Incorrect check-all check result'

def check_is_all_flaw_unselected(self):
flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
flaw_checked = [c for c in flaw_checkboxes if c.get_attribute('checked') == 'true']
assert len(flaw_checked) == 0, 'Incorrect check-all uncheck result'
# def click_flaw_check_all_checkbox(self):
# self.firstFlaw.visibility_of_element_located()
# self.flawCheckAllCheckBox.click_button()
#
# def check_is_all_flaw_selected(self):
# flaw_rows = find_elements_in_page_factory(self, "flawRow")
# flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
# assert len(flaw_rows) + 1 == len(flaw_checkboxes), 'Incorrect checkbox count'
# flaw_checked = [c for c in flaw_checkboxes if c.get_attribute('checked') == 'true']
# assert len(flaw_checked) == len(flaw_checkboxes), 'Incorrect check-all check result'
#
# def check_is_all_flaw_unselected(self):
# flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
# flaw_checked = [c for c in flaw_checkboxes if c.get_attribute('checked') == 'true']
# assert len(flaw_checked) == 0, 'Incorrect check-all uncheck result'

def check_is_all_flaw_loaded(self):
self.firstFlaw.visibility_of_element_located()
Expand Down Expand Up @@ -112,34 +112,34 @@ def clear_box(self, field):
self.driver.execute_script("arguments[0].scrollIntoView(true);", field_input)
field_input.send_keys(Keys.CONTROL + 'a', Keys.BACKSPACE)

def select_bulk_flaws(self, length=1):
self.firstFlaw.visibility_of_element_located()
flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
links = []
for i in range(1, length+1):
checkbox = flaw_checkboxes[i]
checkbox.click()
flaw_link = self.driver.find_element(
By.XPATH, f"(//td[contains(@class, 'osim-issue-title')])[{i}]/a")
links.append(flaw_link)
return links

def bulk_assign(self):
self.click_btn('bulkActionBtn')
hide = self.driver.find_elements(
locate_with(By.XPATH, "//div[@class='osim-incident-list']/table/thead"))[0]
self.driver.execute_script("arguments[0].style.visibility='hidden'", hide)
self.click_btn('assignToMeBtn')
self.driver.execute_script("arguments[0].style.visibility='visible'", hide)

def check_bulk_assign(self, flaw_link):
from features.utils import wait_for_visibility_by_locator
flaw_link.click()
wait_for_visibility_by_locator(self.driver, By.XPATH, '//button[text()=" Save Changes "]')
assignee_value_element = self.driver.find_elements(
locate_with(By.XPATH, ("(//span[@class='osim-editable-text-value form-control'])[6]")))[0]
login_user = self.userBtn.get_text()
assert assignee_value_element.get_text() == login_user.strip(), 'Bulk assign failed'
# def select_bulk_flaws(self, length=1):
# self.firstFlaw.visibility_of_element_located()
# flaw_checkboxes = find_elements_in_page_factory(self, "flawCheckBox")
# links = []
# for i in range(1, length+1):
# checkbox = flaw_checkboxes[i]
# checkbox.click()
# flaw_link = self.driver.find_element(
# By.XPATH, f"(//td[contains(@class, 'osim-issue-title')])[{i}]/a")
# links.append(flaw_link)
# return links
#
# def bulk_assign(self):
# self.click_btn('bulkActionBtn')
# hide = self.driver.find_elements(
# locate_with(By.XPATH, "//div[@class='osim-incident-list']/table/thead"))[0]
# self.driver.execute_script("arguments[0].style.visibility='hidden'", hide)
# self.click_btn('assignToMeBtn')
# self.driver.execute_script("arguments[0].style.visibility='visible'", hide)
#
# def check_bulk_assign(self, flaw_link):
# from features.utils import wait_for_visibility_by_locator
# flaw_link.click()
# wait_for_visibility_by_locator(self.driver, By.XPATH, '//button[text()=" Save Changes "]')
# assignee_value_element = self.driver.find_elements(
# locate_with(By.XPATH, ("(//span[@class='osim-editable-text-value form-control'])[6]")))[0]
# login_user = self.userBtn.get_text()
# assert assignee_value_element.get_text() == login_user.strip(), 'Bulk assign failed'

def get_sort_flaws(self, field, sort_fields):
sorted_numbers = sorted(random.sample(range(1, 50), 3))
Expand Down
73 changes: 37 additions & 36 deletions features/steps/flaw_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,42 +38,43 @@ def step_impl(context):
home_page.check_is_all_flaw_selected()


@given('The check-all checkbox of flaw list is checked')
def step_impl(context):
context.execute_steps(u"""
When I check the check-all checkbox of flaw table
""")


@when('I uncheck the check-all checkbox')
def step_impl(context):
home_page = HomePage(context.browser)
home_page.click_flaw_check_all_checkbox()


@then('No flaw in flaw table is selected')
def step_impl(context):
home_page = HomePage(context.browser)
home_page.check_is_all_flaw_unselected()


@when("I select some flaws from flaw list and click 'Assign to Me'")
def step_impl(context):
home_page = HomePage(context.browser)
# 1. Wait for loading flaw list and select flaws to bulk assign
context.links = home_page.select_bulk_flaws()
# 2. Click bulck action and assign to me buttons
home_page.bulk_assign()
# 3. Wait message "Flaw saved"
# The current bulk assign is not actually bulk update, thus
# there will be a 'Flaw saved' message for each selected flaw.
home_page.wait_msg('flawSavedMsg')


@then("The owner of selected flaws is updated to me")
def step_impl(context):
home_page = HomePage(context.browser)
home_page.check_bulk_assign(context.links[0])
# @given('The check-all checkbox of flaw list is checked')
# def step_impl(context):
# context.execute_steps(u"""
# When I check the check-all checkbox of flaw table
# """)
#
#
# @when('I uncheck the check-all checkbox')
# def step_impl(context):
# home_page = HomePage(context.browser)
# home_page.click_flaw_check_all_checkbox()
#
#
# @then('No flaw in flaw table is selected')
# def step_impl(context):
# home_page = HomePage(context.browser)
# home_page.check_is_all_flaw_unselected()
# context.browser.quit()
#
#
# @when("I select some flaws from flaw list and click 'Assign to Me'")
# def step_impl(context):
# home_page = HomePage(context.browser)
# # 1. Wait for loading flaw list and select flaws to bulk assign
# context.links = home_page.select_bulk_flaws()
# # 2. Click bulck action and assign to me buttons
# home_page.bulk_assign()
# # 3. Wait message "Flaw saved"
# # The current bulk assign is not actually bulk update, thus
# # there will be a 'Flaw saved' message for each selected flaw.
# home_page.wait_msg('flawSavedMsg')
#
#
# @then("The owner of selected flaws is updated to me")
# def step_impl(context):
# home_page = HomePage(context.browser)
# home_page.check_bulk_assign(context.links[0])


@when("I click the field header of flaw list table")
Expand Down
Loading

0 comments on commit 6d3b729

Please sign in to comment.