Commit 5dcaeeee authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '294174-request-title-from-backend-in-mr-popover' into 'master'

Request title from backend in MR popovers

See merge request gitlab-org/gitlab!75012
parents 6e8ae813 6585c88d
...@@ -65,6 +65,9 @@ export default { ...@@ -65,6 +65,9 @@ export default {
return humanMRStates.open; return humanMRStates.open;
} }
}, },
title() {
return this.mergeRequest?.title || this.mergeRequestTitle;
},
showDetails() { showDetails() {
return Object.keys(this.mergeRequest).length > 0; return Object.keys(this.mergeRequest).length > 0;
}, },
...@@ -89,7 +92,7 @@ export default { ...@@ -89,7 +92,7 @@ export default {
<template> <template>
<gl-popover :target="target" boundary="viewport" placement="top" show> <gl-popover :target="target" boundary="viewport" placement="top" show>
<div class="mr-popover"> <div class="mr-popover">
<div v-if="$apollo.loading"> <div v-if="$apollo.queries.mergeRequest.loading">
<gl-skeleton-loading :lines="1" class="animation-container-small mt-1" /> <gl-skeleton-loading :lines="1" class="animation-container-small mt-1" />
</div> </div>
<div v-else-if="showDetails" class="d-flex align-items-center justify-content-between"> <div v-else-if="showDetails" class="d-flex align-items-center justify-content-between">
...@@ -101,7 +104,7 @@ export default { ...@@ -101,7 +104,7 @@ export default {
</div> </div>
<ci-icon v-if="detailedStatus" :status="detailedStatus" /> <ci-icon v-if="detailedStatus" :status="detailedStatus" />
</div> </div>
<h5 class="my-2">{{ mergeRequestTitle }}</h5> <h5 v-if="!$apollo.queries.mergeRequest.loading" class="my-2">{{ title }}</h5>
<!-- eslint-disable @gitlab/vue-require-i18n-strings --> <!-- eslint-disable @gitlab/vue-require-i18n-strings -->
<div class="text-secondary"> <div class="text-secondary">
{{ `${projectPath}!${mergeRequestIID}` }} {{ `${projectPath}!${mergeRequestIID}` }}
......
query mergeRequest($projectPath: ID!, $mergeRequestIID: String!) { query mergeRequest($projectPath: ID!, $mergeRequestIID: String!) {
project(fullPath: $projectPath) { project(fullPath: $projectPath) {
mergeRequest(iid: $mergeRequestIID) { mergeRequest(iid: $mergeRequestIID) {
title
createdAt createdAt
state state
headPipeline { headPipeline {
......
...@@ -45,7 +45,7 @@ exports[`MR Popover loaded state matches the snapshot 1`] = ` ...@@ -45,7 +45,7 @@ exports[`MR Popover loaded state matches the snapshot 1`] = `
<h5 <h5
class="my-2" class="my-2"
> >
MR Title Updated Title
</h5> </h5>
<div <div
...@@ -77,11 +77,7 @@ exports[`MR Popover shows skeleton-loader while apollo is loading 1`] = ` ...@@ -77,11 +77,7 @@ exports[`MR Popover shows skeleton-loader while apollo is loading 1`] = `
/> />
</div> </div>
<h5 <!---->
class="my-2"
>
MR Title
</h5>
<div <div
class="text-secondary" class="text-secondary"
......
...@@ -15,14 +15,18 @@ describe('MR Popover', () => { ...@@ -15,14 +15,18 @@ describe('MR Popover', () => {
}, },
mocks: { mocks: {
$apollo: { $apollo: {
loading: false, queries: {
mergeRequest: {
loading: false,
},
},
}, },
}, },
}); });
}); });
it('shows skeleton-loader while apollo is loading', () => { it('shows skeleton-loader while apollo is loading', () => {
wrapper.vm.$apollo.loading = true; wrapper.vm.$apollo.queries.mergeRequest.loading = true;
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(wrapper.element).toMatchSnapshot(); expect(wrapper.element).toMatchSnapshot();
...@@ -33,6 +37,7 @@ describe('MR Popover', () => { ...@@ -33,6 +37,7 @@ describe('MR Popover', () => {
it('matches the snapshot', () => { it('matches the snapshot', () => {
wrapper.setData({ wrapper.setData({
mergeRequest: { mergeRequest: {
title: 'Updated Title',
state: 'opened', state: 'opened',
createdAt: new Date(), createdAt: new Date(),
headPipeline: { headPipeline: {
...@@ -64,5 +69,11 @@ describe('MR Popover', () => { ...@@ -64,5 +69,11 @@ describe('MR Popover', () => {
expect(wrapper.find(CiIcon).exists()).toBe(false); expect(wrapper.find(CiIcon).exists()).toBe(false);
}); });
}); });
it('falls back to cached MR title when request fails', () => {
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.text()).toContain('MR Title');
});
});
}); });
}); });
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