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

Run tests in a single browser session

parent 79440890
...@@ -18,60 +18,67 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -18,60 +18,67 @@ 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 # 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. # 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 # These are all in a single `it` for performance reasons.
verify '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**' it 'works', :aggregate_failures do
end verify(
'nesting',
it 'supports a real world example from the gitlab-ce README' do '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
verify <<-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) verify(
[![CE coverage report](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/coverage.svg?job=coverage)](https://gitlab-org.gitlab.io/gitlab-ce/coverage-ruby) 'a real world example from the gitlab-ce README',
[![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.svg)](https://codeclimate.com/github/gitlabhq/gitlabhq)
[![Core Infrastructure Initiative Best Practices](https://bestpractices.coreinfrastructure.org/projects/42/badge)](https://bestpractices.coreinfrastructure.org/projects/42)
## Canonical source <<-GFM.strip_heredoc
# GitLab
The canonical source of GitLab Community Edition is [hosted on GitLab.com](https://gitlab.com/gitlab-org/gitlab-ce/). [![Build status](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/build.svg)](https://gitlab.com/gitlab-org/gitlab-ce/commits/master)
[![CE coverage report](https://gitlab.com/gitlab-org/gitlab-ce/badges/master/coverage.svg?job=coverage)](https://gitlab-org.gitlab.io/gitlab-ce/coverage-ruby)
[![Code Climate](https://codeclimate.com/github/gitlabhq/gitlabhq.svg)](https://codeclimate.com/github/gitlabhq/gitlabhq)
[![Core Infrastructure Initiative Best Practices](https://bestpractices.coreinfrastructure.org/projects/42/badge)](https://bestpractices.coreinfrastructure.org/projects/42)
## Open source software to collaborate on code ## Canonical source
To see how GitLab looks please see the [features page on our website](https://about.gitlab.com/features/). The canonical source of GitLab Community Edition is [hosted on GitLab.com](https://gitlab.com/gitlab-org/gitlab-ce/).
## Open source software to collaborate on code
- Manage Git repositories with fine grained access controls that keep your code secure To see how GitLab looks please see the [features page on our website](https://about.gitlab.com/features/).
- Perform code reviews and enhance collaboration with merge requests
- Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications - Manage Git repositories with fine grained access controls that keep your code secure
- Each project can also have an issue tracker, issue board, and a wiki - Perform code reviews and enhance collaboration with merge requests
- Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises - Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications
- Completely free and open source (MIT Expat license) - Each project can also have an issue tracker, issue board, and a wiki
GFM
end - Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises
- Completely free and open source (MIT Expat license)
GFM
)
it 'supports InlineDiffFilter' do
verify( verify(
'InlineDiffFilter',
'{-Deleted text-}', '{-Deleted text-}',
'{+Added text+}' '{+Added text+}'
) )
end
it 'supports TaskListFilter' do
verify( verify(
'TaskListFilter',
'- [ ] Unchecked task', '- [ ] Unchecked task',
'- [x] Checked task', '- [x] Checked task',
'1. [ ] Unchecked numbered task', '1. [ ] Unchecked numbered task',
'1. [x] Checked numbered task' '1. [x] Checked numbered task'
) )
end
it 'supports ReferenceFilter' do
verify( verify(
'ReferenceFilter',
# issue reference # issue reference
@feat.issue.to_reference, @feat.issue.to_reference,
# full issue reference # full issue reference
...@@ -85,43 +92,51 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -85,43 +92,51 @@ describe 'Copy as GFM', feature: true, js: true do
# issue link with note anchor # issue link with note anchor
"[Issue](#{namespace_project_issue_url(@project.namespace, @project, @feat.issue, anchor: 'note_123')})", "[Issue](#{namespace_project_issue_url(@project.namespace, @project, @feat.issue, anchor: 'note_123')})",
) )
end
it 'supports AutolinkFilter' do verify(
verify 'https://example.com' 'AutolinkFilter',
end
it 'supports TableOfContentsFilter' do 'https://example.com'
verify '[[_TOC_]]' )
end
it 'supports EmojiFilter' do verify(
verify ':thumbsup:' 'TableOfContentsFilter',
end
it 'supports ImageLinkFilter' do '[[_TOC_]]'
verify '![Image](https://example.com/image.png)' )
end
it 'supports VideoLinkFilter' do verify(
verify '![Video](https://example.com/video.mp4)' 'EmojiFilter',
end
context 'MathFilter' do ':thumbsup:'
it 'supports math as converted from GFM to HTML' do )
verify(
'$`c = \pm\sqrt{a^2 + b^2}`$', verify(
'ImageLinkFilter',
# math block
<<-GFM.strip_heredoc '![Image](https://example.com/image.png)'
```math )
c = \pm\sqrt{a^2 + b^2}
``` verify(
GFM 'VideoLinkFilter',
)
end '![Video](https://example.com/video.mp4)'
)
verify(
'MathFilter: math as converted from GFM to HTML',
'$`c = \pm\sqrt{a^2 + b^2}`$',
it 'supports math as transformed from HTML to KaTeX' do # math block
<<-GFM.strip_heredoc
```math
c = \pm\sqrt{a^2 + b^2}
```
GFM
)
aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do
gfm = '$`c = \pm\sqrt{a^2 + b^2}`$' gfm = '$`c = \pm\sqrt{a^2 + b^2}`$'
html = <<-HTML.strip_heredoc html = <<-HTML.strip_heredoc
...@@ -231,10 +246,10 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -231,10 +246,10 @@ describe 'Copy as GFM', feature: true, js: true do
output_gfm = html_to_gfm(html) output_gfm = html_to_gfm(html)
expect(output_gfm.strip).to eq(gfm.strip) expect(output_gfm.strip).to eq(gfm.strip)
end end
end
it 'supports SanitizationFilter' do
verify( verify(
'SanitizationFilter',
<<-GFM.strip_heredoc <<-GFM.strip_heredoc
<sub>sub</sub> <sub>sub</sub>
...@@ -260,10 +275,10 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -260,10 +275,10 @@ describe 'Copy as GFM', feature: true, js: true do
<abbr>abbr</abbr> <abbr>abbr</abbr>
GFM GFM
) )
end
it 'supports SyntaxHighlightFilter' do
verify( verify(
'SanitizationFilter',
<<-GFM.strip_heredoc, <<-GFM.strip_heredoc,
``` ```
Plain text Plain text
...@@ -280,7 +295,7 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -280,7 +295,7 @@ describe 'Copy as GFM', feature: true, js: true do
<<-GFM.strip_heredoc <<-GFM.strip_heredoc
Foo Foo
This is an example of GFM This is an example of GFM
```js ```js
...@@ -288,10 +303,10 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -288,10 +303,10 @@ describe 'Copy as GFM', feature: true, js: true do
``` ```
GFM GFM
) )
end
it 'supports MarkdownFilter' do
verify( verify(
'MarkdownFilter',
"Line with two spaces at the end \nto insert a linebreak", "Line with two spaces at the end \nto insert a linebreak",
'`code`', '`code`',
...@@ -400,8 +415,8 @@ describe 'Copy as GFM', feature: true, js: true do ...@@ -400,8 +415,8 @@ describe 'Copy as GFM', feature: true, js: true do
page.evaluate_script(js) page.evaluate_script(js)
end end
def verify(*gfms) def verify(label, *gfms)
aggregate_failures do aggregate_failures(label) do
gfms.each do |gfm| gfms.each do |gfm|
html = gfm_to_html(gfm) html = gfm_to_html(gfm)
output_gfm = html_to_gfm(html) 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