Commit 4d48658b authored by Phil Hughes's avatar Phil Hughes

added specs

long branch names no longer wrap
parent 16c2e2f5
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
</div> </div>
<div class="prepend-top-5 ide-review-sub-header"> <div class="prepend-top-5 ide-review-sub-header">
<template v-if="!currentMergeRequest || viewer === 'diff'"> <template v-if="!currentMergeRequest || viewer === 'diff'">
{{ __('Lastest changes') }} {{ __('Latest changes') }}
</template> </template>
<template v-else-if="currentMergeRequest && viewer === 'mrdiff'"> <template v-else-if="currentMergeRequest && viewer === 'mrdiff'">
Merge request Merge request
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import ProjectAvatarImage from '~/vue_shared/components/project_avatar/image.vue'; import ProjectAvatarImage from '~/vue_shared/components/project_avatar/image.vue';
import Icon from '~/vue_shared/components/icon.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 PanelResizer from '~/vue_shared/components/panel_resizer.vue';
import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue'; import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_container.vue';
import Identicon from '../../vue_shared/components/identicon.vue'; import Identicon from '../../vue_shared/components/identicon.vue';
...@@ -12,6 +13,9 @@ import CommitSection from './repo_commit_section.vue'; ...@@ -12,6 +13,9 @@ import CommitSection from './repo_commit_section.vue';
import IdeReview from './ide_review.vue'; import IdeReview from './ide_review.vue';
export default { export default {
directives: {
tooltip,
},
components: { components: {
Icon, Icon,
PanelResizer, PanelResizer,
...@@ -24,9 +28,24 @@ export default { ...@@ -24,9 +28,24 @@ export default {
IdeTree, IdeTree,
IdeReview, IdeReview,
}, },
data() {
return {
showTooltip: false,
};
},
computed: { computed: {
...mapState(['loading', 'currentBranchId', 'currentActivityView']), ...mapState(['loading', 'currentBranchId', 'currentActivityView']),
...mapGetters(['currentProject']), ...mapGetters(['currentProject']),
branchTooltipTitle() {
return this.showTooltip ? this.currentBranchId : undefined;
},
},
watch: {
currentBranchId() {
this.$nextTick(() => {
this.showTooltip = this.$refs.branchId.scrollWidth > this.$refs.branchId.offsetWidth;
});
},
}, },
}; };
</script> </script>
...@@ -79,6 +98,9 @@ export default { ...@@ -79,6 +98,9 @@ export default {
</div> </div>
<div <div
class="sidebar-context-title ide-sidebar-branch-title" class="sidebar-context-title ide-sidebar-branch-title"
ref="branchId"
v-tooltip
:title="branchTooltipTitle"
> >
<icon <icon
name="branch" name="branch"
......
...@@ -995,3 +995,17 @@ ...@@ -995,3 +995,17 @@
width: 100%; width: 100%;
align-items: center; align-items: center;
} }
.ide-context-header {
.avatar {
flex: 0 0 40px;
}
}
.ide-sidebar-project-title {
min-width: 0;
.sidebar-context-title {
white-space: nowrap;
}
}
...@@ -2,6 +2,7 @@ import Vue from 'vue'; ...@@ -2,6 +2,7 @@ import Vue from 'vue';
import IdeReview from '~/ide/components/ide_review.vue'; import IdeReview from '~/ide/components/ide_review.vue';
import store from '~/ide/stores'; import store from '~/ide/stores';
import { createComponentWithStore } from '../../helpers/vue_mount_component_helper'; import { createComponentWithStore } from '../../helpers/vue_mount_component_helper';
import { trimText } from '../../helpers/vue_component_helper';
import { resetStore, file } from '../helpers'; import { resetStore, file } from '../helpers';
import { projectData } from '../mock_data'; import { projectData } from '../mock_data';
...@@ -30,4 +31,39 @@ describe('IDE review mode', () => { ...@@ -30,4 +31,39 @@ describe('IDE review mode', () => {
it('renders list of files', () => { it('renders list of files', () => {
expect(vm.$el.textContent).toContain('fileName'); 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();
});
});
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment