Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-03 18:10:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-03 18:10:01 +0300
commit4f41b713eb264096903c168375815adec96ab8ac (patch)
tree48f4ccefb4e6521c02c4101e84db65025efacfbe /spec
parentf5987db869d7025fb8f403edc5106c5f2a3e448f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/repository/components/blob_content_viewer_spec.js18
-rw-r--r--spec/frontend/repository/components/blob_header_edit_spec.js63
-rw-r--r--spec/helpers/gitlab_script_tag_helper_spec.rb7
-rw-r--r--spec/helpers/webpack_helper_spec.rb3
-rw-r--r--spec/lib/gitlab/content_security_policy/config_loader_spec.rb1
5 files changed, 88 insertions, 4 deletions
diff --git a/spec/frontend/repository/components/blob_content_viewer_spec.js b/spec/frontend/repository/components/blob_content_viewer_spec.js
index f03df8cf2ac..ea554db6909 100644
--- a/spec/frontend/repository/components/blob_content_viewer_spec.js
+++ b/spec/frontend/repository/components/blob_content_viewer_spec.js
@@ -162,15 +162,22 @@ describe('Blob content viewer component', () => {
});
describe('BlobHeader action slot', () => {
- it('renders BlobHeaderEdit button in simple viewer', async () => {
+ const { ideEditPath, editBlobPath } = simpleMockData;
+
+ it('renders BlobHeaderEdit buttons in simple viewer', async () => {
fullFactory({
mockData: { blobInfo: simpleMockData },
stubs: {
BlobContent: true,
},
});
+
await nextTick();
- expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit');
+
+ expect(findBlobHeaderEdit().props()).toMatchObject({
+ editPath: editBlobPath,
+ webIdePath: ideEditPath,
+ });
});
it('renders BlobHeaderEdit button in rich viewer', async () => {
@@ -180,8 +187,13 @@ describe('Blob content viewer component', () => {
BlobContent: true,
},
});
+
await nextTick();
- expect(findBlobHeaderEdit().props('editPath')).toEqual('some_file.js/edit');
+
+ expect(findBlobHeaderEdit().props()).toMatchObject({
+ editPath: editBlobPath,
+ webIdePath: ideEditPath,
+ });
});
});
});
diff --git a/spec/frontend/repository/components/blob_header_edit_spec.js b/spec/frontend/repository/components/blob_header_edit_spec.js
new file mode 100644
index 00000000000..bd02bbe65d9
--- /dev/null
+++ b/spec/frontend/repository/components/blob_header_edit_spec.js
@@ -0,0 +1,63 @@
+import { GlButton } from '@gitlab/ui';
+import { shallowMount } from '@vue/test-utils';
+import BlobHeaderEdit from '~/repository/components/blob_header_edit.vue';
+
+const DEFAULT_PROPS = {
+ editPath: 'some_file.js/edit',
+ webIdePath: 'some_file.js/ide/edit',
+};
+
+describe('BlobHeaderEdit component', () => {
+ let wrapper;
+
+ const createComponent = (props = {}) => {
+ wrapper = shallowMount(BlobHeaderEdit, {
+ propsData: {
+ ...DEFAULT_PROPS,
+ ...props,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ const findButtons = () => wrapper.findAll(GlButton);
+ const findEditButton = () => findButtons().at(0);
+ const findWebIdeButton = () => findButtons().at(1);
+
+ it('renders component', () => {
+ createComponent();
+
+ const { editPath, webIdePath } = DEFAULT_PROPS;
+
+ expect(wrapper.props()).toMatchObject({
+ editPath,
+ webIdePath,
+ });
+ });
+
+ it('renders both buttons', () => {
+ createComponent();
+
+ expect(findButtons()).toHaveLength(2);
+ });
+
+ it('renders the Edit button', () => {
+ createComponent();
+
+ expect(findEditButton().attributes('href')).toBe(DEFAULT_PROPS.editPath);
+ expect(findEditButton().text()).toBe('Edit');
+ expect(findEditButton()).not.toBeDisabled();
+ });
+
+ it('renders the Web IDE button', () => {
+ createComponent();
+
+ expect(findWebIdeButton().attributes('href')).toBe(DEFAULT_PROPS.webIdePath);
+ expect(findWebIdeButton().text()).toBe('Web IDE');
+ expect(findWebIdeButton()).not.toBeDisabled();
+ });
+});
diff --git a/spec/helpers/gitlab_script_tag_helper_spec.rb b/spec/helpers/gitlab_script_tag_helper_spec.rb
index 37413b9b1c2..35f2c0795be 100644
--- a/spec/helpers/gitlab_script_tag_helper_spec.rb
+++ b/spec/helpers/gitlab_script_tag_helper_spec.rb
@@ -41,4 +41,11 @@ RSpec.describe GitlabScriptTagHelper do
expect(helper.javascript_tag( '// ignored', type: 'application/javascript') { 'alert(1)' }.to_s).to eq tag_with_nonce_and_type
end
end
+
+ describe '#preload_link_tag' do
+ it 'returns a link tag with a nonce' do
+ expect(helper.preload_link_tag('https://example.com/script.js').to_s)
+ .to eq "<link rel=\"preload\" href=\"https://example.com/script.js\" as=\"script\" type=\"text/javascript\" nonce=\"noncevalue\">"
+ end
+ end
end
diff --git a/spec/helpers/webpack_helper_spec.rb b/spec/helpers/webpack_helper_spec.rb
index f9386c99dc3..f9e2d265153 100644
--- a/spec/helpers/webpack_helper_spec.rb
+++ b/spec/helpers/webpack_helper_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe WebpackHelper do
describe '#webpack_preload_asset_tag' do
before do
allow(Gitlab::Webpack::Manifest).to receive(:asset_paths).and_return([asset_path])
+ allow(helper).to receive(:content_security_policy_nonce).and_return('noncevalue')
end
it 'preloads the resource by default' do
@@ -22,7 +23,7 @@ RSpec.describe WebpackHelper do
output = helper.webpack_preload_asset_tag(source)
- expect(output).to eq("<link rel=\"preload\" href=\"#{asset_path}\" as=\"script\" type=\"text/javascript\">")
+ expect(output).to eq("<link rel=\"preload\" href=\"#{asset_path}\" as=\"script\" type=\"text/javascript\" nonce=\"noncevalue\">")
end
it 'prefetches the resource if explicitly asked' do
diff --git a/spec/lib/gitlab/content_security_policy/config_loader_spec.rb b/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
index 19e52d2cf4a..d08057fb10a 100644
--- a/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
+++ b/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
@@ -58,6 +58,7 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
expect(directives['script_src']).to eq("'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/ https://www.recaptcha.net https://apis.google.com https://example.com")
expect(directives['style_src']).to eq("'self' 'unsafe-inline' https://example.com")
+ expect(directives['font_src']).to eq("'self' https://example.com")
end
end
end