-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[maps] fix geojson layer with joins and no left source matches stuck in loading state #160222
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29e9a84
fix warning state when GeoIndexPatternSelect does not have a value
nreese f323fc6
move loading indicator to same side for layer wizard buttons
nreese 71fed3c
do not check join loading when there are no source features
nreese bff6da7
add unit test
nreese 2c187be
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine 8ff43b2
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 881e6d6
tslint
nreese ea4ccc0
Merge branch 'main' into issue_156630
kibanamachine 5d29bb1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 8cb3683
Merge branch 'main' into issue_156630
kibanamachine d395341
fix test
nreese f56a122
Merge branch 'main' into issue_156630
kibanamachine e3a613f
Merge branch 'main' into issue_156630
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
166 changes: 166 additions & 0 deletions
166
...maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SOURCE_DATA_REQUEST_ID } from '../../../../../common/constants'; | ||
import { VectorLayerDescriptor } from '../../../../../common/descriptor_types'; | ||
import { InnerJoin } from '../../../joins/inner_join'; | ||
import { IJoinSource } from '../../../sources/join_sources'; | ||
import { IVectorSource } from '../../../sources/vector_source'; | ||
import { GeoJsonVectorLayer } from './geojson_vector_layer'; | ||
|
||
const joinDataRequestId = 'join_source_a0b0da65-5e1a-4967-9dbe-74f24391afe2'; | ||
const mockJoin = { | ||
hasCompleteConfig: () => { | ||
return true; | ||
}, | ||
getSourceDataRequestId: () => { | ||
return joinDataRequestId; | ||
}, | ||
getRightJoinSource: () => { | ||
return {} as unknown as IJoinSource; | ||
}, | ||
} as unknown as InnerJoin; | ||
|
||
describe('isLayerLoading', () => { | ||
test('should return true when source loading has not started', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
layerDescriptor: {}, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(true); | ||
}); | ||
|
||
test('Should return true when source data request is pending', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
layerDescriptor: { | ||
__dataRequests: [ | ||
{ | ||
data: {}, | ||
dataId: SOURCE_DATA_REQUEST_ID, | ||
dataRequestMetaAtStart: {}, | ||
dataRequestToken: Symbol(), | ||
}, | ||
], | ||
}, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(true); | ||
}); | ||
|
||
describe('no joins', () => { | ||
test('Should return false when source data request is finished', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
layerDescriptor: { | ||
__dataRequests: [ | ||
{ | ||
data: {}, | ||
dataId: SOURCE_DATA_REQUEST_ID, | ||
dataRequestMeta: {}, | ||
dataRequestMetaAtStart: undefined, | ||
dataRequestToken: undefined, | ||
}, | ||
], | ||
}, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('joins', () => { | ||
describe('source data loaded with no features', () => { | ||
test('should return false when join loading has not started', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
joins: [mockJoin], | ||
layerDescriptor: { | ||
__dataRequests: [ | ||
{ | ||
data: { | ||
features: [], | ||
}, | ||
dataId: SOURCE_DATA_REQUEST_ID, | ||
dataRequestMeta: {}, | ||
dataRequestMetaAtStart: undefined, | ||
dataRequestToken: undefined, | ||
}, | ||
], | ||
} as unknown as VectorLayerDescriptor, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('source data loaded with features', () => { | ||
const sourceDataRequestDescriptorWithFeatures = { | ||
data: { | ||
features: [{}], | ||
}, | ||
dataId: SOURCE_DATA_REQUEST_ID, | ||
dataRequestMeta: {}, | ||
dataRequestMetaAtStart: undefined, | ||
dataRequestToken: undefined, | ||
}; | ||
|
||
test('should return true when join loading has not started', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
joins: [mockJoin], | ||
layerDescriptor: { | ||
__dataRequests: [sourceDataRequestDescriptorWithFeatures], | ||
} as unknown as VectorLayerDescriptor, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(true); | ||
}); | ||
|
||
test('should return true when join data request is pending', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
joins: [mockJoin], | ||
layerDescriptor: { | ||
__dataRequests: [ | ||
sourceDataRequestDescriptorWithFeatures, | ||
{ | ||
dataId: joinDataRequestId, | ||
dataRequestMetaAtStart: {}, | ||
dataRequestToken: Symbol(), | ||
}, | ||
], | ||
} as unknown as VectorLayerDescriptor, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(true); | ||
}); | ||
|
||
test('should return false when join data request is finished', () => { | ||
const layer = new GeoJsonVectorLayer({ | ||
customIcons: [], | ||
joins: [mockJoin], | ||
layerDescriptor: { | ||
__dataRequests: [ | ||
sourceDataRequestDescriptorWithFeatures, | ||
{ | ||
data: {}, | ||
dataId: joinDataRequestId, | ||
dataRequestMeta: {}, | ||
dataRequestMetaAtStart: undefined, | ||
dataRequestToken: undefined, | ||
}, | ||
], | ||
} as unknown as VectorLayerDescriptor, | ||
source: {} as unknown as IVectorSource, | ||
}); | ||
expect(layer.isLayerLoading(1)).toBe(false); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,7 @@ export class AddLayerPanel extends Component<Props, State> { | |
disabled={isDisabled || isLoading} | ||
isLoading={isLoading} | ||
onClick={addLayersAndClose} | ||
iconSide="right" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
> | ||
{ADD_LAYER_STEP_SECONDARY_ACTION_BUTTON_LABEL} | ||
</EuiButton> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for displaying data view select input with validation errors when no data view is selected