diff options
author | Phil Hughes <me@iamphill.com> | 2018-05-04 13:40:13 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-05-04 13:40:13 +0300 |
commit | 4d48658bcce6129f266f426036e58967a46ed8c1 (patch) | |
tree | 561c63ff605cba6a68a386a6e6d83111419c020b | |
parent | 16c2e2f56bf533088988b8595ec89a9fdfc4292d (diff) |
added specs
long branch names no longer wrap
-rw-r--r-- | app/assets/javascripts/ide/components/ide_review.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/ide_side_bar.vue | 22 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/repo.scss | 14 | ||||
-rw-r--r-- | spec/javascripts/ide/components/ide_review_spec.js | 36 |
4 files changed, 73 insertions, 1 deletions
diff --git a/app/assets/javascripts/ide/components/ide_review.vue b/app/assets/javascripts/ide/components/ide_review.vue index fb0747439c4..cf8a4f4d0e6 100644 --- a/app/assets/javascripts/ide/components/ide_review.vue +++ b/app/assets/javascripts/ide/components/ide_review.vue @@ -43,7 +43,7 @@ export default { </div> <div class="prepend-top-5 ide-review-sub-header"> <template v-if="!currentMergeRequest || viewer === 'diff'"> - {{ __('Lastest changes') }} + {{ __('Latest changes') }} </template> <template v-else-if="currentMergeRequest && viewer === 'mrdiff'"> Merge request diff --git a/app/assets/javascripts/ide/components/ide_side_bar.vue b/app/assets/javascripts/ide/components/ide_side_bar.vue index 3fb9b8b241d..2872d4e8687 100644 --- a/app/assets/javascripts/ide/components/ide_side_bar.vue +++ b/app/assets/javascripts/ide/components/ide_side_bar.vue @@ -2,6 +2,7 @@ import { mapState, mapGetters } from 'vuex'; import ProjectAvatarImage from '~/vue_shared/components/project_avatar/image.vue'; import Icon from '~/vue_shared/components/icon.vue'; +import tooltip from '~/vue_shared/directives/tooltip'; import PanelResizer from '~/vue_shared/components/panel_resizer.vue'; import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; import Identicon from '../../vue_shared/components/identicon.vue'; @@ -12,6 +13,9 @@ import CommitSection from './repo_commit_section.vue'; import IdeReview from './ide_review.vue'; export default { + directives: { + tooltip, + }, components: { Icon, PanelResizer, @@ -24,9 +28,24 @@ export default { IdeTree, IdeReview, }, + data() { + return { + showTooltip: false, + }; + }, computed: { ...mapState(['loading', 'currentBranchId', 'currentActivityView']), ...mapGetters(['currentProject']), + branchTooltipTitle() { + return this.showTooltip ? this.currentBranchId : undefined; + }, + }, + watch: { + currentBranchId() { + this.$nextTick(() => { + this.showTooltip = this.$refs.branchId.scrollWidth > this.$refs.branchId.offsetWidth; + }); + }, }, }; </script> @@ -79,6 +98,9 @@ export default { </div> <div class="sidebar-context-title ide-sidebar-branch-title" + ref="branchId" + v-tooltip + :title="branchTooltipTitle" > <icon name="branch" diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index 6fa2b7c709b..6c60c61cea1 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -995,3 +995,17 @@ width: 100%; align-items: center; } + +.ide-context-header { + .avatar { + flex: 0 0 40px; + } +} + +.ide-sidebar-project-title { + min-width: 0; + + .sidebar-context-title { + white-space: nowrap; + } +} diff --git a/spec/javascripts/ide/components/ide_review_spec.js b/spec/javascripts/ide/components/ide_review_spec.js index 13753c6b6fb..b9ee22b7c1a 100644 --- a/spec/javascripts/ide/components/ide_review_spec.js +++ b/spec/javascripts/ide/components/ide_review_spec.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import IdeReview from '~/ide/components/ide_review.vue'; import store from '~/ide/stores'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; +import { trimText } from '../../helpers/vue_component_helper'; import { resetStore, file } from '../helpers'; import { projectData } from '../mock_data'; @@ -30,4 +31,39 @@ describe('IDE review mode', () => { it('renders list of files', () => { expect(vm.$el.textContent).toContain('fileName'); }); + + describe('merge request', () => { + beforeEach(done => { + store.state.currentMergeRequestId = '1'; + store.state.projects.abcproject.mergeRequests['1'] = { + iid: 123, + web_url: 'testing123', + }; + + vm.$nextTick(done); + }); + + it('renders edit dropdown', () => { + expect(vm.$el.querySelector('.btn')).not.toBe(null); + }); + + it('renders merge request link & IID', () => { + const link = vm.$el.querySelector('.ide-review-sub-header'); + + expect(link.querySelector('a').getAttribute('href')).toBe('testing123'); + expect(trimText(link.textContent)).toBe('Merge request (!123)'); + }); + + it('changes text to latest changes when viewer is not mrdiff', done => { + store.state.viewer = 'diff'; + + vm.$nextTick(() => { + expect(trimText(vm.$el.querySelector('.ide-review-sub-header').textContent)).toBe( + 'Latest changes', + ); + + done(); + }); + }); + }); }); |