summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-10-03 00:33:13 -0500
committerEric Eastwood <contact@ericeastwood.com>2017-10-03 00:33:13 -0500
commitbca86c858b361f3b5a19abcfc03972c95f4b2d2a (patch)
treecfd16b3301384e9c65492d55c7cecb566308ef05
parentb4d95002af504488af5c5c2117175ec73192c942 (diff)
downloadgitlab-ce-bca86c858b361f3b5a19abcfc03972c95f4b2d2a.tar.gz
Add test for external HTML artifact
-rw-r--r--app/assets/javascripts/lib/utils/url_utility.js2
-rw-r--r--app/views/projects/artifacts/_tree_file.html.haml2
-rw-r--r--doc/user/project/pipelines/img/job_artifacts_browser.pngbin3944 -> 0 bytes
-rw-r--r--spec/features/projects/artifacts/browse_spec.rb28
4 files changed, 26 insertions, 6 deletions
diff --git a/app/assets/javascripts/lib/utils/url_utility.js b/app/assets/javascripts/lib/utils/url_utility.js
index 6512f7c8a94..78c7a094127 100644
--- a/app/assets/javascripts/lib/utils/url_utility.js
+++ b/app/assets/javascripts/lib/utils/url_utility.js
@@ -90,7 +90,7 @@ w.gl.utils.refreshCurrentPage = () => gl.utils.visitUrl(document.location.href);
// eslint-disable-next-line import/prefer-default-export
export function visitUrl(url, external = false) {
if (external) {
- // Simulate `target="blank" ref="noopener noreferrer"`
+ // Simulate `target="blank" rel="noopener noreferrer"`
// See https://mathiasbynens.github.io/rel-noopener/
const otherWindow = window.open();
otherWindow.opener = null;
diff --git a/app/views/projects/artifacts/_tree_file.html.haml b/app/views/projects/artifacts/_tree_file.html.haml
index 78df1dab9d6..10e238b6ba1 100644
--- a/app/views/projects/artifacts/_tree_file.html.haml
+++ b/app/views/projects/artifacts/_tree_file.html.haml
@@ -12,6 +12,6 @@
title: ('Opens in a new window' if is_external_link) do
%span.str-truncated>= blob.name
- if is_external_link
- = icon('external-link')
+ = icon('external-link', class: 'js-artifact-tree-external-icon')
%td
= number_to_human_size(blob.size, precision: 2)
diff --git a/doc/user/project/pipelines/img/job_artifacts_browser.png b/doc/user/project/pipelines/img/job_artifacts_browser.png
deleted file mode 100644
index d3d8de5ac60..00000000000
--- a/doc/user/project/pipelines/img/job_artifacts_browser.png
+++ /dev/null
Binary files differ
diff --git a/spec/features/projects/artifacts/browse_spec.rb b/spec/features/projects/artifacts/browse_spec.rb
index 42b47cb3301..40af0247bce 100644
--- a/spec/features/projects/artifacts/browse_spec.rb
+++ b/spec/features/projects/artifacts/browse_spec.rb
@@ -1,19 +1,20 @@
require 'spec_helper'
feature 'Browse artifact', :js do
+ include ArtifactHelper
+
let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
+ let(:browse_url) do
+ browse_path('other_artifacts_0.1.2')
+ end
def browse_path(path)
browse_project_job_artifacts_path(project, job, path)
end
context 'when visiting old URL' do
- let(:browse_url) do
- browse_path('other_artifacts_0.1.2')
- end
-
before do
visit browse_url.sub('/-/jobs', '/builds')
end
@@ -22,4 +23,23 @@ feature 'Browse artifact', :js do
expect(page.current_path).to eq(browse_url)
end
end
+
+ context 'when browsing a directory with an HTML file' do
+ let(:html_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/index.html") }
+
+ before do
+ allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
+ allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
+
+ visit browse_url
+ end
+
+ it "shows external link icon and styles" do
+ link = first('.tree-item-file-external-link')
+
+ expect(link).to have_content('index.html')
+ expect(link[:href]).to eq(html_artifact_url(project, job, html_entry.blob))
+ expect(page).to have_selector('.js-artifact-tree-external-icon')
+ end
+ end
end