2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-31 16:48:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Math rendering', :js do
|
2019-01-31 15:31:25 -05:00
|
|
|
let!(:project) { create(:project, :public) }
|
2019-01-24 09:41:42 -05:00
|
|
|
|
2018-01-31 16:48:18 -05:00
|
|
|
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-01-18 13:55:05 -05:00
|
|
|
expect(page).to have_selector('.katex .mord.mathdefault', text: 'b')
|
|
|
|
expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b')
|
2018-01-31 16:48:18 -05:00
|
|
|
end
|
2019-01-24 09:41:42 -05:00
|
|
|
|
|
|
|
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-07-24 08:19:25 -04:00
|
|
|
page.within '.description > .md' do
|
|
|
|
expect(page).to have_selector('.katex-error')
|
|
|
|
expect(page).to have_selector('.katex-html a', text: 'Gitlab')
|
|
|
|
end
|
2019-01-24 09:41:42 -05:00
|
|
|
end
|
2018-01-31 16:48:18 -05:00
|
|
|
end
|