Commit 37e08863 authored by Sam Beckham's avatar Sam Beckham Committed by Savas Vedova

Adds changes from @svedova review

- Uses the `findByTestId` helper to target the expand button
parent 35bd91b7
<script> <script>
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import StatusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue'; import StatusIcon from '~/vue_merge_request_widget/components/mr_widget_status_icon.vue';
import Popover from '~/vue_shared/components/help_popover.vue'; import Popover from '~/vue_shared/components/help_popover.vue';
...@@ -8,9 +9,10 @@ import IssuesList from './issues_list.vue'; ...@@ -8,9 +9,10 @@ import IssuesList from './issues_list.vue';
export default { export default {
name: 'ReportSection', name: 'ReportSection',
components: { components: {
GlButton,
IssuesList, IssuesList,
StatusIcon,
Popover, Popover,
StatusIcon,
}, },
props: { props: {
alwaysOpen: { alwaysOpen: {
...@@ -186,16 +188,15 @@ export default { ...@@ -186,16 +188,15 @@ export default {
<slot name="action-buttons" :is-collapsible="isCollapsible"></slot> <slot name="action-buttons" :is-collapsible="isCollapsible"></slot>
<button <gl-button
v-if="isCollapsible" v-if="isCollapsible"
type="button" class="js-collapse-btn"
data-testid="report-section-expand-button" data-testid="report-section-expand-button"
class="js-collapse-btn btn float-right btn-sm align-self-center"
data-qa-selector="expand_report_button" data-qa-selector="expand_report_button"
@click="toggleCollapsed" @click="toggleCollapsed"
> >
{{ collapseText }} {{ collapseText }}
</button> </gl-button>
</div> </div>
</div> </div>
......
---
title: Migrates the expand button in MR reports to GitLab UI
merge_request: 57021
author:
type: other
import { shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import mountComponent, { mountComponentWithSlots } from 'helpers/vue_mount_component_helper'; import mountComponent, { mountComponentWithSlots } from 'helpers/vue_mount_component_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import reportSection from '~/reports/components/report_section.vue'; import reportSection from '~/reports/components/report_section.vue';
describe('Report section', () => { describe('Report section', () => {
let vm; let vm;
let wrapper; let wrapper;
const ReportSection = Vue.extend(reportSection); const ReportSection = Vue.extend(reportSection);
const findCollapseButton = () => wrapper.findByTestId('report-section-expand-button');
const resolvedIssues = [ const resolvedIssues = [
{ {
...@@ -30,12 +32,14 @@ describe('Report section', () => { ...@@ -30,12 +32,14 @@ describe('Report section', () => {
}; };
const createComponent = (props) => { const createComponent = (props) => {
wrapper = shallowMount(reportSection, { wrapper = extendedWrapper(
propsData: { mount(reportSection, {
...defaultProps, propsData: {
...props, ...defaultProps,
}, ...props,
}); },
}),
);
return wrapper; return wrapper;
}; };
...@@ -182,7 +186,7 @@ describe('Report section', () => { ...@@ -182,7 +186,7 @@ describe('Report section', () => {
expect(wrapper.emitted().toggleEvent).toBeUndefined(); expect(wrapper.emitted().toggleEvent).toBeUndefined();
wrapper.vm.$el.querySelector('button').click(); findCollapseButton().trigger('click');
return wrapper.vm return wrapper.vm
.$nextTick() .$nextTick()
.then(() => { .then(() => {
...@@ -197,7 +201,7 @@ describe('Report section', () => { ...@@ -197,7 +201,7 @@ describe('Report section', () => {
expect(wrapper.emitted().toggleEvent).toBeUndefined(); expect(wrapper.emitted().toggleEvent).toBeUndefined();
wrapper.vm.$el.querySelector('button').click(); findCollapseButton().trigger('click');
return wrapper.vm return wrapper.vm
.$nextTick() .$nextTick()
.then(() => { .then(() => {
......
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