PB-1263: add handleLegacyParam function tests#1161
Conversation
web-mapviewer
|
||||||||||||||||||||||||||||
| Project |
web-mapviewer
|
| Branch Review |
develop
|
| Run status |
|
| Run duration | 01m 43s |
| Commit |
|
| Committer | Felix Sommer |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
1
|
|
|
0
|
|
|
48
|
| View all changes introduced in this branch ↗︎ | |
02a0ea4 to
305f1f6
Compare
591755d to
154de0a
Compare
ltkum
left a comment
There was a problem hiding this comment.
It's a good foundation, but I think we can simplify this a bit, and also extend the coverage at the same time
| newValue = LV95.transformCustomZoomLevelToStandard(legacyValue) | ||
| if (projection instanceof CustomCoordinateSystem) { | ||
| newValue = projection.transformStandardZoomLevelToCustom(newValue) | ||
| newValue = projection.transformStandardZoomLevelToCustom(newValue) // FIXME: the function transformStandardZoomLevelToCustom is not implemented in CustomCoordinateSystem |
There was a problem hiding this comment.
Currently in the mapviewer, we have the following coordinates systems :
LV95 & LV03 : swissCoordinatesSystems which inherits CustomCoordinateSystem, and in which the function is implemented
WGS84 & webmercator which inherits StandardCoordinateSystem
We should not call for the function outside of a specific projection. I would remove this FIXME.
There was a problem hiding this comment.
do i understand this right, that this function will never be called ? so then we should remove either the whole if statement or replace this function call directly with a throw Error call
There was a problem hiding this comment.
I think this function will never be called in the current implementation of the mapviewer. There might be a day where we have a Coordinate System which would be both custom, and not swiss. I would at least add a comment for this , and maybe @pakb has another idea for further mitigation.
Regarding the throw Error call, that is the basic function implementation, so this is currently the case: if we reach this place, something went very wrong and it will throw an error.
There was a problem hiding this comment.
Ok so I removed the FIXME comment, so it is like it was before. But I can add a comment saying that this case should never be called in theory
src/router/__tests__/legacyPermalinkManagement.routerPlugin.spec.js
Outdated
Show resolved
Hide resolved
src/router/__tests__/legacyPermalinkManagement.routerPlugin.spec.js
Outdated
Show resolved
Hide resolved
src/router/__tests__/legacyPermalinkManagement.routerPlugin.spec.js
Outdated
Show resolved
Hide resolved
src/router/__tests__/legacyPermalinkManagement.routerPlugin.spec.js
Outdated
Show resolved
Hide resolved
| it('N', () => { | ||
| const param = 'N' | ||
| const legacyCoordinates = [0, 0] | ||
| handleLegacyParams({ param, legacyCoordinates }) | ||
|
|
||
| expect(legacyCoordinates).to.deep.equal([0, legacyValue]) |
There was a problem hiding this comment.
this can also work if the array is still empty, and we should make sure it works in both case.
There was a problem hiding this comment.
so if legacyCoordinates = []
then the result is [ undefined, 10 ]
is this valid ?
There was a problem hiding this comment.
I don't know if it is ['undefined', 10], as when I tried it quickly it gave me in the console something of the form : [, 10], but if you do legacyCoordinates[0], it should give you undefined, yes.
There was a problem hiding this comment.
I tried it and it fills the index 0 with undefined, how did you get [, 10] ? is this an empty string then or what is at index 0
so should i add a test to see if the result is [undefined, 10] ?
There was a problem hiding this comment.
I tried it in a quick js codepen, and it gave me [ <1 empty item>, 10 ] as a result. Maybe it's an implementation of the codepen to show undefined items in such a way (for example if I had put the coordinates at arrray[250]).
I would test that the result is indeed [undefined, 10]
There was a problem hiding this comment.
ok i'll test this thanks
| const layerVisibility = 'layers_visibility' | ||
| const layerOpacity = 'layers_opacity' | ||
| const layerTimestamp = 'layers_timestamp' |
There was a problem hiding this comment.
if we want to check it's transformed correctly, we should also make tests which checks that the values are transformed correctly. This means :
we need to set the visibility to 'true'
we need to check that if we set the opacity to a valid value (a value between 0 and 1 as a string)
we need to add a timeConfig to the layerConfig and a timestamp to check that it can be added to the layer
but it is also good to check that if we set invalid values, it work as expected and ignores those values.
There was a problem hiding this comment.
I think this has to be done in a unit test of the transformLayerIntoUrlString function and does not belong to this test
do you want me to create also a unit test for the transformLayerIntoUrlString function ?
There was a problem hiding this comment.
Well, handleLegacyParameter uses transformLayerIntoUrlString anyway, but we should also test the transformLayerIntoUrlString if it's not already tested.
There was a problem hiding this comment.
i just saw that transformLayerIntoUrlString is already tested in the layersParamParser.spec.js unit test. So i think there is nothing else to do
ad67651 to
c607a7a
Compare
a34d7f9 to
4d2fc45
Compare
ltkum
left a comment
There was a problem hiding this comment.
Please quickly change the comment to reflect the situation, but I don't want you to be blocked by it. Once it's done and the tests passes, you can merge :)
good job
| if (!(projection instanceof SwissCoordinateSystem)) { | ||
| newValue = LV95.transformCustomZoomLevelToStandard(legacyValue) | ||
| if (projection instanceof CustomCoordinateSystem) { | ||
| // Currently ther is no SwissCoordinateSystem which is also a CustomCoordinateSystem so this case should never be reached |
There was a problem hiding this comment.
This would be
// Currently, there is no CustomCoordinateSystem which is not a SwissCoordinateSystem, so this case should never be reached.
4d2fc45 to
af1b597
Compare
af1b597 to
00c562a
Compare
Test link