selectors.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. # This file defines custom Capybara selectors for DRYed specs.
  3. Capybara.add_selector(:href) do
  4. css { |href| %(a[href="#{href}"]) }
  5. end
  6. Capybara.add_selector(:active_content) do
  7. css { |content_class| ['.content.active', content_class].compact.join(' ') }
  8. end
  9. Capybara.add_selector(:active_ticket_article) do
  10. css { |article| ['.content.active', "#article-#{article.id}" ].compact.join(' ') }
  11. end
  12. Capybara.add_selector(:manage) do
  13. css { 'a[href="#manage"]' }
  14. end
  15. Capybara.add_selector(:clues_close) do
  16. css { '.js-modal--clue .js-close' }
  17. end
  18. Capybara.add_selector(:richtext) do
  19. css { |name| "div[data-name=#{name || 'body'}]" }
  20. end
  21. Capybara.add_selector(:code_editor) do
  22. css { |name| "div[data-attribute-name=#{name}] div.CodeMirror-code" }
  23. end
  24. Capybara.add_selector(:text_module) do
  25. css { |id| %(.shortcut > ul > li[data-id="#{id}"]) }
  26. end
  27. Capybara.add_selector(:macro) do
  28. css { |id| %(.js-submitDropdown > ul > li[data-id="#{id}"]) }
  29. end
  30. Capybara.add_selector(:macro_batch) do
  31. css { |id| %(.batch-overlay-macro-entry[data-id='#{id}'] .batch-overlay-macro-entry-name) }
  32. end
  33. Capybara.add_selector(:table_row) do
  34. css { |id| %(tr[data-id='#{id}']) }
  35. end
  36. Capybara.add_selector(:link_containing) do
  37. xpath { |text| ".//a//*[text()[contains(.,\"#{text}\")]]" }
  38. end
  39. Capybara.add_selector(:task_active) do
  40. css { '.tasks .task.is-active' }
  41. end
  42. Capybara.add_selector(:task_with) do
  43. css { |task_key| ".tasks .task[data-key='#{task_key}']" }
  44. end
  45. Capybara.add_selector(:draft_sidebar_button) do
  46. css { '.tabsSidebar-tab[data-tab=shared_draft]' }
  47. end
  48. Capybara.add_selector(:draft_sidebar) do
  49. css { '.shared-drafts-manage' }
  50. end
  51. Capybara.add_selector(:draft_share_button) do
  52. css { '.attributeBar-draft' }
  53. end
  54. Capybara.add_selector(:draft_save_button) do
  55. css { '.js-dropdownActionSaveDraft' }
  56. end