From f68553dc00372161b625f5c61d46d48c2950d356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 18 Jun 2020 16:08:27 +0200 Subject: [PATCH] Extract method to fill in markdown editor in specs --- spec/support/common_actions/verifications.rb | 9 +++++++++ spec/system/admin/legislation/draft_versions_spec.rb | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spec/support/common_actions/verifications.rb b/spec/support/common_actions/verifications.rb index d9c4b2c68..b6e65fae4 100644 --- a/spec/support/common_actions/verifications.rb +++ b/spec/support/common_actions/verifications.rb @@ -55,4 +55,13 @@ module Verifications within_frame(0) { find("body").set(with) } end end + + def fill_in_markdown_editor(label, with:) + click_link "Launch text editor" + fill_in label, with: with + + within(".fullscreen") do + click_link "Close text editor" + end + end end diff --git a/spec/system/admin/legislation/draft_versions_spec.rb b/spec/system/admin/legislation/draft_versions_spec.rb index e6c12238d..5ac47be22 100644 --- a/spec/system/admin/legislation/draft_versions_spec.rb +++ b/spec/system/admin/legislation/draft_versions_spec.rb @@ -83,14 +83,7 @@ describe "Admin legislation draft versions" do click_link "Version 1" fill_in "Version title", with: "Version 1b" - - click_link "Launch text editor" - - fill_in "Text", with: "# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote" - - within(".fullscreen") do - click_link "Close text editor" - end + fill_in_markdown_editor "Text", with: "# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote" click_button "Save changes"