summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-02-16 16:02:40 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-02-23 15:47:23 -0600
commit103f5a116b1ae6ecbef69d6903b26f7259f090cb (patch)
tree0e3d762be03e421a0f07a96c8ad94dc333724f89 /spec
parent4802bd512a2492c7560acde077fee2f4cd9483b3 (diff)
downloadgitlab-ce-103f5a116b1ae6ecbef69d6903b26f7259f090cb.tar.gz
Created unit tests, fixtures and integration tests
Also changed the user_callout haml to a partial and added the corresponding SVG icon
Diffstat (limited to 'spec')
-rw-r--r--spec/features/user_callout_spec.rb37
-rw-r--r--spec/javascripts/fixtures/user_callout.html.haml12
-rw-r--r--spec/javascripts/user_callout_spec.js42
3 files changed, 91 insertions, 0 deletions
diff --git a/spec/features/user_callout_spec.rb b/spec/features/user_callout_spec.rb
new file mode 100644
index 00000000000..9ab22475b5e
--- /dev/null
+++ b/spec/features/user_callout_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe 'User Callouts', js: true do
+ let(:user) { create(:user) }
+ let(:project) { create(:empty_project, path: 'gitlab', name: 'sample') }
+
+ before do
+ login_as(user)
+ project.team << [user, :master]
+ end
+
+ it 'takes you to the profile preferences when the link is clicked' do
+ visit dashboard_projects_path
+ click_link 'Check it out'
+ expect(current_path).to eq profile_preferences_path
+ end
+
+ describe 'user callout should appear in two routes' do
+ it 'shows up on the user profile' do
+ visit user_path(user)
+ expect(find('#user-callout')).to have_content 'Customize your experience'
+ end
+
+ it 'shows up on the dashboard projects' do
+ visit dashboard_projects_path
+ expect(find('#user-callout')).to have_content 'Customize your experience'
+ end
+ end
+
+ it 'hides the user callout when click on the dismiss icon' do
+ visit user_path(user)
+ within('#user-callout') do
+ find('.dismiss-icon').click
+ end
+ expect(page).not_to have_selector('#user-callout')
+ end
+end \ No newline at end of file
diff --git a/spec/javascripts/fixtures/user_callout.html.haml b/spec/javascripts/fixtures/user_callout.html.haml
new file mode 100644
index 00000000000..2aa6bf4b604
--- /dev/null
+++ b/spec/javascripts/fixtures/user_callout.html.haml
@@ -0,0 +1,12 @@
+#user-callout
+ .bordered-box.landing.content-block
+ %i.fa.fa-times.dismiss-icon
+ .row
+ .col-sm-3.col-xs-12.svg-container
+ .col-sm-8.col-xs-12.inner-content
+ %h4
+ Customize your experience
+ %p
+ Change syntax themes, default project pages, and more in preferences.
+ %a{ href: 'foo', class:'user-callout-btn' }
+ Check it out \ No newline at end of file
diff --git a/spec/javascripts/user_callout_spec.js b/spec/javascripts/user_callout_spec.js
new file mode 100644
index 00000000000..26a12bed067
--- /dev/null
+++ b/spec/javascripts/user_callout_spec.js
@@ -0,0 +1,42 @@
+/* esint-disable space-before-function-paren, arrow-body-style */
+require('~/user_callout');
+
+((global) => {
+ const USER_CALLOUT_COOKIE = 'user_callout_dismissed';
+ const Cookie = window.Cookies;
+
+ describe('UserCallout', function () {
+ const fixtureName = 'static/user_callout.html.raw';
+ preloadFixtures(fixtureName);
+
+ it('should be defined in the global scope', () => {
+ expect(global.UserCallout).toBeDefined();
+ });
+
+ beforeEach(() => {
+ loadFixtures(fixtureName);
+ this.userCallout = new global.UserCallout();
+ this.dismissIcon = $('.dismiss-icon');
+ this.userCalloutContainer = $('#user-callout');
+ this.userCalloutBtn = $('.user-callout-btn');
+ Cookie.set(USER_CALLOUT_COOKIE, 0);
+ });
+
+ it('shows when cookie is set to false', () => {
+ expect(Cookie.get(USER_CALLOUT_COOKIE)).toBeDefined();
+ expect(this.userCalloutContainer.is(':visible')).toBe(true);
+ });
+
+ it('hides when user clicks on the dismiss-icon', () => {
+ this.dismissIcon.click();
+ expect(this.userCalloutContainer.is(':visible')).toBe(false);
+ expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('1');
+ });
+
+ it('hides when user clicks on the "check it out" button', () => {
+ this.userCalloutBtn.click();
+ expect(this.userCalloutContainer.is(':visible')).toBe(false);
+ expect(Cookie.get(USER_CALLOUT_COOKIE)).toBe('1');
+ });
+ });
+})(window.gl || (window.gl = {}));