Commit f998b6ff authored by Miguel Rincon's avatar Miguel Rincon

Improve dropdowns performance with lazy

Sets the "artifacts" and "manual" dropdowns in the pipelines list page
to "lazy".
parent d54e6dc0
...@@ -82,6 +82,7 @@ export default { ...@@ -82,6 +82,7 @@ export default {
:loading="isLoading" :loading="isLoading"
data-testid="pipelines-manual-actions-dropdown" data-testid="pipelines-manual-actions-dropdown"
right right
lazy
icon="play" icon="play"
> >
<gl-dropdown-item <gl-dropdown-item
......
...@@ -31,6 +31,8 @@ export default { ...@@ -31,6 +31,8 @@ export default {
:text="$options.translations.artifacts" :text="$options.translations.artifacts"
:aria-label="$options.translations.artifacts" :aria-label="$options.translations.artifacts"
icon="download" icon="download"
right
lazy
text-sr-only text-sr-only
> >
<gl-dropdown-item <gl-dropdown-item
......
---
title: Reduce elements in Pipeline page dropdowns with lazy
merge_request: 54674
author:
type: changed
import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
...@@ -63,10 +63,6 @@ describe('Pipelines Actions dropdown', () => { ...@@ -63,10 +63,6 @@ describe('Pipelines Actions dropdown', () => {
}); });
describe('on click', () => { describe('on click', () => {
beforeEach(() => {
createComponent({ actions: mockActions }, mount);
});
it('makes a request and toggles the loading state', async () => { it('makes a request and toggles the loading state', async () => {
mock.onPost(mockActions.path).reply(200); mock.onPost(mockActions.path).reply(200);
......
import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlDropdown, GlDropdownItem, GlSprintf } from '@gitlab/ui';
import { mount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue'; import PipelineArtifacts from '~/pipelines/components/pipelines_list/pipelines_artifacts.vue';
describe('Pipelines Artifacts dropdown', () => { describe('Pipelines Artifacts dropdown', () => {
let wrapper; let wrapper;
const createComponent = () => { const createComponent = () => {
wrapper = mount(PipelineArtifacts, { wrapper = shallowMount(PipelineArtifacts, {
propsData: { propsData: {
artifacts: [ artifacts: [
{ {
name: 'artifact', name: 'job my-artifact',
path: '/download/path', path: '/download/path',
}, },
{ {
name: 'artifact two', name: 'job-2 my-artifact-2',
path: '/download/path-two', path: '/download/path-two',
}, },
], ],
}, },
stubs: {
GlSprintf,
},
}); });
}; };
...@@ -39,8 +42,8 @@ describe('Pipelines Artifacts dropdown', () => { ...@@ -39,8 +42,8 @@ describe('Pipelines Artifacts dropdown', () => {
}); });
it('should render a link with the provided path', () => { it('should render a link with the provided path', () => {
expect(findFirstGlDropdownItem().find('a').attributes('href')).toEqual('/download/path'); expect(findFirstGlDropdownItem().attributes('href')).toBe('/download/path');
expect(findFirstGlDropdownItem().text()).toContain('artifact'); expect(findFirstGlDropdownItem().text()).toBe('Download job my-artifact artifact');
}); });
}); });
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import waitForPromises from 'helpers/wait_for_promises';
import PipelinesTableRowComponent from '~/pipelines/components/pipelines_list/pipelines_table_row.vue'; import PipelinesTableRowComponent from '~/pipelines/components/pipelines_list/pipelines_table_row.vue';
import eventHub from '~/pipelines/event_hub'; import eventHub from '~/pipelines/event_hub';
...@@ -182,10 +183,16 @@ describe('Pipelines Table Row', () => { ...@@ -182,10 +183,16 @@ describe('Pipelines Table Row', () => {
expect(wrapper.find('.js-pipelines-retry-button').attributes('title')).toMatch('Retry'); expect(wrapper.find('.js-pipelines-retry-button').attributes('title')).toMatch('Retry');
expect(wrapper.find('.js-pipelines-cancel-button').exists()).toBe(true); expect(wrapper.find('.js-pipelines-cancel-button').exists()).toBe(true);
expect(wrapper.find('.js-pipelines-cancel-button').attributes('title')).toMatch('Cancel'); expect(wrapper.find('.js-pipelines-cancel-button').attributes('title')).toMatch('Cancel');
});
it('should render the manual actions', async () => {
const manualActions = wrapper.find('[data-testid="pipelines-manual-actions-dropdown"]');
const actionsMenu = wrapper.find('[data-testid="pipelines-manual-actions-dropdown"]'); // Click on the dropdown and wait for `lazy` dropdown items
manualActions.find('.dropdown-toggle').trigger('click');
await waitForPromises();
expect(actionsMenu.text()).toContain(scheduledJobAction.name); expect(manualActions.text()).toContain(scheduledJobAction.name);
}); });
it('emits `retryPipeline` event when retry button is clicked and toggles loading', () => { it('emits `retryPipeline` event when retry button is clicked and toggles loading', () => {
......
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