Commit 558c19ec authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'ek-vsa-base-speci-minor-reorganization' into 'master'

VSA base spec minor reorganization

See merge request gitlab-org/gitlab!42329
parents 485a0b98 1301ac5c
...@@ -191,356 +191,351 @@ describe('Cycle Analytics component', () => { ...@@ -191,356 +191,351 @@ describe('Cycle Analytics component', () => {
expect(wrapper.find(ValueStreamSelect).exists()).toBe(flag); expect(wrapper.find(ValueStreamSelect).exists()).toBe(flag);
}; };
describe('displays the components as required', () => { describe('without a group', () => {
describe('without a group', () => { beforeEach(async () => {
beforeEach(async () => { const { group, ...stateWithoutGroup } = initialCycleAnalyticsState;
const { group, ...stateWithoutGroup } = initialCycleAnalyticsState; mock = new MockAdapter(axios);
mock = new MockAdapter(axios); wrapper = await createComponent({
wrapper = await createComponent({ featureFlags: {
featureFlags: { hasPathNavigation: true,
hasPathNavigation: true, },
}, initialState: stateWithoutGroup,
initialState: stateWithoutGroup,
});
}); });
});
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
mock.restore(); mock.restore();
wrapper = null; wrapper = null;
}); });
it('displays an empty state', () => { it('displays an empty state', () => {
const emptyState = wrapper.find(GlEmptyState); const emptyState = wrapper.find(GlEmptyState);
expect(emptyState.exists()).toBe(true); expect(emptyState.exists()).toBe(true);
expect(emptyState.props('svgPath')).toBe(emptyStateSvgPath); expect(emptyState.props('svgPath')).toBe(emptyStateSvgPath);
}); });
it('does not display the projects filter', () => { it('does not display the projects filter', () => {
displaysProjectsDropdownFilter(false); displaysProjectsDropdownFilter(false);
}); });
it('does not display the date range picker', () => { it('does not display the date range picker', () => {
displaysDateRangePicker(false); displaysDateRangePicker(false);
}); });
it('does not display the metrics cards', () => { it('does not display the metrics cards', () => {
displaysMetrics(false); displaysMetrics(false);
}); });
it('does not display the stage table', () => { it('does not display the stage table', () => {
displaysStageTable(false); displaysStageTable(false);
}); });
it('does not display the duration chart', () => { it('does not display the duration chart', () => {
displaysDurationChart(false); displaysDurationChart(false);
}); });
it('does not display the add stage button', () => { it('does not display the add stage button', () => {
displaysAddStageButton(false); displaysAddStageButton(false);
}); });
it('does not display the path navigation', () => {
displaysPathNavigation(false);
});
it('does not display the value stream select component', () => {
displaysValueStreamSelect(false);
});
});
describe('the user does not have access to the group', () => {
beforeEach(async () => {
mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
it('does not display the path navigation', () => { wrapper = await createComponent({
displaysPathNavigation(false); featureFlags: {
hasPathNavigation: true,
},
}); });
it('does not display the value stream select component', () => { await store.dispatch('receiveCycleAnalyticsDataError', {
displaysValueStreamSelect(false); response: { status: httpStatusCodes.FORBIDDEN },
}); });
}); });
describe('with a group', () => { it('renders the no access information', () => {
beforeEach(async () => { const emptyState = wrapper.find(GlEmptyState);
mock = new MockAdapter(axios);
mockRequiredRoutes(mock); expect(emptyState.exists()).toBe(true);
wrapper = await createComponent({ expect(emptyState.props('svgPath')).toBe(noAccessSvgPath);
featureFlags: { });
hasPathNavigation: true,
}, it('does not display the projects filter', () => {
}); displaysProjectsDropdownFilter(false);
}); });
it('does not display the date range picker', () => {
displaysDateRangePicker(false);
});
it('does not display the metrics', () => {
displaysMetrics(false);
});
it('does not display the stage table', () => {
displaysStageTable(false);
});
it('does not display the add stage button', () => {
displaysAddStageButton(false);
});
afterEach(() => { it('does not display the tasks by type chart', () => {
wrapper.destroy(); displaysTypeOfWork(false);
mock.restore(); });
wrapper = null;
it('does not display the duration chart', () => {
displaysDurationChart(false);
});
describe('path navigation', () => {
describe('disabled', () => {
it('does not display the path navigation', () => {
displaysPathNavigation(false);
});
}); });
describe('the user has access to the group', () => { describe('enabled', () => {
beforeEach(async () => { beforeEach(async () => {
mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
wrapper = await createComponent({ wrapper = await createComponent({
withValueStreamSelected: false,
withStageSelected: true, withStageSelected: true,
featureFlags: { pathNavigationEnabled: true,
hasPathNavigation: true,
},
}); });
});
it('hides the empty state', () => { mock = new MockAdapter(axios);
expect(wrapper.find(GlEmptyState).exists()).toBe(false); mockRequiredRoutes(mock);
}); mock.onAny().reply(httpStatusCodes.FORBIDDEN);
it('displays the projects filter', () => { await waitForPromises();
displaysProjectsDropdownFilter(true); });
expect(wrapper.find(ProjectsDropdownFilter).props()).toEqual( afterEach(() => {
expect.objectContaining({ mock.restore();
queryParams: wrapper.vm.projectsQueryParams,
multiSelect: wrapper.vm.$options.multiProjectSelect,
}),
);
}); });
describe('hasCreateMultipleValueStreams = true', () => { it('does not display the path navigation', () => {
beforeEach(() => { displaysPathNavigation(false);
mock = new MockAdapter(axios); });
mockRequiredRoutes(mock); });
}); });
});
it('hides the value stream select component', () => { describe('the user has access to the group', () => {
displaysValueStreamSelect(false); beforeEach(async () => {
}); mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
wrapper = await createComponent({
withStageSelected: true,
featureFlags: {
hasPathNavigation: true,
},
});
});
it('displays the value stream select component', async () => { afterEach(() => {
wrapper = await createComponent({ wrapper.destroy();
featureFlags: { mock.restore();
hasCreateMultipleValueStreams: true, wrapper = null;
}, });
});
displaysValueStreamSelect(true); it('hides the empty state', () => {
}); expect(wrapper.find(GlEmptyState).exists()).toBe(false);
}); });
describe('when analyticsSimilaritySearch feature flag is on', () => { it('displays the projects filter', () => {
beforeEach(async () => { displaysProjectsDropdownFilter(true);
wrapper = await createComponent({
withStageSelected: true,
featureFlags: {
hasAnalyticsSimilaritySearch: true,
},
});
});
it('uses similarity as the order param', () => { expect(wrapper.find(ProjectsDropdownFilter).props()).toEqual(
displaysProjectsDropdownFilter(true); expect.objectContaining({
queryParams: wrapper.vm.projectsQueryParams,
multiSelect: wrapper.vm.$options.multiProjectSelect,
}),
);
});
expect(wrapper.find(ProjectsDropdownFilter).props().queryParams.order_by).toEqual( describe('hasCreateMultipleValueStreams = true', () => {
'similarity', beforeEach(() => {
); mock = new MockAdapter(axios);
}); mockRequiredRoutes(mock);
}); });
it('displays the date range picker', () => { it('hides the value stream select component', () => {
displaysDateRangePicker(true); displaysValueStreamSelect(false);
}); });
it('displays the metrics', () => { it('displays the value stream select component', async () => {
displaysMetrics(true); wrapper = await createComponent({
featureFlags: {
hasCreateMultipleValueStreams: true,
},
}); });
it('displays the stage table', () => { displaysValueStreamSelect(true);
displaysStageTable(true); });
}); });
it('displays the filter bar', () => { describe('when analyticsSimilaritySearch feature flag is on', () => {
displaysFilterBar(true); beforeEach(async () => {
wrapper = await createComponent({
withStageSelected: true,
featureFlags: {
hasAnalyticsSimilaritySearch: true,
},
}); });
});
it('displays the add stage button', async () => { it('uses similarity as the order param', () => {
wrapper = await createComponent({ displaysProjectsDropdownFilter(true);
opts: {
stubs: {
StageTable,
StageTableNav,
AddStageButton,
},
},
withStageSelected: true,
});
await wrapper.vm.$nextTick(); expect(wrapper.find(ProjectsDropdownFilter).props().queryParams.order_by).toEqual(
displaysAddStageButton(true); 'similarity',
}); );
});
});
it('displays the tasks by type chart', async () => { it('displays the date range picker', () => {
wrapper = await createComponent({ shallow: false, withStageSelected: true }); displaysDateRangePicker(true);
await wrapper.vm.$nextTick(); });
expect(wrapper.find('.js-tasks-by-type-chart').exists()).toBe(true);
});
it('displays the duration chart', () => { it('displays the metrics', () => {
displaysDurationChart(true); displaysMetrics(true);
}); });
describe('path navigation', () => { it('displays the stage table', () => {
describe('disabled', () => { displaysStageTable(true);
beforeEach(async () => { });
wrapper = await createComponent({
withStageSelected: true,
featureFlags: {
hasPathNavigation: false,
},
});
});
it('does not display the path navigation', () => {
displaysPathNavigation(false);
});
});
describe('enabled', () => { it('displays the filter bar', () => {
beforeEach(async () => { displaysFilterBar(true);
wrapper = await createComponent({ });
withStageSelected: true,
featureFlags: {
hasPathNavigation: true,
},
});
});
it('displays the path navigation', () => {
displaysPathNavigation(true);
});
});
});
describe('StageTable', () => { it('displays the add stage button', async () => {
beforeEach(async () => { wrapper = await createComponent({
mock = new MockAdapter(axios); opts: {
mockRequiredRoutes(mock); stubs: {
StageTable,
wrapper = await createComponent({ StageTableNav,
opts: { AddStageButton,
stubs: { },
StageTable, },
StageTableNav, withStageSelected: true,
StageNavItem, });
},
},
withValueStreamSelected: false,
withStageSelected: true,
});
});
it('has the first stage selected by default', async () => { await wrapper.vm.$nextTick();
const first = findStageNavItemAtIndex(0); displaysAddStageButton(true);
const second = findStageNavItemAtIndex(1); });
expect(first.props('isActive')).toBe(true); it('displays the tasks by type chart', async () => {
expect(second.props('isActive')).toBe(false); wrapper = await createComponent({ shallow: false, withStageSelected: true });
}); await wrapper.vm.$nextTick();
expect(wrapper.find('.js-tasks-by-type-chart').exists()).toBe(true);
});
it('can navigate to different stages', async () => { it('displays the duration chart', () => {
findStageNavItemAtIndex(2).trigger('click'); displaysDurationChart(true);
});
await wrapper.vm.$nextTick(); describe('path navigation', () => {
const first = findStageNavItemAtIndex(0); describe('disabled', () => {
const third = findStageNavItemAtIndex(2); beforeEach(async () => {
expect(third.props('isActive')).toBe(true); wrapper = await createComponent({
expect(first.props('isActive')).toBe(false); withStageSelected: true,
featureFlags: {
hasPathNavigation: false,
},
}); });
});
describe('Add stage button', () => { it('does not display the path navigation', () => {
beforeEach(async () => { displaysPathNavigation(false);
wrapper = await createComponent({
opts: {
stubs: {
StageTable,
StageTableNav,
AddStageButton,
},
},
withStageSelected: true,
});
});
it('can navigate to the custom stage form', async () => {
expect(wrapper.find(CustomStageForm).exists()).toBe(false);
findAddStageButton().trigger('click');
await wrapper.vm.$nextTick();
expect(wrapper.find(CustomStageForm).exists()).toBe(true);
});
});
}); });
});
describe('the user does not have access to the group', () => { describe('enabled', () => {
beforeEach(async () => { beforeEach(async () => {
await store.dispatch('receiveCycleAnalyticsDataError', { wrapper = await createComponent({
response: { status: httpStatusCodes.FORBIDDEN }, withStageSelected: true,
}); featureFlags: {
hasPathNavigation: true,
},
}); });
});
it('renders the no access information', () => { it('displays the path navigation', () => {
const emptyState = wrapper.find(GlEmptyState); displaysPathNavigation(true);
});
});
});
expect(emptyState.exists()).toBe(true); describe('StageTable', () => {
expect(emptyState.props('svgPath')).toBe(noAccessSvgPath); beforeEach(async () => {
}); mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
it('does not display the projects filter', () => { wrapper = await createComponent({
displaysProjectsDropdownFilter(false); opts: {
}); stubs: {
StageTable,
StageTableNav,
StageNavItem,
},
},
withValueStreamSelected: false,
withStageSelected: true,
});
});
it('does not display the date range picker', () => { it('has the first stage selected by default', async () => {
displaysDateRangePicker(false); const first = findStageNavItemAtIndex(0);
}); const second = findStageNavItemAtIndex(1);
it('does not display the metrics', () => { expect(first.props('isActive')).toBe(true);
displaysMetrics(false); expect(second.props('isActive')).toBe(false);
}); });
it('does not display the stage table', () => { it('can navigate to different stages', async () => {
displaysStageTable(false); findStageNavItemAtIndex(2).trigger('click');
});
it('does not display the add stage button', () => { await wrapper.vm.$nextTick();
displaysAddStageButton(false); const first = findStageNavItemAtIndex(0);
}); const third = findStageNavItemAtIndex(2);
expect(third.props('isActive')).toBe(true);
expect(first.props('isActive')).toBe(false);
});
it('does not display the tasks by type chart', () => { describe('Add stage button', () => {
displaysTypeOfWork(false); beforeEach(async () => {
wrapper = await createComponent({
opts: {
stubs: {
StageTable,
StageTableNav,
AddStageButton,
},
},
withStageSelected: true,
}); });
});
it('does not display the duration chart', () => { it('can navigate to the custom stage form', async () => {
displaysDurationChart(false); expect(wrapper.find(CustomStageForm).exists()).toBe(false);
}); findAddStageButton().trigger('click');
describe('path navigation', () => { await wrapper.vm.$nextTick();
describe('disabled', () => { expect(wrapper.find(CustomStageForm).exists()).toBe(true);
it('does not display the path navigation', () => {
displaysPathNavigation(false);
});
});
describe('enabled', () => {
beforeEach(async () => {
wrapper = await createComponent({
withValueStreamSelected: false,
withStageSelected: true,
pathNavigationEnabled: true,
});
mock = new MockAdapter(axios);
mockRequiredRoutes(mock);
mock.onAny().reply(httpStatusCodes.FORBIDDEN);
await waitForPromises();
});
afterEach(() => {
mock.restore();
});
it('does not display the path navigation', () => {
displaysPathNavigation(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