Commit 03bf24d9 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Natalia Tepluhina

Add missing jest tests

Adds additional jest tests for the VSA
aggregating warning message
parent 67fd98b1
......@@ -32,7 +32,7 @@ export default {
primaryText: AGGREGATING_DATA_PRIMARY_ACTION_TEXT,
secondaryText: AGGREGATING_DATA_SECONDARY_ACTION_TEXT,
},
docsPath: helpPagePath('user/group/value_stream_analytics', {
docsPath: helpPagePath('user/group/value_stream_analytics/index', {
anchor: 'create-a-value-stream',
}),
};
......
......@@ -60,7 +60,7 @@ export default {
EMPTY_STATE_FILTER_ERROR_TITLE,
EMPTY_STATE_FILTER_ERROR_DESCRIPTION,
},
docsPath: helpPagePath('user/group/value_stream_analytics', {
docsPath: helpPagePath('user/group/value_stream_analytics/index', {
anchor: 'custom-value-streams',
}),
};
......
import { shallowMount } from '@vue/test-utils';
import { GlAlert } from '@gitlab/ui';
import ValueStreamAggregatingWarning from 'ee/analytics/cycle_analytics/components/value_stream_aggregating_warning.vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
const valueStreamTitle = 'New value stream';
const aggregatingMessage = `'${valueStreamTitle}' is collecting the data. This can take a few minutes.`;
const nextUpdateMsg =
'If you have recently upgraded to GitLab Premium, it can take up to 30 minutes for data to collect and display.';
const secondaryBtnLink = '/help/user/group/value_stream_analytics/index#create-a-value-stream';
const createComponent = (props = {}) =>
extendedWrapper(
shallowMount(ValueStreamAggregatingWarning, {
propsData: {
valueStreamTitle,
...props,
},
}),
);
describe('ValueStreamAggregatingWarning', () => {
let wrapper = null;
const findAlert = () => wrapper.findComponent(GlAlert);
const findPrimaryButtonTxt = () => findAlert().attributes('primarybuttontext');
const findSecondaryButtonTxt = () => findAlert().attributes('secondarybuttontext');
const findSecondaryButtonLink = () => findAlert().attributes('secondarybuttonlink');
afterEach(() => {
wrapper.destroy();
});
describe('default state', () => {
beforeEach(() => {
wrapper = createComponent();
});
it('renders the primary button', () => {
expect(findPrimaryButtonTxt()).toBe('Reload page');
});
it('renders the secondary button with a docs link', () => {
expect(findSecondaryButtonTxt()).toBe('Learn more');
expect(findSecondaryButtonLink()).toBe(secondaryBtnLink);
});
it('renders the aggregating warning and estimated next update', () => {
const content = findAlert().text();
expect(content).toContain(aggregatingMessage);
expect(content).toContain(nextUpdateMsg);
});
it('emits the `reload` action when the primary button is clicked', async () => {
expect(wrapper.emitted('reload')).toBeUndefined();
await findAlert().vm.$emit('primaryAction');
expect(wrapper.emitted('reload')).toHaveLength(1);
});
});
});
......@@ -65,7 +65,7 @@ describe('ValueStreamEmptyState', () => {
expect(findSecondaryAction().exists()).toBe(true);
expect(findSecondaryAction().text()).toBe(EMPTY_STATE_SECONDARY_TEXT);
expect(findSecondaryAction().attributes('href')).toBe(
'/help/user/group/value_stream_analytics#custom-value-streams',
'/help/user/group/value_stream_analytics/index#custom-value-streams',
);
});
});
......
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