diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 21:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 21:09:19 +0300 |
commit | c54e7283c976bf7f4394e3270a28e34655275275 (patch) | |
tree | 06bdc5fff4eeceba2911bfc71e2c14b1768b43fa /spec/features/markdown | |
parent | fa7c331b76ed59230cc56fc51bfc9e467c8bb9b4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/math_spec.rb | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb index 0c77bd2a8ff..25459494a0c 100644 --- a/spec/features/markdown/math_spec.rb +++ b/spec/features/markdown/math_spec.rb @@ -64,7 +64,82 @@ RSpec.describe 'Math rendering', :js, feature_category: :team_planning do visit project_issue_path(project, issue) page.within '.description > .md' do - expect(page).to have_selector('.js-lazy-render-math') + expect(page).to have_selector('.js-lazy-render-math-container', text: /math block exceeds 1000 characters/) + end + end + + it 'allows many expansions', :js do + description = <<~MATH + ```math + #{'\\mod e ' * 100} + ``` + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + wait_for_requests + + page.within '.description > .md' do + expect(page).not_to have_selector('.katex-error') + end + end + + it 'shows error message when too many expansions', :js do + description = <<~MATH + ```math + #{'\\mod e ' * 150} + ``` + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + wait_for_requests + + page.within '.description > .md' do + click_button 'Display anyway' + + expect(page).to have_selector('.katex-error', text: /Too many expansions/) + end + end + + it 'shows error message when other errors are generated', :js do + description = <<~MATH + ```math + \\unknown + ``` + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + wait_for_requests + + page.within '.description > .md' do + expect(page).to have_selector('.katex-error', + text: /There was an error rendering this math block. KaTeX parse error/) + end + end + + it 'escapes HTML in error', :js do + description = <<~MATH + ```math + \\unknown <script> + ``` + MATH + + issue = create(:issue, project: project, description: description) + + visit project_issue_path(project, issue) + + wait_for_requests + + page.within '.description > .md' do + expect(page).to have_selector('.katex-error', text: /&lt;script&gt;/) end end |