2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Math rendering', :js do
|
2019-03-02 22:35:43 +05:30
|
|
|
let!(:project) { create(:project, :public) }
|
2019-02-02 18:00:53 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'renders inline and display math correctly' do
|
|
|
|
description = <<~MATH
|
|
|
|
This math is inline $`a^2+b^2=c^2`$.
|
|
|
|
|
|
|
|
This is on a separate line
|
|
|
|
```math
|
|
|
|
a^2+b^2=c^2
|
|
|
|
```
|
|
|
|
MATH
|
|
|
|
|
|
|
|
issue = create(:issue, project: project, description: description)
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
|
2019-02-02 18:00:53 +05:30
|
|
|
expect(page).to have_selector('.katex .mord.mathdefault', text: 'b')
|
|
|
|
expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'only renders non XSS links' do
|
|
|
|
description = <<~MATH
|
|
|
|
This link is valid $`\\href{javascript:alert('xss');}{xss}`$.
|
|
|
|
|
|
|
|
This link is valid $`\\href{https://gitlab.com}{Gitlab}`$.
|
|
|
|
MATH
|
|
|
|
|
|
|
|
issue = create(:issue, project: project, description: description)
|
|
|
|
|
|
|
|
visit project_issue_path(project, issue)
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
page.within '.description > .md' do
|
|
|
|
expect(page).to have_selector('.katex-error')
|
|
|
|
expect(page).to have_selector('.katex-html a', text: 'Gitlab')
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|