summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/snippet/new.rb
blob: 7431d6c1bf8a85a3506410361b14157fb90d2935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module QA
  module Page
    module Project
      module Snippet
        class New < Page::Base
          include Page::Component::NewSnippet
          include Component::LazyLoader
          view 'app/views/shared/empty_states/_snippets.html.haml' do
            element :create_first_snippet_link
            element :svg_content
          end

          def click_create_first_snippet
            finished_loading?
            # The svg takes a fraction of a second to load after which the
            # "New snippet" button shifts up a bit. This can cause
            # webdriver to miss the hit so we wait for the svg to load before
            # clicking the button.
            within_element(:svg_content) do
              has_element?(:js_lazy_loaded)
            end
            click_element(:create_first_snippet_link)
          end
        end
      end
    end
  end
end