summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-01-31 11:16:29 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-01-31 11:16:29 +0000
commit4251c6565fa18ecd64befe3a2561df30d48d1846 (patch)
treeb42253c8c3acb3956aed10d667a6edf69b972060
parentdacd9dbef4b245f7da5640e3638eae05e9678992 (diff)
parent2f4d088fb4f3d17622655951dcc16255646d0f7f (diff)
downloadgitlab-ce-4251c6565fa18ecd64befe3a2561df30d48d1846.tar.gz
Merge branch 'qa-new-dropzone-component' into 'master'
Introduce a new QA::Gitlab::Page::Component::Dropzone class See merge request gitlab-org/gitlab-ce!16805
-rw-r--r--qa/qa.rb7
-rw-r--r--qa/qa/page/base.rb15
-rw-r--r--qa/qa/page/component/dropzone.rb29
-rw-r--r--qa/qa/page/project/issue/show.rb7
4 files changed, 41 insertions, 17 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index bd24f241747..8630e2a522c 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -150,6 +150,13 @@ module QA
autoload :Main, 'qa/page/mattermost/main'
autoload :Login, 'qa/page/mattermost/login'
end
+
+ ##
+ # Classes describing components that are used by several pages.
+ #
+ module Component
+ autoload :Dropzone, 'qa/page/component/dropzone'
+ end
end
##
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 7a2d9731205..5c3af4b9115 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -97,21 +97,6 @@ module QA
views.map(&:errors).flatten
end
- # Not tested and not expected to work with multiple dropzones
- # instantiated on one page because there is no distinguishing
- # attribute per dropzone file field.
- def attach_file_to_dropzone(attachment, dropzone_form_container)
- filename = File.basename(attachment)
-
- field_style = { visibility: 'visible', height: '', width: '' }
- attach_file(attachment, class: 'dz-hidden-input', make_visible: field_style)
-
- # Wait for link to be appended to dropzone text
- wait(reload: false) do
- find("#{dropzone_form_container} textarea").value.match(filename)
- end
- end
-
class DSL
attr_reader :views
diff --git a/qa/qa/page/component/dropzone.rb b/qa/qa/page/component/dropzone.rb
new file mode 100644
index 00000000000..5e6fdff20eb
--- /dev/null
+++ b/qa/qa/page/component/dropzone.rb
@@ -0,0 +1,29 @@
+module QA
+ module Page
+ module Component
+ class Dropzone
+ attr_reader :page, :container
+
+ def initialize(page, container)
+ @page = page
+ @container = container
+ end
+
+ # Not tested and not expected to work with multiple dropzones
+ # instantiated on one page because there is no distinguishing
+ # attribute per dropzone file field.
+ def attach_file(attachment)
+ filename = File.basename(attachment)
+
+ field_style = { visibility: 'visible', height: '', width: '' }
+ page.attach_file(attachment, class: 'dz-hidden-input', make_visible: field_style)
+
+ # Wait for link to be appended to dropzone text
+ page.wait(reload: false) do
+ page.find("#{container} textarea").value.match(filename)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb
index 10644c0fecc..364a2c61665 100644
--- a/qa/qa/page/project/issue/show.rb
+++ b/qa/qa/page/project/issue/show.rb
@@ -23,10 +23,13 @@ module QA
# Adds a comment to an issue
# attachment option should be an absolute path
- def comment(text, attachment:)
+ def comment(text, attachment: nil)
fill_in(with: text, name: 'note[note]')
- attach_file_to_dropzone(attachment, '.new-note') if attachment
+ unless attachment.nil?
+ QA::Page::Component::Dropzone.new(page, '.new-note')
+ .attach_file(attachment)
+ end
click_on 'Comment'
end