diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644
index 000000000..7db9fe427
--- /dev/null
+++ b/.github/workflows/tests.yml
@@ -0,0 +1,60 @@
+name: tests
+on: [pull_request]
+jobs:
+ jasmine-tests:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: '10'
+ check-latest: true
+ - name: Cache node modules
+ uses: actions/cache@v2
+ env:
+ cache-name: cache-node-modules
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-build-${{ env.cache-name }}-
+ ${{ runner.os }}-build-
+ ${{ runner.os }}-
+ - name: Install Dependencies
+ run: npm install
+ - name: "Build dist files"
+ run: grunt build
+ - name: "Transpile"
+ run: grunt transpile
+ - name: "Run tests"
+ run: grunt jasmine
+
+ cypress-tests:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup node
+ uses: actions/setup-node@v2
+ with:
+ node-version: '10'
+ check-latest: true
+ - name: Cache node modules
+ uses: actions/cache@v2
+ env:
+ cache-name: cache-node-modules
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
+ restore-keys: |
+ ${{ runner.os }}-build-${{ env.cache-name }}-
+ ${{ runner.os }}-build-
+ ${{ runner.os }}-
+ - name: Install Dependencies
+ run: npm install
+ - name: "Build dist files"
+ run: grunt build
+ - name: "Transpile"
+ run: grunt transpile
+ - name: "Run Cypress tests"
+ run: npm run start:ci & npm run cy:run:chrome
diff --git a/cypress.json b/cypress.json
index 80cd6a934..268107b1c 100644
--- a/cypress.json
+++ b/cypress.json
@@ -1,4 +1,5 @@
{
"baseUrl": "http://localhost:8080",
- "modifyObstructiveCode": false
-}
\ No newline at end of file
+ "modifyObstructiveCode": false,
+ "chromeWebSecurity": false
+}
diff --git a/cypress/integration/purpleAirMarker.spec.js b/cypress/integration/purpleAirMarker.spec.js
index 6cb452a2b..45f67515a 100644
--- a/cypress/integration/purpleAirMarker.spec.js
+++ b/cypress/integration/purpleAirMarker.spec.js
@@ -26,7 +26,9 @@ describe('Purple layer - markers', function() {
it('has circle markers in minimal mode', function() {
cy.server()
- cy.route('GET', 'https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001', 'fixture:purpleMarker.json')
+ cy.route('GET',
+ 'https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001',
+ 'fixture:purpleMarker.json')
const spy = cy.spy(window.top.aut.PurpleAirMarkerLayer, 'requestData')
cy.get('[title="Show minimal markers"]').click().then(() => {
expect(spy).to.be.called
@@ -52,4 +54,4 @@ describe('Purple layer - markers', function() {
cy.get('.leaflet-marker-pane img').should('have.length', 0)
cy.get('.leaflet-overlay-pane svg g').children().should('have.length', 0)
})
-})
\ No newline at end of file
+})
diff --git a/cypress/integration/skytruth.spec.js b/cypress/integration/skytruth.spec.js
index 1fa9d0bda..bc146d4b6 100644
--- a/cypress/integration/skytruth.spec.js
+++ b/cypress/integration/skytruth.spec.js
@@ -3,13 +3,14 @@ describe('Skytruth layer', function() {
cy.openWindow('/example/index.html#lat=41.6283&lon=-91.7235&zoom=10&layers=Standard')
cy.wait(300)
cy.window().then((win) => {
+ cy.get('.leaflet-overlay-pane').children().should('have.length', 0)
cy.fixture('skytruth').then((data) => {
cy.stub(win.SkyTruth, 'requestData', function() {
win.SkyTruth.parseData(data);
})
})
cy.get('#map-menu-skytruth label').click({ force: true })
- cy.get('.leaflet-marker-pane').children().should('have.length', 2)
+ cy.get('.leaflet-overlay-pane').children().should('have.length', 1)
})
})
@@ -18,8 +19,7 @@ describe('Skytruth layer', function() {
})
it('has default markers in default mode', function() {
- cy.get('.leaflet-marker-pane img').invoke('attr', 'src').should('eq', 'https://www.clker.com/cliparts/T/G/b/7/r/A/red-dot.svg')
- cy.get('.leaflet-marker-pane img[src="https://www.clker.com/cliparts/T/G/b/7/r/A/red-dot.svg"]').should('have.length', 2)
+ cy.get('.leaflet-overlay-pane svg').should('have.length', 1)
})
it('has circle markers in minimal mode', function() {
diff --git a/src/layercode.js b/src/layercode.js
index 6a6d94b2b..bfc964ad7 100644
--- a/src/layercode.js
+++ b/src/layercode.js
@@ -309,13 +309,15 @@ L.LayerGroup.LayerCode = L.LayerGroup.extend(
if (this.layer == 'purpleairmarker')
{
var redDotIcon =new L.icon.purpleAirMarkerIcon();
- var lat = data[25];
- var lng = data[26];
+ // ref https://www.purpleair.com/data.json?fetchData=true&minimize=true&sensorsActive2=10080&orderby=L&nwlat=45.67548217560647&selat=41.79179268262892&nwlng=-101.03576660156251&selng=-93.93310546875001
+ // ["ID","pm","pm_cf_1","pm_atm","age","pm_0","pm_1","pm_2","pm_3","pm_4","pm_5","pm_6","conf","pm1","pm_10","p1","p2","p3","p4","p5","p6","Humidity","Temperature","Pressure","Elevation","Type","Label","Lat","Lon","Icon","isOwner","Flags","Voc","Ozone1","Adc","CH"],
+ var lat = data[27];
+ var lng = data[28];
var value = parseFloat(data[16]);
- var Label = data[24];
- var temp_f = data[21];
- var humidity = data[20];
- var pressure = data[22];
+ var Label = data[26];
+ var temp_f = data[22];
+ var humidity = data[21];
+ var pressure = data[23];
var defaultMarker = L.marker([lat, lng], {icon: redDotIcon});
var minimalMarker = L.circleMarker(L.latLng([lat, lng]), { radius: 5, weight: 1, fillOpacity: 1, color: '#7c7c7c', fillColor: '#7c22b5' });
var content = 'Label : ' + Label + '
PM2.5 Value : ' + value +'
Lat: ' + lat + '
Lon: ' + lng + '
Temp (F) : '+temp_f+'
Humidity : ' + humidity + '
Pressure : ' + pressure +'
Data provided by www.purpleair.com';