summaryrefslogtreecommitdiff
path: root/spec/docs_screenshots/wiki_docs.rb
blob: e7b71408b1c8b033876c412af2d2a94182d374db (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
47
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Wiki', :js do
  include DocsScreenshotHelpers
  include WikiHelpers

  let(:user) { create(:user) }
  let(:project) { create(:project, namespace: user.namespace, creator: user) }
  let(:wiki) { create(:project_wiki, user: user, project: project) }

  before do
    page.driver.browser.manage.window.resize_to(1366, 1024)

    sign_in(user)
    visit wiki_path(wiki)

    click_link "Create your first page"
  end

  context 'switching to content editor' do
    it 'user/project/wiki/img/use_new_editor_button' do
      screenshot_area = find('[data-testid="wiki-form-content-fieldset"]')
      scroll_to screenshot_area
      expect(screenshot_area).to have_content 'Use the new editor'
      set_crop_data(screenshot_area, 0)
    end
  end

  context 'content editor' do
    it 'user/project/wiki/img/content_editor' do
      content_editor_testid = '[data-testid="wiki-form-content-fieldset"]'

      click_button 'Use the new editor'

      expect(page).to have_css(content_editor_testid)

      screenshot_area = find(content_editor_testid)
      scroll_to screenshot_area

      find("#{content_editor_testid} [contenteditable]").send_keys '## Using the Content Editor'

      set_crop_data(screenshot_area, 0)
    end
  end
end