diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 09:07:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-24 09:07:07 +0300 |
commit | 12287a65b735d784cda3555d1b261e50b461b29e (patch) | |
tree | e7539b1b3672986a4f41b544f913ee120d623d44 /spec | |
parent | 24ed154fa81265f47bcfbecfcb331f82a5faad0d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/blobs/edit_spec.rb | 7 | ||||
-rw-r--r-- | spec/javascripts/blob/viewer/index_spec.js | 49 |
2 files changed, 42 insertions, 14 deletions
diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index 3b32d213754..e02a4579095 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -60,6 +60,13 @@ describe 'Editing file blob', :js do expect(page).to have_content 'NextFeature' end + it 'renders a URL in the content of file as a link' do + project.repository.create_file(user, 'file.yml', '# go to https://gitlab.com', message: 'testing', branch_name: branch) + visit project_edit_blob_path(project, tree_join(branch, 'file.yml')) + + expect(page).to have_selector('.ace_content .ace_line a') + end + context 'from blob file path' do before do visit project_blob_path(project, tree_join(branch, file_path)) diff --git a/spec/javascripts/blob/viewer/index_spec.js b/spec/javascripts/blob/viewer/index_spec.js index 06c06613887..bbc59632f3c 100644 --- a/spec/javascripts/blob/viewer/index_spec.js +++ b/spec/javascripts/blob/viewer/index_spec.js @@ -11,6 +11,13 @@ describe('Blob viewer', () => { preloadFixtures('snippets/show.html'); + const asyncClick = () => + new Promise(resolve => { + document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); + + setTimeout(resolve); + }); + beforeEach(() => { mock = new MockAdapter(axios); @@ -66,19 +73,12 @@ describe('Blob viewer', () => { }); it('doesnt reload file if already loaded', done => { - const asyncClick = () => - new Promise(resolve => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(resolve); - }); - asyncClick() .then(() => asyncClick()) .then(() => { - expect( - document.querySelector('.blob-viewer[data-type="simple"]').getAttribute('data-loaded'), - ).toBe('true'); + expect(document.querySelector('.blob-viewer[data-type="simple"]').dataset.loaded).toBe( + 'true', + ); done(); }) @@ -100,9 +100,7 @@ describe('Blob viewer', () => { }); it('has tooltip when disabled', () => { - expect(copyButton.getAttribute('data-original-title')).toBe( - 'Switch to the source to copy the file contents', - ); + expect(copyButton.dataset.title).toBe('Switch to the source to copy the file contents'); }); it('is blurred when clicked and disabled', () => { @@ -136,7 +134,7 @@ describe('Blob viewer', () => { document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); setTimeout(() => { - expect(copyButton.getAttribute('data-original-title')).toBe('Copy file contents'); + expect(copyButton.dataset.title).toBe('Copy file contents'); done(); }); @@ -177,4 +175,27 @@ describe('Blob viewer', () => { expect(axios.get.calls.count()).toBe(1); }); }); + + describe('a URL inside the blob content', () => { + beforeEach(() => { + mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, { + html: + '<div class="js-blob-content"><pre class="code"><code><span class="line" lang="yaml"><span class="c1">To install gitlab-shell you also need a Go compiler version 1.8 or newer. https://golang.org/dl/</span></span></code></pre></div>', + }); + }); + + it('is rendered as a link in simple view', done => { + asyncClick() + .then(() => { + expect(document.querySelector('.blob-viewer[data-type="simple"]').innerHTML).toContain( + '<a href="https://golang.org/dl/">https://golang.org/dl/</a>', + ); + done(); + }) + .catch(() => { + fail(); + done(); + }); + }); + }); }); |