diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/lib/banzai | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/lib/banzai')
3 files changed, 22 insertions, 21 deletions
diff --git a/spec/lib/banzai/filter/references/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/references/issue_reference_filter_spec.rb index c6f0e592cdf..d17deaa4736 100644 --- a/spec/lib/banzai/filter/references/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/references/issue_reference_filter_spec.rb @@ -93,7 +93,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Issue #{reference}") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end it 'includes a data-project attribute' do @@ -112,6 +112,14 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do expect(link.attr('data-issue')).to eq issue.id.to_s end + it 'includes data attributes for issuable popover' do + doc = reference_filter("See #{reference}") + link = doc.css('a').first + + expect(link.attr('data-project-path')).to eq project.full_path + expect(link.attr('data-iid')).to eq issue.iid.to_s + end + it 'includes a data-original attribute' do doc = reference_filter("See #{reference}") link = doc.css('a').first @@ -201,7 +209,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end it 'ignores invalid issue IDs on the referenced project' do @@ -253,7 +261,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end it 'ignores invalid issue IDs on the referenced project' do @@ -305,7 +313,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end it 'ignores invalid issue IDs on the referenced project' do @@ -347,7 +355,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end end @@ -378,7 +386,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference_link}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end end @@ -409,7 +417,7 @@ RSpec.describe Banzai::Filter::References::IssueReferenceFilter do it 'includes default classes' do doc = reference_filter("Fixed (#{reference_link}.)") - expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip' + expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue' end end diff --git a/spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb index e5809ac6949..42e8cf1c857 100644 --- a/spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/references/merge_request_reference_filter_spec.rb @@ -77,9 +77,9 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do expect(reference_filter(act).to_html).to eq exp end - it 'has no title' do + it 'has the MR title in the title attribute' do doc = reference_filter("Merge #{reference}") - expect(doc.css('a').first.attr('title')).to eq "" + expect(doc.css('a').first.attr('title')).to eq(merge.title) end it 'escapes the title attribute' do @@ -169,7 +169,6 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do expect(link.attr('data-project')).to eq project2.id.to_s expect(link.attr('data-project-path')).to eq project2.full_path expect(link.attr('data-iid')).to eq merge.iid.to_s - expect(link.attr('data-mr-title')).to eq merge.title end it 'ignores invalid merge IDs on the referenced project' do @@ -273,12 +272,6 @@ RSpec.describe Banzai::Filter::References::MergeRequestReferenceFilter do expect(doc.text).to eq("See #{mr.to_reference(full: true)} (#{commit.short_id})") end - it 'has valid title attribute' do - doc = reference_filter("See #{reference}") - - expect(doc.css('a').first.attr('title')).to eq(commit.title) - end - it 'ignores invalid commit short_ids on link text' do invalidate_commit_reference = urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=12345678" diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb index 16c958ec10b..33adca0ddfc 100644 --- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb +++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Banzai::Filter::SyntaxHighlightFilter do it "highlights as plaintext" do result = filter('<pre><code>def fun end</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">def fun end</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">def fun end</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "" @@ -59,7 +59,7 @@ RSpec.describe Banzai::Filter::SyntaxHighlightFilter do it "highlights as plaintext" do result = filter('<pre lang="gnuplot"><code>This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="gnuplot" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "gnuplot" @@ -130,13 +130,13 @@ RSpec.describe Banzai::Filter::SyntaxHighlightFilter do it "includes it in the highlighted code block" do result = filter('<pre data-sourcepos="1:1-3:3"><code lang="plaintext">This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos="1:1-3:3" class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">This is a test</span></code></pre><copy-code></copy-code></div>') end it "escape sourcepos metadata to prevent XSS" do result = filter('<pre data-sourcepos=""%22 href="x"></pre><base href=http://unsafe-website.com/><pre x=""><code></code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos=\'"%22 href="x"></pre><base href=http://unsafe-website.com/><pre x="\' class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre data-sourcepos=\'"%22 href="x"></pre><base href=http://unsafe-website.com/><pre x="\' class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" data-canonical-lang="" v-pre="true"><code></code></pre><copy-code></copy-code></div>') end end @@ -150,7 +150,7 @@ RSpec.describe Banzai::Filter::SyntaxHighlightFilter do it "highlights as plaintext" do result = filter('<pre lang="ruby"><code>This is a test</code></pre>') - expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight" lang="" v-pre="true"><code><span id="LC1" class="line" lang="">This is a test</span></code></pre><copy-code></copy-code></div>') + expect(result.to_html.delete("\n")).to eq('<div class="gl-relative markdown-code-block js-markdown-code"><pre class="code highlight js-syntax-highlight" lang="" data-canonical-lang="ruby" v-pre="true"><code><span id="LC1" class="line" lang="">This is a test</span></code></pre><copy-code></copy-code></div>') end include_examples "XSS prevention", "ruby" |