issue_details.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. from selenium.webdriver.common.by import By
  2. from .base import BasePage
  3. from .global_selection import GlobalSelectionPage
  4. class IssueDetailsPage(BasePage):
  5. def __init__(self, browser, client):
  6. super().__init__(browser)
  7. self.client = client
  8. self.global_selection = GlobalSelectionPage(browser)
  9. def visit_issue(self, org, groupid):
  10. self.browser.get(f"/organizations/{org}/issues/{groupid}/")
  11. self.wait_until_loaded()
  12. def visit_issue_activity(self, org, groupid):
  13. self.browser.get(f"/organizations/{org}/issues/{groupid}/activity/")
  14. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  15. def visit_issue_in_environment(self, org, groupid, environment):
  16. self.browser.get(f"/organizations/{org}/issues/{groupid}/?environment={environment}")
  17. self.browser.wait_until(".group-detail")
  18. def visit_tag_values(self, org, groupid, tag):
  19. self.browser.get(f"/organizations/{org}/issues/{groupid}/tags/{tag}/")
  20. self.browser.wait_until('[data-test-id="group-tag-value"]')
  21. def get_environment(self):
  22. return self.browser.find_element(
  23. by=By.CSS_SELECTOR, value='[data-test-id="env-label"'
  24. ).text.lower()
  25. def go_back_to_issues(self):
  26. self.global_selection.go_back_to_issues()
  27. def api_issue_get(self, groupid):
  28. return self.client.get(f"/api/0/issues/{groupid}/")
  29. def go_to_subtab(self, name):
  30. tabs = self.browser.find_element(by=By.CSS_SELECTOR, value=".group-detail .nav-tabs")
  31. tabs.find_element(by=By.PARTIAL_LINK_TEXT, value=name).click()
  32. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  33. def open_issue_errors(self):
  34. self.browser.click(".errors-toggle")
  35. self.browser.wait_until(".entries > .errors ul")
  36. def open_curl(self):
  37. self.browser.find_element(by=By.XPATH, value="//a//code[contains(text(), 'curl')]").click()
  38. def resolve_issue(self):
  39. self.browser.click('[aria-label="Resolve"]')
  40. # Resolve should become unresolve
  41. self.browser.wait_until('[aria-label="Unresolve"]')
  42. def ignore_issue(self):
  43. self.browser.click('[aria-label="Ignore"]')
  44. # Ignore should become unresolve
  45. self.browser.wait_until('[aria-label="Unignore"]')
  46. def bookmark_issue(self):
  47. self.browser.click('button[aria-label="More Actions"]')
  48. self.browser.wait_until('[data-test-id="bookmark"]')
  49. button = self.browser.element('[data-test-id="bookmark"]')
  50. button.click()
  51. self.browser.click('button[aria-label="More Actions"]')
  52. self.browser.wait_until('[data-test-id="unbookmark"]')
  53. def assign_to(self, user):
  54. assignee = self.browser.find_element(by=By.CSS_SELECTOR, value=".assigned-to")
  55. # Open the assignee picker
  56. assignee.find_element(by=By.CSS_SELECTOR, value='[role="button"]').click()
  57. assignee.find_element(by=By.TAG_NAME, value="input").send_keys(user)
  58. # Click the member/team
  59. options = assignee.find_elements(
  60. by=By.CSS_SELECTOR, value='[data-test-id="assignee-option"]'
  61. )
  62. assert len(options) > 0, "No assignees could be found."
  63. options[0].click()
  64. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  65. def find_comment_form(self):
  66. self.browser.wait_until_test_id("note-input-form")
  67. return self.browser.find_element(
  68. by=By.CSS_SELECTOR, value='[data-test-id="note-input-form"]'
  69. )
  70. def has_comment(self, text):
  71. element = self.browser.element('[data-test-id="activity-note-body"]')
  72. return text in element.text
  73. def wait_until_loaded(self):
  74. self.browser.wait_until_not('[data-test-id="loading-indicator"]')
  75. self.browser.wait_until_test_id("event-entries-loading-false")
  76. self.browser.wait_until_test_id("linked-issues")
  77. self.browser.wait_until_test_id("loaded-device-name")
  78. if self.browser.element_exists("#grouping-info"):
  79. self.browser.wait_until_test_id("loaded-grouping-info")
  80. self.browser.wait_until_not('[data-test-id="loading-placeholder"]')
  81. def mark_reviewed(self):
  82. self.browser.click('[aria-label="Mark Reviewed"]')
  83. self.browser.wait_until('.disabled[aria-label="Mark Reviewed"]')