Skip to content

Commit

Permalink
Street links modifications (#1091)
Browse files Browse the repository at this point in the history
* Allows for a more natural usage of rendering map children

* Add add-street-link modification

* add street link modifications

* Fix tests

* Remove modification containers

* Load opportunity data on page load

* Fix modify streets polygon saving

* Fix multiple polylines and polygons

* Ensure all new parameters are saved

* Ensure the FeatureGroup exists before using it's leaflet elements

* Update snapshots, fix tests

* Update more tests and snapshots

* Fix modification deletion

* Fix jest tests

* Update yarn.lock

* Update yarn.lock again

* Fix add trip pattern

* WebVitals Tracking (#1093)

* Track UI performance

* Add WebVitals tracking to App

* Add Bike LTS selector, refactor advanced settings (#1094)
  • Loading branch information
trevorgerhardt authored Jun 6, 2020
1 parent 1777dd8 commit 4c52d94
Show file tree
Hide file tree
Showing 106 changed files with 9,185 additions and 4,251 deletions.
2 changes: 1 addition & 1 deletion __mocks__/@fortawesome/free-solid-svg-icons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const I = require.requireActual('@fortawesome/free-solid-svg-icons')
const I = jest.requireActual('@fortawesome/free-solid-svg-icons')

/**
* Return just the name and not the entire SVG object. Throw an error if the
Expand Down
60 changes: 30 additions & 30 deletions __mocks__/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

import assign from 'lodash/assign'

const L = require.requireActual('leaflet')
const L = jest.requireActual('leaflet')
const LeafletMock = jest.genMockFromModule('leaflet')

class ControlMock extends LeafletMock.Control {
constructor (options) {
constructor(options) {
super()
this.options = {...L.Control.prototype.options, ...options}
}

getPosition () {
getPosition() {
return this.options.position
}

setPosition (position) {
setPosition(position) {
this.options.position = position
return this
}
}

const controlMock = options => new ControlMock(options)
const controlMock = (options) => new ControlMock(options)

class LayersControlMock extends ControlMock {
constructor (baseLayers = [], overlays = [], options) {
constructor(baseLayers = [], overlays = [], options) {
super(options)
this._layers = []

Expand All @@ -36,21 +36,21 @@ class LayersControlMock extends ControlMock {
})
}

_addLayer (layer, name, overlay) {
_addLayer(layer, name, overlay) {
this._layers.push({layer, name, overlay})
}

addBaseLayer (layer, name) {
addBaseLayer(layer, name) {
this._addLayer(layer, name)
return this
}

addOverlay (layer, name) {
addOverlay(layer, name) {
this._addLayer(layer, name, true)
return this
}

removeLayer (obj) {
removeLayer(obj) {
this._layers.splice(this._layers.indexOf(obj), 1)
}
}
Expand All @@ -61,7 +61,7 @@ controlMock.layers = (baseLayers, overlays, options) => {
}

class MapMock extends LeafletMock.Map {
constructor (id, options = {}) {
constructor(id, options = {}) {
super()
assign(this, L.Mixin.Events)

Expand All @@ -81,85 +81,85 @@ class MapMock extends LeafletMock.Map {
}
}

_limitZoom (zoom) {
_limitZoom(zoom) {
const min = this.getMinZoom()
const max = this.getMaxZoom()
return Math.max(min, Math.min(max, zoom))
}

_resetView (center, zoom) {
_resetView(center, zoom) {
this._initialCenter = center
this._zoom = zoom
}

fitBounds (bounds, options) {
fitBounds(bounds, options) {
this._bounds = bounds
this._boundsOptions = options
}

getBounds () {
getBounds() {
return this._bounds
}

getCenter () {
getCenter() {
return this._initialCenter
}

getMaxZoom () {
getMaxZoom() {
return this.options.maxZoom === undefined ? Infinity : this.options.maxZoom
}

getMinZoom () {
getMinZoom() {
return this.options.minZoom === undefined ? 0 : this.options.minZoom
}

getZoom () {
getZoom() {
return this._zoom
}

setMaxBounds (bounds) {
setMaxBounds(bounds) {
bounds = L.latLngBounds(bounds)
this.options.maxBounds = bounds
return this
}

setView (center, zoom) {
setView(center, zoom) {
zoom = zoom === undefined ? this.getZoom() : zoom
this._resetView(L.latLng(center), this._limitZoom(zoom))
return this
}

setZoom (zoom) {
setZoom(zoom) {
return this.setView(this.getCenter(), zoom)
}

project (point, zoom = 9) {
project(point, zoom = 9) {
return L.Map.prototype.project(point, zoom)
}

unproject (point, zoom = 9) {
unproject(point, zoom = 9) {
return L.Map.prototype.unproject(point, zoom)
}
}

class PopupMock extends LeafletMock.Popup {
constructor (options, source) {
constructor(options, source) {
super()
assign(this, L.Mixin.Events)

this.options = {...L.Popup.prototype.options, ...options}
this._source = source
}

getContent () {
getContent() {
return this._content
}

setContent (content) {
setContent(content) {
this._content = content
}

bindPopup () {}
bindPopup() {}
}

module.exports = {
Expand All @@ -170,10 +170,10 @@ module.exports = {
latLng: L.latLng,
LatLngBounds: L.LatLngBounds,
latLngBounds: L.latLngBounds,
geoJson (data, props) {
geoJson(data, props) {
return {
data,
getLayers () {
getLayers() {
return []
},
props
Expand Down
5 changes: 5 additions & 0 deletions __mocks__/next/dynamic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function dynamic() {
return function DynamicMockedComponent() {
return null
}
}
2 changes: 1 addition & 1 deletion __mocks__/uuid.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const uuid = require.requireActual('uuid')
const uuid = jest.requireActual('uuid')

module.exports = {
...uuid,
Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = {
},
// Add the current working directory to the path to allow absolute imports from /lib
modulePaths: ['.'],
notify: true,
setupFiles: ['./lib/utils/enzyme'],
notify: false,
setupFiles: ['./jest/enzyme', './jest/fetch'],
snapshotSerializers: [
'./lib/utils/geojson-snapshot-serializer',
'./jest/geojson-snapshot-serializer',
'enzyme-to-json/serializer'
],
testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/']
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions jest/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('whatwg-fetch')
File renamed without changes.
5 changes: 5 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"baseUrl": "."
}
}
2 changes: 1 addition & 1 deletion lib/actions/analysis/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('actions > analysis', () => {
await store.dispatch(analysis.fetchTravelTimeSurface())

const actions = store.getActions()
expect(actions).toHaveLength(10)
expect(actions).toHaveLength(5)
expect(actions[0].type).toBe('set isochrone fetch status')
expect(actions[1].type).toBe('set profile request')
})
Expand Down
5 changes: 1 addition & 4 deletions lib/actions/fetch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import isObject from 'lodash/isObject'

import fetch from 'lib/utils/fetch'
import {timer} from 'lib/utils/metric'

import {getUser} from '../user'
Expand Down Expand Up @@ -316,9 +315,7 @@ function createResponse(res) {
}

async function deserialize(res) {
const header = `${res.headers.get('Content-Type')} ${res.headers.get(
'Content'
)}`
const header = res.headers.get('Content-Type') || res.headers.get('Content')
if (header.indexOf('json') > -1) return res.json()
if (header.indexOf('octet-stream') > -1) return res.arrayBuffer()
if (header.indexOf('text') > -1) return res.text()
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/get-feeds-routes-and-stops.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
REMOVE_STOPS,
REMOVE_TRIPS,
REROUTE
} from 'lib/constants'
import * as query from 'lib/graphql/query'
} from '../constants'
import * as query from '../graphql/query'

import {setFeeds} from './'
import fetch from './fetch'
Expand Down
8 changes: 4 additions & 4 deletions lib/components/__tests__/__snapshots__/create-region.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`create-region.render 1`] = `
}
}
>
<Stack
<ForwardRef
as="form"
p={4}
spacing={4}
Expand Down Expand Up @@ -383,7 +383,7 @@ exports[`create-region.render 1`] = `
mb={4}
onChange={[Function]}
>
<Stack
<ForwardRef
mb={4}
spacing={4}
>
Expand Down Expand Up @@ -1235,7 +1235,7 @@ exports[`create-region.render 1`] = `
</div>
</Box>
</Flex>
</Stack>
</ForwardRef>
</EditBoundsForm>
<Button
block={true}
Expand Down Expand Up @@ -1360,7 +1360,7 @@ exports[`create-region.render 1`] = `
</form>
</Box>
</Flex>
</Stack>
</ForwardRef>
</div>
</InnerDock>
</CreateRegion>
Expand Down
16 changes: 4 additions & 12 deletions lib/components/__tests__/__snapshots__/edit-bundle.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Component EditBundle snapshot(mount) 1`] = `
<EditBundle
bundleProjects={Array []}
>
<Stack
<ForwardRef
spacing={8}
>
<Flex
Expand Down Expand Up @@ -80,7 +80,7 @@ exports[`Component EditBundle snapshot(mount) 1`] = `
]
}
>
<ForwardRef(LoadableComponent)
<DynamicMockedComponent
getOptionLabel={[Function]}
getOptionValue={[Function]}
onChange={[Function]}
Expand Down Expand Up @@ -113,15 +113,7 @@ exports[`Component EditBundle snapshot(mount) 1`] = `
"option": [Function],
}
}
>
<loading
error={null}
isLoading={true}
pastDelay={false}
retry={[Function]}
timedOut={false}
/>
</ForwardRef(LoadableComponent)>
/>
</S>
</div>
</Box>
Expand All @@ -131,6 +123,6 @@ exports[`Component EditBundle snapshot(mount) 1`] = `
</div>
</Box>
</Flex>
</Stack>
</ForwardRef>
</EditBundle>
`;
9 changes: 5 additions & 4 deletions lib/components/__tests__/__snapshots__/edit-region.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ exports[`Component > EditRegion 1`] = `
}
router={
Router {
"_bps": undefined,
"_getServerData": [Function],
"_getStaticData": [Function],
"_wrapApp": undefined,
Expand Down Expand Up @@ -107,7 +108,7 @@ exports[`Component > EditRegion 1`] = `
}
}
>
<Stack
<ForwardRef
p={4}
spacing={4}
>
Expand Down Expand Up @@ -408,7 +409,7 @@ exports[`Component > EditRegion 1`] = `
mb={4}
onChange={[Function]}
>
<Stack
<ForwardRef
mb={4}
spacing={4}
>
Expand Down Expand Up @@ -1260,7 +1261,7 @@ exports[`Component > EditRegion 1`] = `
</div>
</Box>
</Flex>
</Stack>
</ForwardRef>
</EditBoundsForm>
<Button
block={true}
Expand Down Expand Up @@ -1483,7 +1484,7 @@ exports[`Component > EditRegion 1`] = `
</div>
</Box>
</Flex>
</Stack>
</ForwardRef>
</div>
</InnerDock>
</EditRegion>
Expand Down
Loading

0 comments on commit 4c52d94

Please sign in to comment.