Commit 43dc6263 authored by Douwe Maan's avatar Douwe Maan

Run tests in a single browser session

parent 79440890
......@@ -18,12 +18,18 @@ describe 'Copy as GFM', feature: true, js: true do
# To make sure these filters and handlers are properly aligned, this spec tests the GFM-to-HTML-to-GFM cycle
# by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper.
it 'supports nesting' do
verify '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
end
# These are all in a single `it` for performance reasons.
it 'works', :aggregate_failures do
verify(
'nesting',
'> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
)
verify(
'a real world example from the gitlab-ce README',
it 'supports a real world example from the gitlab-ce README' do
verify <<-GFM.strip_heredoc
<<-GFM.strip_heredoc
# GitLab
[![Build status](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/build.svg)](https://gitlab.com/gitlab-org/gitlab-ce/commits/master)
......@@ -52,26 +58,27 @@ describe 'Copy as GFM', feature: true, js: true do
- Completely free and open source (MIT Expat license)
GFM
end
)
it 'supports InlineDiffFilter' do
verify(
'InlineDiffFilter',
'{-Deleted text-}',
'{+Added text+}'
)
end
it 'supports TaskListFilter' do
verify(
'TaskListFilter',
'- [ ] Unchecked task',
'- [x] Checked task',
'1. [ ] Unchecked numbered task',
'1. [x] Checked numbered task'
)
end
it 'supports ReferenceFilter' do
verify(
'ReferenceFilter',
# issue reference
@feat.issue.to_reference,
# full issue reference
......@@ -85,31 +92,40 @@ describe 'Copy as GFM', feature: true, js: true do
# issue link with note anchor
"[Issue](#{namespace_project_issue_url(@project.namespace, @project, @feat.issue, anchor: 'note_123')})",
)
end
it 'supports AutolinkFilter' do
verify 'https://example.com'
end
verify(
'AutolinkFilter',
it 'supports TableOfContentsFilter' do
verify '[[_TOC_]]'
end
'https://example.com'
)
it 'supports EmojiFilter' do
verify ':thumbsup:'
end
verify(
'TableOfContentsFilter',
it 'supports ImageLinkFilter' do
verify '![Image](https://example.com/image.png)'
end
'[[_TOC_]]'
)
it 'supports VideoLinkFilter' do
verify '![Video](https://example.com/video.mp4)'
end
verify(
'EmojiFilter',
':thumbsup:'
)
context 'MathFilter' do
it 'supports math as converted from GFM to HTML' do
verify(
'ImageLinkFilter',
'![Image](https://example.com/image.png)'
)
verify(
'VideoLinkFilter',
'![Video](https://example.com/video.mp4)'
)
verify(
'MathFilter: math as converted from GFM to HTML',
'$`c = \pm\sqrt{a^2 + b^2}`$',
# math block
......@@ -119,9 +135,8 @@ describe 'Copy as GFM', feature: true, js: true do
```
GFM
)
end
it 'supports math as transformed from HTML to KaTeX' do
aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do
gfm = '$`c = \pm\sqrt{a^2 + b^2}`$'
html = <<-HTML.strip_heredoc
......@@ -231,10 +246,10 @@ describe 'Copy as GFM', feature: true, js: true do
output_gfm = html_to_gfm(html)
expect(output_gfm.strip).to eq(gfm.strip)
end
end
it 'supports SanitizationFilter' do
verify(
'SanitizationFilter',
<<-GFM.strip_heredoc
<sub>sub</sub>
......@@ -260,10 +275,10 @@ describe 'Copy as GFM', feature: true, js: true do
<abbr>abbr</abbr>
GFM
)
end
it 'supports SyntaxHighlightFilter' do
verify(
'SanitizationFilter',
<<-GFM.strip_heredoc,
```
Plain text
......@@ -288,10 +303,10 @@ describe 'Copy as GFM', feature: true, js: true do
```
GFM
)
end
it 'supports MarkdownFilter' do
verify(
'MarkdownFilter',
"Line with two spaces at the end \nto insert a linebreak",
'`code`',
......@@ -400,8 +415,8 @@ describe 'Copy as GFM', feature: true, js: true do
page.evaluate_script(js)
end
def verify(*gfms)
aggregate_failures do
def verify(label, *gfms)
aggregate_failures(label) do
gfms.each do |gfm|
html = gfm_to_html(gfm)
output_gfm = html_to_gfm(html)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment