publiclab / leaflet-environmental-layers

Collection of different environmental map layers in an easy to use Leaflet library, similar to https://github.com/leaflet-extras/leaflet-providers#leaflet-providers
https://publiclab.github.io/leaflet-environmental-layers/example/
GNU General Public License v3.0
99 stars 77 forks source link

Tracking general cypress test failures #668

Open jywarren opened 2 years ago

jywarren commented 2 years ago

Some recent PRs that should be unrelated to tests like http-server are failing cypress tests: https://github.com/publiclab/leaflet-environmental-layers/runs/6688364021?check_suite_focus=true

no test runs on recent PRs have succeeded; some have limited layer-specific failures like #667

while others like the http-server one above are failing ALL cypress tests with the error:

     Error: Trying to stub property 'requestData' of undefined

I'm re-running https://github.com/publiclab/leaflet-environmental-layers/pull/662 just to see if it's intermittent.

Those with limited layer-specific failures include:

The tests failing are:

jywarren commented 2 years ago

PurpleAir

Confirmed purpleAirMarker layer shows a 302 error on the demo, message at https://purpleair-over-quota-2.appspot.com/

jquery.min.js:2          GET https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=39.2173592639196&selat=38.47186888757717&nwlng=-77.65136718750001&selng=-76.24374389648439 net::ERR_FAILED 302

Should look at the PurpleAir API again to see what's up.

AQICN

The AQICN layer looks fine though - markers appear normally. But, the error had been:

Aqicn layer
       has circle markers in minimal mode:
AssertionError: Timed out retrying: Too many elements found. Found '1143', expected '2'.

Plus it failing to find a marker labeled "Spain".

It searches in this region: https://publiclab.github.io/leaflet-environmental-layers/example/index.html#lat=51.15&lon=13.45&zoom=4&layers=Standard

FracTracker

The FracTracker Mobile layer is a spreadsheet layer: https://spreadsheets.google.com/feeds/list/19j4AQmjWuELuzn1GIn0TFRcK42HjdHF_fsIa8jtM1yw/o4rmdye/public/values?alt=json and the Google Sheets spreadsheet API v3 was deprecated -- see:

jywarren commented 2 years ago

For PurpleAir, the API is v1.8 now, not sure what it had been at the time the Cypress test was written, but the URL for markers is now:

https://map.purpleair.com/v1/sensors?token=8f2O5WHWva0Imrp7rEB2AmfHd41SMiFuCYStIXV52vk%2BBKHCpds8v0dGdXDyXNuwztL6jzbw6GDwX6vqk8DDtxIUSj8%2BsFjwGBLzK8T1q1p0pI%2BTTDw11mD3qFdzgIw2&fields=is_owner,name,location_type,latitude,longitude,altitude,last_seen,channel_state,channel_flags,confidence,primary_key_a,pm2.5_10minute&max_age=604800&nwlat=41.91210058954218&selat=41.73377525046183&nwlng=-71.59125291137713&selng=-71.23934708862353

vs the one we had:

https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=39.2173592639196&selat=38.47186888757717&nwlng=-77.65136718750001&selng=-76.24374389648439

jywarren commented 2 years ago

PurpleAir changed their API

support for changes to historical API here: https://community.purpleair.com/t/purpleair-data-migration-to-bigquery-and-a-new-api/295

They dropped the /data.json style calls a little before?: https://community.purpleair.com/t/discontinuation-of-the-json-and-data-json-urls/713/2

We had expected this format: https://github.com/publiclab/leaflet-environmental-layers/blob/main/cypress/fixtures/purpleMarker.json

But the new format is: https://map.purpleair.com/v1/sensors?token=8f2O5WHWva0Imrp7rEB2AmfHd41SMiFuCYStIXV52vk%2BBKHCpds8v0dGdXDyXNuwztL6jzbw6GDwX6vqk8DDtxIUSj8%2BsFjwGBLzK8T1q1p0pI%2BTTDw11mD3qFdzgIw2&fields=is_owner,name,location_type,latitude,longitude,altitude,last_seen,channel_state,channel_flags,confidence,primary_key_a,pm2.5_10minute&max_age=604800&nwlat=41.91210058954218&selat=41.73377525046183&nwlng=-71.59125291137713&selng=-71.23934708862353

Basically we need to begin using the new API:

jywarren commented 2 years ago

On the AQICN front, it's supposed to be checking data from this fixtures file, which we intercept via a spy: https://github.com/publiclab/leaflet-environmental-layers/blob/main/cypress/fixtures/aqicn.json

For whatever reason, the test is no longer properly finding the fixture data...?

https://github.com/publiclab/leaflet-environmental-layers/blob/main/cypress/integration/aqicn.spec.js

jywarren commented 2 years ago

Cypress has deprecated cy.server() and cy.route() in v6, but we're on v4... https://docs.cypress.io/api/commands/intercept https://docs.cypress.io/api/commands/server