-
Notifications
You must be signed in to change notification settings - Fork 53
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
Gql mock server #1071
Merged
Merged
Gql mock server #1071
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4289d2f
initial work on mocking graphql requests for percy
daniel-heppner-ibigroup 43d4e0a
more progress on making the graphql mock work
daniel-heppner-ibigroup e1d3596
get everything working for otp-rr desktop
daniel-heppner-ibigroup 242a60d
add to codespell ignore
daniel-heppner-ibigroup 71b8095
fix issue with mock server not runnign
daniel-heppner-ibigroup 818be90
re-add headless mode
daniel-heppner-ibigroup 1572b88
add percy mocks to codespell ignore
daniel-heppner-ibigroup fd9aac7
fix port issue on server
daniel-heppner-ibigroup 55970a2
fix percy tests on ci
miles-grant-ibigroup 9366ad3
fix weird date bug
daniel-heppner-ibigroup f594b86
fix stop ID issue for schedule viewer
daniel-heppner-ibigroup bebb0c0
fix alerts bug
daniel-heppner-ibigroup 4a84a7d
disable headful
daniel-heppner-ibigroup cb17d6b
add mock config to git
daniel-heppner-ibigroup 2ca5449
add documentation for GraphQL mocking and running the percy tests
daniel-heppner-ibigroup 2ba3c5b
fix spelling
daniel-heppner-ibigroup 9e44ede
address PR feedback
daniel-heppner-ibigroup b652b6b
remove unneeded config sections
daniel-heppner-ibigroup 856973b
remove email
daniel-heppner-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
const PlanResponseBike = require('./mocks/PlanResponseBike.json').data.plan | ||
const PlanResponseWalk = require('./mocks/PlanResponseWalk.json').data.plan | ||
const PlanResponseBusSubwayTram = | ||
require('./mocks/PlanResponseBusSubwayTram.json').data.plan | ||
const TripResponse = require('./mocks/TripResponse.json').data.trip | ||
const NearestResponse = require('./mocks/NearbyResponse.json').data.nearest | ||
const Stop114900Response = require('./mocks/Stop114900Response.json').data.stop | ||
const Stop803Response = require('./mocks/Stop803Response.json').data.stop | ||
const StopsByRadiusResponse = require('./mocks/StopsByRadiusResponse.json').data | ||
.stopsByRadius | ||
const ServiceTimeRangeResponse = | ||
require('./mocks/ServiceTimeRangeResponse.json').data.serviceTimeRange | ||
const RoutesResponse = require('./mocks/Routes.json').data.routes | ||
const IndividualRouteResponse = require('./mocks/IndividualRoute.json').data | ||
.route | ||
|
||
function getPlanResponseMock(transportModes) { | ||
const transportModesString = transportModes | ||
.map((tm) => tm.mode) | ||
.sort() | ||
.join('') | ||
switch (transportModesString) { | ||
case 'BICYCLEBUSSUBWAYTRAM': | ||
case 'BUSSUBWAY': | ||
return PlanResponseBusSubwayTram | ||
case 'BICYCLE': | ||
return PlanResponseBike | ||
case 'WALK': | ||
return PlanResponseWalk | ||
default: | ||
return PlanResponseBike | ||
} | ||
} | ||
|
||
function getStopResponseMock(stopId) { | ||
switch (stopId) { | ||
case 'MARTA:803': | ||
return Stop803Response | ||
case 'MARTA:114900': | ||
default: | ||
return Stop114900Response | ||
} | ||
} | ||
|
||
const increment = (obj, key) => (obj[key] ? obj[key]++ : (obj[key] = 0)) | ||
|
||
const mocks = (callCount) => ({ | ||
QueryType: { | ||
nearest() { | ||
increment(callCount, 'nearest') | ||
return NearestResponse | ||
}, | ||
plan(obj, { transportModes }) { | ||
increment(callCount, 'plan') | ||
return getPlanResponseMock(transportModes) | ||
}, | ||
route() { | ||
increment(callCount, 'route') | ||
return IndividualRouteResponse | ||
}, | ||
routes() { | ||
increment(callCount, 'routes') | ||
return RoutesResponse | ||
}, | ||
serviceTimeRange() { | ||
increment(callCount, 'serviceTimeRange') | ||
return ServiceTimeRangeResponse | ||
}, | ||
stop(obj, { id }) { | ||
increment(callCount, 'stop') | ||
return getStopResponseMock(id) | ||
}, | ||
stopsByRadius() { | ||
increment(callCount, 'stopsByRoute') | ||
return StopsByRadiusResponse | ||
}, | ||
trip() { | ||
increment(callCount, 'trip') | ||
return TripResponse | ||
} | ||
} | ||
}) | ||
module.exports = mocks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,125 @@ | ||
branding: HAR test | ||
title: test environment | ||
branding: HAR Test | ||
title: Percy Mock Config | ||
homeTimezone: America/New_York | ||
|
||
# Default OTP API | ||
api: | ||
host: http://localhost:9999 | ||
path: /test/otp/routers/default | ||
path: /otp2/routers/default | ||
v2: true | ||
|
||
# Enabled multimodal routing types (e.g. interary, profile) | ||
routingTypes: | ||
- key: ITINERARY | ||
text: Exact Time | ||
- key: BATCH | ||
text: Multiple Mode Combinations | ||
# Map config | ||
|
||
elevationProfile: true | ||
map: | ||
# Enabled map views | ||
views: | ||
- type: DEFAULT | ||
text: Map View | ||
# Default map center | ||
initLat: 29.7604 | ||
initLon: -95.3698 | ||
initZoom: 12 | ||
|
||
overlays: | ||
- type: bike-rental | ||
name: HOPR | ||
modes: | ||
- BICYCLE_RENT | ||
companies: | ||
- HOPR | ||
mapSymbols: | ||
- maxZoom: 12 | ||
minZoom: 0 | ||
type: circle | ||
pixels: 3 | ||
fillColor: "#FF2E28" | ||
dockStrokeColor: "#000000" | ||
- maxZoom: 15 | ||
minZoom: 13 | ||
type: circle | ||
pixels: 5 | ||
fillColor: "#FF2E28" | ||
dockStrokeColor: "#000000" | ||
- maxZoom: 20 | ||
minZoom: 16 | ||
fillColor: "#FF2E28" | ||
dockStrokeColor: "#000000" | ||
type: hubAndFloatingBike | ||
initLat: 33.7490 | ||
initLon: -84.3880 | ||
initZoom: 10 | ||
|
||
- type: park-and-ride | ||
name: Park & Ride Locations | ||
maxTransitDistance: 1000 | ||
geocoder: | ||
baseUrl: http://localhost:9977 | ||
focusPoint: | ||
lat: 33.7490 | ||
lon: -84.3880 | ||
boundary: | ||
rect: | ||
minLon: -86.0856 | ||
maxLon: -81.9499 | ||
minLat: 32.066 | ||
maxLat: 35.7251 | ||
maxNearbyStops: 6 | ||
options: | ||
headers: | ||
x-api-key: insert-your-geocoder-key | ||
type: PELIAS | ||
modes: | ||
modeButtons: | ||
- iconName: transit | ||
key: transit | ||
label: Transit | ||
modes: | ||
- CAR_PARK | ||
|
||
- type: stops | ||
name: Transit Stops | ||
visible: true | ||
- mode: TRANSIT | ||
- iconName: walk | ||
key: walk | ||
label: Walk | ||
modes: | ||
- mode: WALK | ||
- iconName: bicycle | ||
key: bike | ||
label: Bike | ||
modes: | ||
- mode: BICYCLE | ||
- iconName: car | ||
key: car | ||
label: Car | ||
modes: | ||
- mode: CAR | ||
initialState: | ||
enabledModeButtons: | ||
- walk | ||
- transit | ||
modeSettingDefinitions: | ||
- applicableMode: TRANSIT | ||
default: false | ||
key: wheelchair | ||
label: Use Accessible Routing | ||
type: CHECKBOX | ||
|
||
# A list of private transportation operators. These are either companies that | ||
# provide rental vehicles or transportation network companies. Companies that | ||
# have multiple modes of transport should have all modes listed as a string with | ||
# commas. For example: BICYCLE_RENT,MICROMOBILITY_RENT. | ||
companies: | ||
- id: HOPR | ||
label: HOPR | ||
modes: BICYCLE_RENT | ||
|
||
# Mode selector configuration | ||
modes: | ||
transitModes: | ||
- mode: BUS | ||
label: Bus | ||
- mode: TRAM | ||
label: Tram | ||
showWheelchairSetting: true | ||
- mode: SUBWAY | ||
label: Subway | ||
combinations: | ||
# Standard | ||
- mode: "WALK,TRANSIT" | ||
params: | ||
numItineraries: 2 | ||
showWheelchairSetting: true | ||
- mode: TRAM | ||
label: Atl. Streetcar | ||
showWheelchairSetting: true | ||
|
||
# access to transit modes. These options are all combined with the above | ||
# transit modes in the request to OTP | ||
accessModes: | ||
- mode: BICYCLE | ||
label: Transit + Personal bike | ||
- mode: BICYCLE_RENT | ||
label: Transit + BCycle | ||
company: HOPR | ||
- mode: CAR_PARK | ||
label: Park & Ride | ||
# which exclusive modes to show. This involves using a single mode and no | ||
# transit for the duration of the trip. Further configurations of | ||
# `bicycleModes`, `micromobilityModes` and/or `carModes` are needed as | ||
# desired, but no extra configuration is needed for a WALK exclusive mode. | ||
exclusiveModes: | ||
- WALK | ||
- BICYCLE | ||
label: Transit + Bikeshare | ||
- mode: SCOOTER | ||
label: Transit + eScooter rental | ||
|
||
bicycleModes: | ||
- mode: BICYCLE | ||
label: Own Bike | ||
iconWidth: 18 | ||
- mode: BICYCLE_RENT | ||
label: HOPR | ||
iconWidth: 36 | ||
itinerary: | ||
showHeaderText: false | ||
hideSkeletons: true | ||
customBatchUiBackground: true | ||
groupByMode: true | ||
groupTransitModes: true | ||
showFirstResultByDefault: false | ||
mergeItineraries: true | ||
|
||
dateTime: | ||
timeFormat: h:mm a | ||
dateFormat: MM/dd/yyyy | ||
stopViewer: | ||
nearbyRadius: 250 | ||
routeViewer: | ||
hideRouteShapesWithinFlexZones: true | ||
|
||
itinerary: | ||
mergeItineraries: true | ||
accessibilityScore: | ||
gradationMap: | ||
0.0: | ||
color: "#ffb5b9" | ||
icon: thumbs-down | ||
0.5: | ||
color: "#b5d1ff" | ||
icon: question-circle | ||
0.8: | ||
color: "#bfffb5" | ||
icon: thumbs-up | ||
1.0: | ||
color: "#a2e099" | ||
icon: thumbs-up | ||
|
||
defaultQueryParams: | ||
maxWalkDistance: 1207 # 3/4 miles in meters |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
env
needed before the env variables?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me. I think because this is a Bash command, it's okay. I am not sure about Windows.