Skip to content

Commit 7e467ef

Browse files
author
David Emory
authored
Merge pull request #41 from opentripplanner/dev
New release
2 parents 102b94e + 18734e5 commit 7e467ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+6590
-2149
lines changed

Diff for: .gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ensure that branch-specific package.json does not change on merge
2+
package.json merge=ours

Diff for: .travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ notifications:
55
email: false
66
node_js:
77
- '6'
8+
before_install:
9+
- npm i -g yarn codecov
810
after_success:
911
- yarn run semantic-release
1012
before_script:

Diff for: __tests__/actions/__snapshots__/api.js.snap

+19-46
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,50 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`actions > api > planTrip should gracefully handle bad response 1`] = `
4-
Array [
5-
Array [
6-
Object {
7-
"type": "PLAN_REQUEST",
8-
},
9-
],
10-
Array [
11-
Object {
12-
"error": true,
13-
"payload": [Error: Received error from server],
14-
"type": "PLAN_ERROR",
15-
},
16-
],
17-
]
18-
`;
3+
exports[`OTP Query Path 1`] = `"/api/plan?fromPlace=12%2C34&toPlace=34%2C12"`;
194

20-
exports[`actions > api > planTrip should make a query to OTP with customOtpQueryBuilder in state config 1`] = `"/api/plan?from=here&to=there"`;
21-
22-
exports[`actions > api > planTrip should make a query to OTP with customOtpQueryBuilder in state config 2`] = `
5+
exports[`actions > api > routingQuery should gracefully handle bad response 1`] = `
236
Array [
24-
Array [
25-
Object {
26-
"type": "PLAN_REQUEST",
27-
},
28-
],
297
Array [
308
Object {
319
"payload": Object {
32-
"fake": "response",
10+
"routingType": "ITINERARY",
11+
"searchId": 2,
3312
},
34-
"type": "PLAN_RESPONSE",
35-
},
36-
],
37-
]
38-
`;
39-
40-
exports[`actions > api > planTrip should make a query to OTP with customOtpQueryBuilder sent to action 1`] = `"/api/plan?from=here&to=there"`;
41-
42-
exports[`actions > api > planTrip should make a query to OTP with customOtpQueryBuilder sent to action 2`] = `
43-
Array [
44-
Array [
45-
Object {
46-
"type": "PLAN_REQUEST",
13+
"type": "ROUTING_REQUEST",
4714
},
4815
],
4916
Array [
5017
Object {
5118
"payload": Object {
52-
"fake": "response",
19+
"error": [Error: Received error from server],
20+
"searchId": 2,
5321
},
54-
"type": "PLAN_RESPONSE",
22+
"type": "ROUTING_ERROR",
5523
},
5624
],
5725
]
5826
`;
5927

60-
exports[`actions > api > planTrip should make a query to OTP with default settings 1`] = `"/api/plan?arriveBy=false&fromPlace=12%2C34&showIntermediateStops=true&toPlace=34%2C12"`;
61-
62-
exports[`actions > api > planTrip should make a query to OTP with default settings 2`] = `
28+
exports[`actions > api > routingQuery should make a query to OTP 1`] = `
6329
Array [
6430
Array [
6531
Object {
66-
"type": "PLAN_REQUEST",
32+
"payload": Object {
33+
"routingType": "ITINERARY",
34+
"searchId": 1,
35+
},
36+
"type": "ROUTING_REQUEST",
6737
},
6838
],
6939
Array [
7040
Object {
7141
"payload": Object {
72-
"fake": "response",
42+
"response": Object {
43+
"fake": "response",
44+
},
45+
"searchId": 1,
7346
},
74-
"type": "PLAN_RESPONSE",
47+
"type": "ROUTING_RESPONSE",
7548
},
7649
],
7750
]

Diff for: __tests__/actions/api.js

+22-57
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import nock from 'nock'
44

55
import {timeoutPromise} from '../test-utils'
66

7-
import {planTrip} from '../../lib/actions/api'
7+
import {routingQuery} from '../../lib/actions/api'
88

99
describe('actions > api', () => {
10-
describe('> planTrip', () => {
10+
describe('> routingQuery', () => {
1111
const defaultState = {
1212
otp: {
1313
config: {
@@ -19,73 +19,38 @@ describe('actions > api', () => {
1919
},
2020
currentQuery: {
2121
from: { lat: 12, lon: 34 },
22+
routingType: 'ITINERARY',
2223
to: { lat: 34, lon: 12 }
2324
},
2425
searches: []
2526
}
2627
}
2728

28-
const customOtpQueryBuilder = () => {
29-
return `http://mock-host.com/api/plan?from=here&to=there`
30-
}
31-
32-
const stateWithCustomBuilderFunction = {
33-
otp: {
34-
config: {
35-
api: {
36-
host: 'http://mock-host.com',
37-
path: '/api',
38-
port: 80
39-
},
40-
customOtpQueryBuilder
41-
},
42-
currentQuery: {
43-
from: { lat: 12, lon: 34 },
44-
to: { lat: 34, lon: 12 }
45-
},
46-
searches: []
47-
}
48-
}
29+
it('should make a query to OTP', async () => {
30+
const routingQueryAction = routingQuery()
4931

50-
const testCases = [{
51-
state: defaultState,
52-
title: 'default settings'
53-
}, {
54-
customOtpQueryBuilder,
55-
state: defaultState,
56-
title: 'customOtpQueryBuilder sent to action'
57-
}, {
58-
state: stateWithCustomBuilderFunction,
59-
title: 'customOtpQueryBuilder in state config'
60-
}]
61-
62-
testCases.forEach((testCase) => {
63-
it(`should make a query to OTP with ${testCase.title}`, async () => {
64-
const planTripAction = planTrip(testCase.customOtpQueryBuilder)
65-
66-
nock('http://mock-host.com')
67-
.get(/api\/plan/)
68-
.reply(200, {
69-
fake: 'response'
70-
})
71-
.on('request', (req, interceptor) => {
72-
expect(req.path).toMatchSnapshot()
73-
})
74-
75-
const mockDispatch = jest.fn()
76-
planTripAction(mockDispatch, () => {
77-
return testCase.state
32+
nock('http://mock-host.com')
33+
.get(/api\/plan/)
34+
.reply(200, {
35+
fake: 'response'
36+
})
37+
.on('request', (req, interceptor) => {
38+
expect(req.path).toMatchSnapshot('OTP Query Path')
7839
})
7940

80-
// wait for request to complete
81-
await timeoutPromise(100)
82-
83-
expect(mockDispatch.mock.calls).toMatchSnapshot()
41+
const mockDispatch = jest.fn()
42+
routingQueryAction(mockDispatch, () => {
43+
return defaultState
8444
})
45+
46+
// wait for request to complete
47+
await timeoutPromise(100)
48+
49+
expect(mockDispatch.mock.calls).toMatchSnapshot()
8550
})
8651

8752
it('should gracefully handle bad response', async () => {
88-
const planTripAction = planTrip()
53+
const routingQueryAction = routingQuery()
8954

9055
nock('http://mock-host.com')
9156
.get(/api\/plan/)
@@ -94,7 +59,7 @@ describe('actions > api', () => {
9459
})
9560

9661
const mockDispatch = jest.fn()
97-
planTripAction(mockDispatch, () => {
62+
routingQueryAction(mockDispatch, () => {
9863
return defaultState
9964
})
10065

Diff for: __tests__/util/__snapshots__/state.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ Object {
1010
"name": "12.00000, 34.00000",
1111
},
1212
"mode": undefined,
13+
"routingType": "ITINERARY",
1314
"time": "12:34",
1415
"to": Object {
1516
"lat": "34",
1617
"lon": "12",
1718
"name": "34.00000, 12.00000",
1819
},
19-
"type": "ITINERARY",
2020
}
2121
`;

Diff for: cpbuild.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
echo 'rebuilding..'
2+
yarn prepublish
3+
echo 'copying built js..'
4+
cp -r ./build ~/dev/otp/trimet-mod-otp/node_modules/otp-react-redux
5+
echo 'done'

Diff for: cpcss.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
echo "building and copying css.."
2+
mastarm build
3+
cp ~/dev/otp/otp-react-redux/dist/index.css* ~/dev/otp/trimet-mod-otp/node_modules/otp-react-redux/dist/
4+
echo "done"
5+

Diff for: example-config.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ geocoder:
2222
minLat: 45.273
2323
maxLat: 45.7445
2424
MAPZEN_KEY: MAPZEN_KEY
25+
focusPoint:
26+
lat: 45.5223452
27+
lon: -122.6821804
28+
# Optional custom Pelias instance (defaults to Mapzen Search)
29+
# baseUrl: https://geocoder.example.com/pelias/v1
2530

26-
modes:
27-
- TRANSIT,WALK
31+
modeGroups:
32+
- name: Transit
33+
modes:
34+
- TRAM
35+
- BUS
36+
- name: Walk/Bike
37+
modes:
38+
- WALK
39+
- BICYCLE

Diff for: example.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.row {
1+
.main-row {
22
position: fixed;
33
top: 52px;
44
bottom: 0px;
@@ -18,3 +18,7 @@
1818
margin: 0px;
1919
padding: 0px;
2020
}
21+
22+
.date-time-selector {
23+
margin-top: 20px;
24+
}

Diff for: example.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ import { Navbar, Grid, Row, Col } from 'react-bootstrap'
1111

1212
// import OTP-RR components
1313
import {
14+
BaseLayers,
15+
BaseMap,
16+
BikeRentalOverlay,
17+
DateTimeSelector,
1418
EndpointsOverlay,
15-
ItineraryCarousel,
19+
ErrorMessage,
1620
ItineraryOverlay,
1721
LocationField,
18-
ModeSelector,
19-
DateTimeSelector,
20-
// NarrativeItineraries,
21-
BaseMap,
22-
BaseLayers,
23-
// OsmBaseLayer,
22+
NarrativeItineraries,
2423
PlanTripButton,
25-
createOtpReducer,
26-
ErrorMessage,
27-
SwitchButton
24+
TransitiveOverlay,
25+
SettingsSelectorPanel,
26+
SwitchButton,
27+
28+
createOtpReducer
2829
} from './lib'
2930

3031
// load the OTP configuration
@@ -61,23 +62,24 @@ class OtpRRExample extends Component {
6162
<Navbar.Brand>OpenTripPlanner</Navbar.Brand>
6263
</Navbar>
6364
<Grid fluid>
64-
<Row>
65+
<Row className='main-row'>
6566
<Col xs={12} md={4} className='sidebar'>
6667
<LocationField type='from' label='Enter start location or click on map...' />
6768
<LocationField type='to' label='Enter destination or click on map...' />
6869
<SwitchButton />
69-
<ModeSelector />
7070
<DateTimeSelector />
71+
<SettingsSelectorPanel />
7172
<ErrorMessage />
7273
<PlanTripButton />
73-
{/* <NarrativeItineraries /> */}
74-
<ItineraryCarousel />
74+
<NarrativeItineraries />
7575
</Col>
7676

7777
<Col xsHidden md={8} className='map-container'>
7878
<BaseMap>
7979
<BaseLayers />
80+
<BikeRentalOverlay />
8081
<ItineraryOverlay />
82+
<TransitiveOverlay />
8183
<EndpointsOverlay />
8284
</BaseMap>
8385
</Col>

0 commit comments

Comments
 (0)