diff options
author | Rémy Coutable <remy@rymai.me> | 2018-01-30 18:18:48 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-30 18:18:48 +0100 |
commit | 6e6aa187fa503ca9b962575c688499c5f2064f6f (patch) | |
tree | df984eed452f5af66144fa3ac71656a15a8f2afa | |
parent | 9d53c15c86cf8deacff2b4c0c2cbd5219b9647e5 (diff) | |
download | gitlab-ce-qa-new-dropzone-component.tar.gz |
Introduce a new QA::Gitlab::Page::Component::Dropzone classqa-new-dropzone-component
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | qa/qa.rb | 7 | ||||
-rw-r--r-- | qa/qa/page/base.rb | 15 | ||||
-rw-r--r-- | qa/qa/page/component/dropzone.rb | 25 | ||||
-rw-r--r-- | qa/qa/page/project/issue/show.rb | 7 |
4 files changed, 38 insertions, 16 deletions
@@ -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..7005217c0c3 --- /dev/null +++ b/qa/qa/page/component/dropzone.rb @@ -0,0 +1,25 @@ +module QA + module Page + module Component + class Dropzone + # include Capybara::DSL + include Scenario::Actable + + # 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(page, attachment, dropzone_form_container) + 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("#{dropzone_form_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..e78607803df 100644 --- a/qa/qa/page/project/issue/show.rb +++ b/qa/qa/page/project/issue/show.rb @@ -26,7 +26,12 @@ module QA def comment(text, attachment:) fill_in(with: text, name: 'note[note]') - attach_file_to_dropzone(attachment, '.new-note') if attachment + + if attachment + self.tap do |page| + QA::Page::Component::Dropzone.act { attach_file_to_dropzone(page, attachment, '.new-note') } + end + end click_on 'Comment' end |