File: kroki_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (55 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download
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
48
49
50
51
52
53
54
55
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'kroki rendering', :js, feature_category: :markdown do
  let_it_be(:project) { create(:project, :public) }

  before do
    stub_application_setting(kroki_enabled: true, kroki_url: 'http://localhost:8000')
  end

  it 'shows kroki image' do
    plain_text = 'This text length is ignored. ' * 300

    description = <<~KROKI
      #{plain_text}
      ```plantuml
      A -> A: T
      ```
    KROKI

    issue = create(:issue, project: project, description: description)

    visit project_issue_path(project, issue)

    within('.description') do
      expect(page).to have_css('img')
      expect(page).not_to have_text 'Warning: Displaying this diagram might cause performance issues on this page.'
    end
  end

  it 'hides kroki image and shows warning alert when kroki source size is large' do
    plantuml_text = 'A -> A: T ' * 300

    description = <<~KROKI
      ```plantuml
      #{plantuml_text}
      ```
    KROKI

    issue = create(:issue, project: project, description: description)

    visit project_issue_path(project, issue)

    within('.description') do
      expect(page).not_to have_css('img')
      expect(page).to have_text 'Warning: Displaying this diagram might cause performance issues on this page.'

      click_button 'Display'

      expect(page).to have_css('img')
      expect(page).not_to have_text 'Warning: Displaying this diagram might cause performance issues on this page.'
    end
  end
end