tests(mvt): validate Tippecanoe TileJSON parsing, skip indexed tilestats, and enforce maxValues truncation#3266
tests(mvt): validate Tippecanoe TileJSON parsing, skip indexed tilestats, and enforce maxValues truncation#3266
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const fields = metadata.layers?.[0]?.fields || []; | ||
| const indexedFieldNames = fields.filter((field) => field.name.includes('|')); | ||
| t.equal(indexedFieldNames.length, 0, 'Indexed tilestats attributes are skipped'); | ||
| t.equal(metadata.layers?.[0]?.minZoom, 0, 'Vector layer minZoom is merged'); |
There was a problem hiding this comment.
Assert
minZoom only if parser normalizes minzoom
This assertion will fail with the current TileJSON parser because parseTileJSONLayer preserves the original minzoom key from vector_layers and never remaps it to minZoom. As a result, metadata.layers?.[0]?.minZoom is undefined for Tippecanoe input (which uses minzoom), so the new test (and the updated expected fixture that uses minZoom) will fail unless the parser is also changed to normalize the key. If you intend to keep the parser behavior, the test should check minzoom instead or be updated alongside a parser change.
Useful? React with 👍 / 👎.
Motivation
layers.|) are ignored by the parser and do not surface as fields.tilejson.maxValuesoption truncatesfields[].valuesas expected.Description
modules/mvt/test/tilejson-loader.spec.tsto load the expected parsed TileJSON viaJSONLoaderand assert deep equality with the parsed output fromTileJSONLoader.dominantGeometryandminZoom) are merged, and thatmaxValuestruncatesvaluescorrectly.modules/mvt/test/data/tilejson/tippecanoe.tilejsonto include an indexed tilestats attribute (e.g.scalerank|0) so the code path that ignores indexed attributes is exercised.modules/mvt/test/data/tilejson/tippecanoe.expected.jsonto match the parsed/normalized TileJSON structure used in assertions.Testing
yarn lint fix(required by project guidelines); it failed due to missing node_modules state file in the environment.yarn test node; this also failed for the same missing node_modules state file.Codex Task