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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-11 18:07:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-11 18:07:38 +0300
commit4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (patch)
tree2eff1ce7ac4a58de15b1f5980acfdb22c7b92ac0 /spec/frontend
parentb86f474bf51e20d2db4cf0895d0a8e0894e31c08 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/error_tracking/store/list/mutation_spec.js2
-rw-r--r--spec/frontend/fixtures/snippet.rb2
-rw-r--r--spec/frontend/ide/components/panes/right_spec.js2
-rw-r--r--spec/frontend/snippets_spec.js70
-rw-r--r--spec/frontend/test_setup.js3
5 files changed, 76 insertions, 3 deletions
diff --git a/spec/frontend/error_tracking/store/list/mutation_spec.js b/spec/frontend/error_tracking/store/list/mutation_spec.js
index 5e6505e13cd..44a75b6aa1f 100644
--- a/spec/frontend/error_tracking/store/list/mutation_spec.js
+++ b/spec/frontend/error_tracking/store/list/mutation_spec.js
@@ -1,6 +1,6 @@
+import { useLocalStorageSpy } from 'helpers/local_storage_helper';
import mutations from '~/error_tracking/store/list/mutations';
import * as types from '~/error_tracking/store/list/mutation_types';
-import { useLocalStorageSpy } from 'helpers/local_storage_helper';
const ADD_RECENT_SEARCH = mutations[types.ADD_RECENT_SEARCH];
const CLEAR_RECENT_SEARCHES = mutations[types.CLEAR_RECENT_SEARCHES];
diff --git a/spec/frontend/fixtures/snippet.rb b/spec/frontend/fixtures/snippet.rb
index 33dfebac3e7..e91050cd2c5 100644
--- a/spec/frontend/fixtures/snippet.rb
+++ b/spec/frontend/fixtures/snippet.rb
@@ -8,7 +8,7 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
- let(:snippet) { create(:personal_snippet, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) }
+ let(:snippet) { create(:personal_snippet, :public, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) }
render_views
diff --git a/spec/frontend/ide/components/panes/right_spec.js b/spec/frontend/ide/components/panes/right_spec.js
index 6f7228add4e..6908790aaa8 100644
--- a/spec/frontend/ide/components/panes/right_spec.js
+++ b/spec/frontend/ide/components/panes/right_spec.js
@@ -1,9 +1,9 @@
import Vue from 'vue';
import '~/behaviors/markdown/render_gfm';
+import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
import { createStore } from '~/ide/stores';
import RightPane from '~/ide/components/panes/right.vue';
import { rightSidebarViews } from '~/ide/constants';
-import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
describe('IDE right pane', () => {
let Component;
diff --git a/spec/frontend/snippets_spec.js b/spec/frontend/snippets_spec.js
new file mode 100644
index 00000000000..5b391606371
--- /dev/null
+++ b/spec/frontend/snippets_spec.js
@@ -0,0 +1,70 @@
+import snippetEmbed from '~/snippet/snippet_embed';
+import { loadHTMLFixture } from './helpers/fixtures';
+
+describe('Snippets', () => {
+ let embedBtn;
+ let snippetUrlArea;
+ let shareBtn;
+ let scriptTag;
+
+ const snippetUrl = 'http://test.host/snippets/1';
+
+ beforeEach(() => {
+ loadHTMLFixture('snippets/show.html');
+
+ embedBtn = document.querySelector('.js-embed-btn');
+ snippetUrlArea = document.querySelector('.js-snippet-url-area');
+ shareBtn = document.querySelector('.js-share-btn');
+ });
+
+ it('selects the fields content when it is clicked', () => {
+ jest.spyOn(snippetUrlArea, 'select');
+ snippetEmbed();
+
+ expect(snippetUrlArea.select).not.toHaveBeenCalled();
+ snippetUrlArea.dispatchEvent(new Event('click'));
+ expect(snippetUrlArea.select).toHaveBeenCalled();
+ });
+
+ describe('when the snippet url does not include params', () => {
+ beforeEach(() => {
+ snippetEmbed();
+
+ scriptTag = `<script src="${snippetUrl}.js"></script>`;
+ });
+
+ it('shows the script tag as default', () => {
+ expect(snippetUrlArea.value).toEqual(scriptTag);
+ });
+
+ it('sets the proper url depending on the button clicked', () => {
+ shareBtn.dispatchEvent(new Event('click'));
+ expect(snippetUrlArea.value).toEqual(snippetUrl);
+
+ embedBtn.dispatchEvent(new Event('click'));
+ expect(snippetUrlArea.value).toEqual(scriptTag);
+ });
+ });
+
+ describe('when the snippet url includes params', () => {
+ beforeEach(() => {
+ scriptTag = `<script src="${snippetUrl}.js?foo=bar"></script>`;
+ snippetUrlArea.value = scriptTag;
+ snippetUrlArea.dataset.url = `${snippetUrl}?foo=bar`;
+
+ snippetEmbed();
+ });
+
+ it('shows the script tag as default', () => {
+ expect(snippetUrlArea.value).toEqual(scriptTag);
+ });
+
+ it('sets the proper url depending on the button clicked', () => {
+ shareBtn.dispatchEvent(new Event('click'));
+ expect(snippetUrlArea.value).toEqual(`${snippetUrl}?foo=bar`);
+
+ embedBtn.dispatchEvent(new Event('click'));
+ expect(snippetUrlArea.value).toEqual(scriptTag);
+ });
+ });
+});
diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js
index b39b7375d80..4636de6b8b6 100644
--- a/spec/frontend/test_setup.js
+++ b/spec/frontend/test_setup.js
@@ -40,6 +40,9 @@ Object.defineProperty(global.Element.prototype, 'innerText', {
get() {
return this.textContent;
},
+ set(value) {
+ this.textContext = value;
+ },
configurable: true, // make it so that it doesn't blow chunks on re-running tests with things like --watch
});