Commit e396187e authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '341816-improve-markup' into 'master'

Improve related merge requests markup

See merge request gitlab-org/gitlab!72617
parents d7c11807 3eba988c
...@@ -64,40 +64,34 @@ export default { ...@@ -64,40 +64,34 @@ export default {
</script> </script>
<template> <template>
<div v-if="isFetchingMergeRequests || (!isFetchingMergeRequests && totalCount)">
<div class="card card-slim gl-mt-5">
<div class="card-header">
<div <div
v-if="isFetchingMergeRequests || (!isFetchingMergeRequests && totalCount)" class="card-title gl-relative gl-display-flex gl-align-items-center gl-line-height-20 gl-font-weight-bold gl-m-0"
id="related-merge-requests"
> >
<div id="merge-requests" class="card card-slim mt-3">
<div class="card-header">
<div class="card-title mt-0 mb-0 h5 merge-requests-title position-relative">
<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> <gl-loading-icon
<div> v-if="isFetchingMergeRequests"
<div v-if="isFetchingMergeRequests" class="qa-related-merge-requests-loading-icon"> size="sm"
<gl-loading-icon size="sm" label="Fetching related merge requests" class="py-2" /> label="Fetching related merge requests"
</div> class="gl-py-3"
/>
<ul v-else class="content-list related-items-list"> <ul v-else class="content-list related-items-list">
<li v-for="mr in mergeRequests" :key="mr.id" class="list-item pt-0 pb-0"> <li v-for="mr in mergeRequests" :key="mr.id" class="list-item gl-m-0! gl-p-0!">
<related-issuable-item <related-issuable-item
:id-key="mr.id" :id-key="mr.id"
:display-reference="mr.reference" :display-reference="mr.reference"
...@@ -116,7 +110,6 @@ export default { ...@@ -116,7 +110,6 @@ export default {
</li> </li>
</ul> </ul>
</div> </div>
</div>
<div <div
v-if="hasClosingMergeRequest && !isFetchingMergeRequests" v-if="hasClosingMergeRequest && !isFetchingMergeRequests"
class="issue-closed-by-widget second-block" class="issue-closed-by-widget second-block"
......
...@@ -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