Commit 3eba988c authored by Coung Ngo's avatar Coung Ngo Committed by Kushal Pandya

Improve related merge requests markup

parent 55f670f9
...@@ -64,58 +64,51 @@ export default { ...@@ -64,58 +64,51 @@ export default {
</script> </script>
<template> <template>
<div <div v-if="isFetchingMergeRequests || (!isFetchingMergeRequests && totalCount)">
v-if="isFetchingMergeRequests || (!isFetchingMergeRequests && totalCount)" <div class="card card-slim gl-mt-5">
id="related-merge-requests"
>
<div id="merge-requests" class="card card-slim mt-3">
<div class="card-header"> <div class="card-header">
<div class="card-title mt-0 mb-0 h5 merge-requests-title position-relative"> <div
class="card-title gl-relative gl-display-flex gl-align-items-center gl-line-height-20 gl-font-weight-bold gl-m-0"
>
<gl-link <gl-link
id="user-content-related-merge-requests" class="anchor gl-absolute gl-text-decoration-none"
class="anchor position-absolute text-decoration-none"
href="#related-merge-requests" href="#related-merge-requests"
aria-hidden="true" aria-labelledby="related-merge-requests"
/> />
<span class="mr-1"> <h3 id="related-merge-requests" class="gl-font-base gl-m-0">
{{ __('Related merge requests') }} {{ __('Related merge requests') }}
</span> </h3>
<div v-if="totalCount" class="d-inline-flex lh-100 align-middle"> <template v-if="totalCount">
<div <gl-icon name="merge-request" class="gl-ml-5 gl-mr-2 gl-text-gray-500" />
class="mr-count-badge gl-display-inline-flex gl-align-items-center gl-py-2 gl-px-3" <span data-testid="count">{{ totalCount }}</span>
> </template>
<svg class="s16 mr-1 text-secondary">
<gl-icon name="merge-request" class="mr-1 text-secondary" />
</svg>
<span class="js-items-count">{{ totalCount }}</span>
</div>
</div>
</div> </div>
</div> </div>
<div> <gl-loading-icon
<div v-if="isFetchingMergeRequests" class="qa-related-merge-requests-loading-icon"> v-if="isFetchingMergeRequests"
<gl-loading-icon size="sm" label="Fetching related merge requests" class="py-2" /> size="sm"
</div> label="Fetching related merge requests"
<ul v-else class="content-list related-items-list"> class="gl-py-3"
<li v-for="mr in mergeRequests" :key="mr.id" class="list-item pt-0 pb-0"> />
<related-issuable-item <ul v-else class="content-list related-items-list">
:id-key="mr.id" <li v-for="mr in mergeRequests" :key="mr.id" class="list-item gl-m-0! gl-p-0!">
:display-reference="mr.reference" <related-issuable-item
:title="mr.title" :id-key="mr.id"
:milestone="mr.milestone" :display-reference="mr.reference"
:assignees="getAssignees(mr)" :title="mr.title"
:created-at="mr.created_at" :milestone="mr.milestone"
:closed-at="mr.closed_at" :assignees="getAssignees(mr)"
:merged-at="mr.merged_at" :created-at="mr.created_at"
:path="mr.web_url" :closed-at="mr.closed_at"
:state="mr.state" :merged-at="mr.merged_at"
:is-merge-request="true" :path="mr.web_url"
:pipeline-status="mr.head_pipeline && mr.head_pipeline.detailed_status" :state="mr.state"
path-id-separator="!" :is-merge-request="true"
/> :pipeline-status="mr.head_pipeline && mr.head_pipeline.detailed_status"
</li> path-id-separator="!"
</ul> />
</div> </li>
</ul>
</div> </div>
<div <div
v-if="hasClosingMergeRequest && !isFetchingMergeRequests" v-if="hasClosingMergeRequest && !isFetchingMergeRequests"
......
...@@ -53,9 +53,7 @@ RSpec.describe "Internal references", :js do ...@@ -53,9 +53,7 @@ RSpec.describe "Internal references", :js do
end end
it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
page.within(".issue-details") do expect(page).not_to have_text 'Related merge requests'
expect(page).not_to have_content("#merge-requests .merge-requests-title")
end
end end
end end
...@@ -65,12 +63,9 @@ RSpec.describe "Internal references", :js do ...@@ -65,12 +63,9 @@ RSpec.describe "Internal references", :js do
end end
it "shows references", :sidekiq_might_not_need_inline do it "shows references", :sidekiq_might_not_need_inline do
page.within("#merge-requests .merge-requests-title") do expect(page).to have_text 'Related merge requests 1'
expect(page).to have_content("Related merge requests")
expect(page).to have_css(".mr-count-badge")
end
page.within("#merge-requests ul") do page.within('.related-items-list') do
expect(page).to have_content(private_project_merge_request.title) expect(page).to have_content(private_project_merge_request.title)
expect(page).to have_css(".ic-issue-open-m") expect(page).to have_css(".ic-issue-open-m")
end end
...@@ -122,9 +117,7 @@ RSpec.describe "Internal references", :js do ...@@ -122,9 +117,7 @@ RSpec.describe "Internal references", :js do
end end
it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do it "doesn't show any references", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/257832' do
page.within(".merge-request-details") do expect(page).not_to have_text 'Related merge requests'
expect(page).not_to have_content("#merge-requests .merge-requests-title")
end
end end
end end
......
...@@ -66,8 +66,8 @@ describe('RelatedMergeRequests', () => { ...@@ -66,8 +66,8 @@ describe('RelatedMergeRequests', () => {
describe('template', () => { describe('template', () => {
it('should render related merge request items', () => { it('should render related merge request items', () => {
expect(wrapper.find('.js-items-count').text()).toEqual('2'); expect(wrapper.find('[data-testid="count"]').text()).toBe('2');
expect(wrapper.findAll(RelatedIssuableItem).length).toEqual(2); expect(wrapper.findAll(RelatedIssuableItem)).toHaveLength(2);
const props = wrapper.findAll(RelatedIssuableItem).at(1).props(); const props = wrapper.findAll(RelatedIssuableItem).at(1).props();
const data = mockData[1]; const data = mockData[1];
......
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