Skip to content
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

Add a testMode Map option to allow for usage in tests without an access token #10445

Merged
merged 13 commits into from
Mar 9, 2021

Conversation

arindam1993
Copy link
Contributor

This PR adds a new Map constructor option called testMode. When enabled it allows for the usage of the map in automated tests without an accessToken with custom self-hosted test fixtures.

In this mode, the Map produces no rendered output on the canvas, but still retains all state for features and the camera. This means mocked mouse and UI events will work as expected.

In order to "test" the testMode I migrated our unit and selenium tests to use it, and removed the custom access tokens that were hardcoded in there.

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog></changelog>

src/render/draw_sky.js Outdated Show resolved Hide resolved
src/ui/map.js Show resolved Hide resolved
src/ui/map.js Show resolved Hide resolved
src/util/mapbox.js Show resolved Hide resolved
src/render/program.js Outdated Show resolved Hide resolved
src/ui/map.js Show resolved Hide resolved
@karimnaaji karimnaaji added this to the v2.2 milestone Mar 9, 2021
Copy link
Contributor

@karimnaaji karimnaaji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for moving the auth check up to Painter.

@arindam1993 arindam1993 merged commit 4c62756 into main Mar 9, 2021
@arindam1993 arindam1993 deleted the map-testing branch March 9, 2021 23:49
@@ -104,6 +104,7 @@ type MapOptions = {
maxTileCacheSize?: number,
transformRequest?: RequestTransformFunction,
accessToken: string,
testMode: ?boolean,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be optional, not just nullable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants