Commit 5bcb81ba authored by Jose Vargas's avatar Jose Vargas

Refactor components tests

Change the expectations to test for
visibility instead of the internal props
this also removes some non needed code
parent 4b3d3112
...@@ -266,9 +266,6 @@ export default { ...@@ -266,9 +266,6 @@ export default {
this.$delete(this.allAlerts, alertPath); this.$delete(this.allAlerts, alertPath);
} }
}, },
openActionsDropdown() {
this.$refs.actionsDropdown.show();
},
}, },
panelTypes, panelTypes,
}; };
...@@ -305,20 +302,14 @@ export default { ...@@ -305,20 +302,14 @@ export default {
ref="contextualMenu" ref="contextualMenu"
data-qa-selector="prometheus_graph_widgets" data-qa-selector="prometheus_graph_widgets"
> >
<div <div class="d-flex align-items-center">
data-testid="actions-dropdown-container"
class="d-flex align-items-center"
@keyup.enter="openActionsDropdown"
>
<gl-dropdown <gl-dropdown
ref="actionsDropdown"
v-gl-tooltip v-gl-tooltip
toggle-class="btn btn-transparent border-0" toggle-class="btn btn-transparent border-0"
data-qa-selector="prometheus_widgets_dropdown" data-qa-selector="prometheus_widgets_dropdown"
right right
no-caret no-caret
:title="__('More actions')" :title="__('More actions')"
tabindex="0"
> >
<template slot="button-content"> <template slot="button-content">
<gl-icon name="ellipsis_v" class="text-secondary" /> <gl-icon name="ellipsis_v" class="text-secondary" />
......
--- ---
title: Make chart panels focusable via keyboard title: Focus and toggle metrics dashboard panels via keyboard
merge_request: 28603 merge_request: 28603
author: author:
type: added type: added
...@@ -56,9 +56,6 @@ describe('Dashboard Panel', () => { ...@@ -56,9 +56,6 @@ describe('Dashboard Panel', () => {
const findTimeChart = () => wrapper.find({ ref: 'timeSeriesChart' }); const findTimeChart = () => wrapper.find({ ref: 'timeSeriesChart' });
const findTitle = () => wrapper.find({ ref: 'graphTitle' }); const findTitle = () => wrapper.find({ ref: 'graphTitle' });
const findContextualMenu = () => wrapper.find({ ref: 'contextualMenu' }); const findContextualMenu = () => wrapper.find({ ref: 'contextualMenu' });
const findActionsDropdown = () => wrapper.find({ ref: 'actionsDropdown' });
const findActionsDropdownContainer = () =>
wrapper.find('[data-testid="actions-dropdown-container"]');
const createWrapper = (props, options) => { const createWrapper = (props, options) => {
wrapper = shallowMount(DashboardPanel, { wrapper = shallowMount(DashboardPanel, {
...@@ -201,21 +198,6 @@ describe('Dashboard Panel', () => { ...@@ -201,21 +198,6 @@ describe('Dashboard Panel', () => {
}); });
}); });
it('should set a tabindex for the actions dropdown', () => {
const actionsDropdown = findActionsDropdown();
expect(actionsDropdown.contains('[tabindex]')).toBe(true);
});
it('should open the actions dropdown when enter is pressed', () => {
const openDropdownSpy = jest.spyOn(wrapper.vm, 'openActionsDropdown').mockImplementation();
const container = findActionsDropdownContainer();
container.trigger('keyup.enter');
expect(openDropdownSpy).toHaveBeenCalled();
});
it('includes a default group id', () => { it('includes a default group id', () => {
expect(wrapper.vm.groupId).toBe('dashboard-panel'); expect(wrapper.vm.groupId).toBe('dashboard-panel');
}); });
......
...@@ -81,13 +81,13 @@ describe('Graph group component', () => { ...@@ -81,13 +81,13 @@ describe('Graph group component', () => {
expect(wrapper.vm.caretIcon).toBe('angle-down'); expect(wrapper.vm.caretIcon).toBe('angle-down');
}); });
it('should call the collapse function when the button listen to a keyup enter trigger', () => { it('should call collapse the graph group content when enter is pressed on the caret icon', () => {
const collapseSpy = jest.spyOn(wrapper.vm, 'collapse'); const graphGroupContent = findContent();
const button = findToggleButton(); const button = findToggleButton();
button.trigger('keyup.enter'); button.trigger('keyup.enter');
expect(collapseSpy).toHaveBeenCalled(); expect(graphGroupContent.isVisible()).toBe(false);
}); });
}); });
......
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