summaryrefslogtreecommitdiff
path: root/spec/features/projects/files
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2016-09-02 19:42:42 +0100
committerFatih Acet <acetfatih@gmail.com>2016-10-01 00:01:47 +0300
commit61afa65d4e5e1ea908d90e45364fbb4e0bcfeb56 (patch)
treec06f220d8d2c008571bde362b8d487f1a546c00d /spec/features/projects/files
parente81f89ee5a36dcda5680a459d29256899a6f7e00 (diff)
downloadgitlab-ce-61afa65d4e5e1ea908d90e45364fbb4e0bcfeb56.tar.gz
Added soft wrap logic and button to editor
Added tests Added awesomeeeeee icons
Diffstat (limited to 'spec/features/projects/files')
-rw-r--r--spec/features/projects/files/edit_file_soft_wrap_spec.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
new file mode 100644
index 00000000000..7ad90b4a89c
--- /dev/null
+++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
@@ -0,0 +1,67 @@
+require 'spec_helper'
+
+feature 'User uses soft wrap whilst editing file', feature: true, js: true do
+ before do
+ user = create(:user)
+ project = create(:project)
+ project.team << [user, :master]
+ login_as user
+ visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: 'test_file-name')
+ editor = find('.file-editor.code')
+ editor.click
+ editor.send_keys 'Touch water with paw then recoil in horror chase dog then
+ run away chase the pig around the house eat owner\'s food, and knock
+ dish off table head butt cant eat out of my own dish. Cat is love, cat
+ is life rub face on everything poop on grasses so meow. Playing with
+ balls of wool flee in terror at cucumber discovered on floor run in
+ circles tuxedo cats always looking dapper, but attack dog, run away
+ and pretend to be victim so all of a sudden cat goes crazy, yet chase
+ laser. Make muffins sit in window and stare ooo, a bird! yum lick yarn
+ hanging out of own butt jump off balcony, onto stranger\'s head yet
+ chase laser. Purr for no reason stare at ceiling hola te quiero.'.squish
+ end
+
+ let(:toggle_button) { find('.soft-wrap-toggle') }
+
+ scenario 'user clicks the "No wrap" button and then "Soft wrap" button' do
+ wrapped_content_width = get_content_width
+ toggle_button.click
+ expect(toggle_button).to have_content 'Soft wrap'
+ unwrapped_content_width = get_content_width
+ expect(unwrapped_content_width).to be > wrapped_content_width
+
+ toggle_button.click
+ expect(toggle_button).to have_content 'No wrap'
+ expect(get_content_width).to be < unwrapped_content_width
+ end
+
+ scenario 'user adds a ".js" extension and then changes to a ".md" extension' do
+ wrapped_content_width = get_content_width
+
+ fill_in 'file_name', with: 'test_file-name.js'
+ expect(toggle_button).to have_content 'Soft wrap'
+ unwrapped_content_width = get_content_width
+ expect(unwrapped_content_width).to be > wrapped_content_width
+
+ fill_in 'file_name', with: 'test_file-name.md'
+ expect(toggle_button).to have_content 'No wrap'
+ expect(get_content_width).to be < unwrapped_content_width
+ end
+
+ scenario 'user clicks "No wrap" and then changes to a ".md" extension' do
+ wrapped_content_width = get_content_width
+
+ toggle_button.click
+ expect(toggle_button).to have_content 'Soft wrap'
+ unwrapped_content_width = get_content_width
+ expect(unwrapped_content_width).to be > wrapped_content_width
+
+ fill_in 'file_name', with: 'test_file-name.md'
+ expect(toggle_button).to have_content 'Soft wrap'
+ expect(unwrapped_content_width).to be == get_content_width
+ end
+
+ def get_content_width
+ find('.ace_content')[:style].slice!(/width: \d+/).slice!(/\d+/)
+ end
+end