Skip to content

Commit

Permalink
add percy snapshot for error display
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhep committed Feb 5, 2025
1 parent fe85539 commit 2a690b5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
5 changes: 4 additions & 1 deletion percy/graphql-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const ServiceTimeRangeResponse =
const RoutesResponse = require('./mocks/Routes.json').data.routes
const IndividualRouteResponse = require('./mocks/IndividualRoute.json').data
.route

const PlanResponseBlank = require('./mocks/PlanResponseBlank.json').data.plan
function getPlanResponseMock(transportModes) {
const transportModesString = transportModes
.map((tm) => tm.mode)
Expand All @@ -29,6 +29,9 @@ function getPlanResponseMock(transportModes) {
return PlanResponseBike
case 'WALK':
return PlanResponseWalk
case 'BUSSUBWAYTRAM':
case 'BUSCARSUBWAYTRAM':
return PlanResponseBlank
default:
return PlanResponseBike
}
Expand Down
34 changes: 34 additions & 0 deletions percy/mocks/PlanResponseBlank.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"errors": [
{
"message": "Exception while fetching data (/plan/itineraries[0]/legs[0]/steps[6]/alerts[0]/alertDescriptionText) : Cannot invoke \"org.opentripplanner.framework.i18n.I18NString.toString(java.util.Locale)\" because the return value of \"org.opentripplanner.routing.alertpatch.TransitAlert.descriptionText()\" is null",
"locations": [
{
"line": 151,
"column": 13
}
],
"path": [
"plan",
"itineraries",
0,
"legs",
0,
"steps",
6,
"alerts",
0,
"alertDescriptionText"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": {
"plan": {
"itineraries": [],
"routingErrors": []
}
}
}
12 changes: 12 additions & 0 deletions percy/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,21 @@ async function executeTest(page, isMobile, isCallTaker) {
// Make sure that the main UI (incl. map controls) has loaded.
await page.waitForSelector('.maplibregl-ctrl-zoom-in')

await page.goto(
`http://localhost:${MOCK_SERVER_PORT}/#/?ui_activeSearch=fg33svlbf&ui_activeItinerary=-1&fromPlace=TestLocation%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A34.78946214120528%2C-86.37663414886111&toPlace=1%20TestLocation2%20Avenue%20NE%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A35.767060728439574%2C-86.35749390533111&date=2023-08-09&time=17%3A56&arriveBy=false&mode=BICYCLE&walkSpeed=1.34&numItineraries=3&modeButtons=car_transit`
)
// FIXME: Network idle condition seems never met after navigating to above link.
// await page.waitForNavigation({ waitUntil: 'networkidle2' })
await page.waitForTimeout(4000)
await page.waitForSelector('.options')
await percySnapshotWithWait(page, 'With error message displayed')
// Load itinerary from URL
// Triggers mock.har graphql query #1 and #2 (bike-only query, twice).
// FIXME: Opening a url with non-default mode params triggers the plan query twice.
await page.goto(
`http://localhost:${MOCK_SERVER_PORT}/#/?ui_activeSearch=fg33svlbf&ui_activeItinerary=-1&fromPlace=South%20Prado%20Northeast%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A33.78946214120528%2C-84.37663414886111&toPlace=1%20Copenhill%20Avenue%20NE%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A33.767060728439574%2C-84.35749390533111&date=2023-08-09&time=17%3A56&arriveBy=false&mode=BICYCLE&walkSpeed=1.34&numItineraries=3&modeButtons=walk_bike`
)
await page.click('#plan-trip')
// FIXME: Network idle condition seems never met after navigating to above link.
// await page.waitForNavigation({ waitUntil: 'networkidle2' })
await page.waitForTimeout(4000)
Expand Down Expand Up @@ -228,6 +237,9 @@ async function executeTest(page, isMobile, isCallTaker) {

// take screenshot
await percySnapshotWithWait(page, 'Call Taker With Settings Adjusted')
await page.goto(
`http://localhost:${MOCK_SERVER_PORT}/#/?ui_activeSearch=fg33svlbf&ui_activeItinerary=-1&fromPlace=South%20Prado%20Northeast%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A33.78946214120528%2C-84.37663414886111&toPlace=1%20Copenhill%20Avenue%20NE%2C%20Atlanta%2C%20GA%2C%20USA%3A%3A33.767060728439574%2C-84.35749390533111&date=2023-08-09&time=17%3A56&arriveBy=false&mode=BICYCLE&walkSpeed=1.34&numItineraries=3&modeButtons=walk_bike`
)

// Other steps are identical to desktop, so we end here to not waste screenshots.
return
Expand Down

0 comments on commit 2a690b5

Please sign in to comment.