Welcome to mirror list, hosted at ThFree Co, Russian Federation.

edit_file_soft_wrap_spec.rb « files « projects « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fda024e893dcd7ad51f688b02462fd9f0280a6be (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Projects > Files > User uses soft wrap while editing file', :js do
  before do
    project = create(:project, :repository)
    user = project.owner
    sign_in user
    visit project_new_blob_path(project, 'master', file_name: 'test_file-name')

    page.within('.file-editor.code') do
      find('.inputarea', visible: false).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
  end

  let(:toggle_button) { find('.soft-wrap-toggle') }

  it 'user clicks the "Soft wrap" button and then "No wrap" button' do
    wrapped_content_width = get_content_width

    toggle_button.click do
      expect(toggle_button).to have_content 'Soft wrap'
      unwrapped_content_width = get_content_width
      expect(unwrapped_content_width).to be > wrapped_content_width
    end

    toggle_button.click do
      expect(toggle_button).to have_content 'No wrap'
      expect(get_content_width).to be < unwrapped_content_width
    end
  end

  def get_content_width
    find('.view-lines', visible: false)[:style].slice!(/width: \d+/).slice!(/\d+/).to_i
  end
end