Commit 5cd6cff3 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '298930-local-storage-oversight' into 'master'

Disregard localStorage if it does not apply

See merge request gitlab-org/gitlab!59913
parents e32b1a8d ee614685
...@@ -138,6 +138,10 @@ export default { ...@@ -138,6 +138,10 @@ export default {
metricsPath: this.metricsPath, metricsPath: this.metricsPath,
}; };
}, },
graphViewType() {
/* This prevents reading view type off the localStorage value if it does not apply. */
return this.showGraphViewSelector ? this.currentViewType : STAGE_VIEW;
},
showLoadingIcon() { showLoadingIcon() {
/* /*
Shows the icon only when the graph is empty, not when it is is Shows the icon only when the graph is empty, not when it is is
...@@ -205,7 +209,7 @@ export default { ...@@ -205,7 +209,7 @@ export default {
> >
<graph-view-selector <graph-view-selector
v-if="showGraphViewSelector" v-if="showGraphViewSelector"
:type="currentViewType" :type="graphViewType"
:show-links="showLinks" :show-links="showLinks"
@updateViewType="updateViewType" @updateViewType="updateViewType"
@updateShowLinksState="updateShowLinksState" @updateShowLinksState="updateShowLinksState"
...@@ -218,7 +222,7 @@ export default { ...@@ -218,7 +222,7 @@ export default {
:pipeline="pipeline" :pipeline="pipeline"
:pipeline-layers="getPipelineLayers()" :pipeline-layers="getPipelineLayers()"
:show-links="showLinks" :show-links="showLinks"
:view-type="currentViewType" :view-type="graphViewType"
@error="reportFailure" @error="reportFailure"
@refreshPipelineGraph="refreshPipelineGraph" @refreshPipelineGraph="refreshPipelineGraph"
/> />
......
...@@ -354,6 +354,36 @@ describe('Pipeline graph wrapper', () => { ...@@ -354,6 +354,36 @@ describe('Pipeline graph wrapper', () => {
}); });
}); });
describe('when feature flag is on and local storage is set, but the graph does not use needs', () => {
beforeEach(async () => {
const nonNeedsResponse = { ...mockPipelineResponse };
nonNeedsResponse.data.project.pipeline.usesNeeds = false;
localStorage.setItem(VIEW_TYPE_KEY, LAYER_VIEW);
createComponentWithApollo({
provide: {
glFeatures: {
pipelineGraphLayersView: true,
},
},
mountFn: mount,
getPipelineDetailsHandler: jest.fn().mockResolvedValue(nonNeedsResponse),
});
jest.runOnlyPendingTimers();
await wrapper.vm.$nextTick();
});
afterEach(() => {
localStorage.clear();
});
it('still passes stage type to graph', () => {
expect(getGraph().props('viewType')).toBe(STAGE_VIEW);
});
});
describe('when feature flag is on but pipeline does not use needs', () => { describe('when feature flag is on but pipeline does not use needs', () => {
beforeEach(async () => { beforeEach(async () => {
const nonNeedsResponse = { ...mockPipelineResponse }; const nonNeedsResponse = { ...mockPipelineResponse };
......
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