Skip to content

Commit d62e430

Browse files
Merge pull request #722 from opentripplanner/percy-fix-annoyances
Percy Fix Annoyances
2 parents 07e5171 + 8571aef commit d62e430

File tree

12 files changed

+275
-263
lines changed

12 files changed

+275
-263
lines changed

Diff for: __tests__/actions/api.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@
22

33
import nock from 'nock'
44

5+
import '../test-utils/mock-window-url'
56
import * as api from '../../lib/actions/api'
67

78
// Use mocked randId function and pass in searchId for routingQuery calls so that
89
// snapshots are deterministic (i.e., the random IDs don't change).
910
let idCounter = 1234
1011
const randId = () => `abcd${idCounter++}`
1112

13+
/**
14+
* Sets the requestId values as needed to deterministic IDs.
15+
*/
16+
function setMockRequestIds(calls) {
17+
calls.forEach((call) => {
18+
call.forEach((action) => {
19+
if (action.payload && action.payload.requestId) {
20+
action.payload.requestId = randId()
21+
}
22+
})
23+
})
24+
}
25+
1226
describe('actions > api', () => {
1327
describe('routingQuery', () => {
1428
const defaultState = {
@@ -64,16 +78,3 @@ describe('actions > api', () => {
6478
})
6579
})
6680
})
67-
68-
/**
69-
* Sets the requestId values as needed to deterministic IDs.
70-
*/
71-
function setMockRequestIds (calls) {
72-
calls.forEach(call => {
73-
call.forEach(action => {
74-
if (action.payload && action.payload.requestId) {
75-
action.payload.requestId = randId()
76-
}
77-
})
78-
})
79-
}

Diff for: __tests__/components/viewers/__snapshots__/stop-viewer.js.snap

+30-30
Large diffs are not rendered by default.

Diff for: __tests__/components/viewers/stop-viewer.js

+31-37
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
import '../../test-utils/mock-window-url'
2+
import {
3+
getMockInitialState,
4+
mockWithProvider
5+
} from '../../test-utils/mock-data/store'
6+
import {
7+
restoreDateNowBehavior,
8+
setDefaultTestTime,
9+
setTestTime
10+
} from '../../test-utils'
111
import StopViewer from '../../../lib/components/viewers/stop-viewer'
2-
import { restoreDateNowBehavior, setDefaultTestTime, setTestTime } from '../../test-utils'
3-
import { getMockInitialState, mockWithProvider } from '../../test-utils/mock-data/store'
412

513
describe('components > viewers > stop viewer', () => {
614
afterEach(restoreDateNowBehavior)
@@ -13,41 +21,33 @@ describe('components > viewers > stop viewer', () => {
1321
}
1422

1523
expect(
16-
mockWithProvider(
17-
StopViewer,
18-
{},
19-
mockState
20-
).snapshot()
24+
mockWithProvider(StopViewer, {}, mockState).snapshot()
2125
).toMatchSnapshot()
2226
})
2327

2428
it('should render with OTP transit index data', () => {
2529
const mockState = getMockInitialState()
2630
const stopId = 'TriMet:715'
2731
mockState.otp.ui.viewedStop = { stopId }
28-
mockState.otp.transitIndex.stops[stopId] = require('./mock-otp-transit-index-data.json')
32+
mockState.otp.transitIndex.stops[
33+
stopId
34+
] = require('./mock-otp-transit-index-data.json')
2935

3036
expect(
31-
mockWithProvider(
32-
StopViewer,
33-
{},
34-
mockState
35-
).snapshot()
37+
mockWithProvider(StopViewer, {}, mockState).snapshot()
3638
).toMatchSnapshot()
3739
})
3840

3941
it('should render times after midnight with the correct day of week', () => {
4042
const mockState = getMockInitialState()
4143
const stopId = 'TriMet:9860'
4244
mockState.otp.ui.viewedStop = { stopId }
43-
mockState.otp.transitIndex.stops[stopId] = require('./mock-otp-transit-index-data-stop-9860.json')
45+
mockState.otp.transitIndex.stops[
46+
stopId
47+
] = require('./mock-otp-transit-index-data-stop-9860.json')
4448

4549
expect(
46-
mockWithProvider(
47-
StopViewer,
48-
{},
49-
mockState
50-
).snapshot()
50+
mockWithProvider(StopViewer, {}, mockState).snapshot()
5151
).toMatchSnapshot()
5252
})
5353

@@ -58,14 +58,12 @@ describe('components > viewers > stop viewer', () => {
5858
const mockState = getMockInitialState()
5959
const stopId = 'TriMet:9860'
6060
mockState.otp.ui.viewedStop = { stopId }
61-
mockState.otp.transitIndex.stops[stopId] = require('./mock-otp-transit-index-data-stop-9860.json')
61+
mockState.otp.transitIndex.stops[
62+
stopId
63+
] = require('./mock-otp-transit-index-data-stop-9860.json')
6264

6365
expect(
64-
mockWithProvider(
65-
StopViewer,
66-
{},
67-
mockState
68-
).snapshot()
66+
mockWithProvider(StopViewer, {}, mockState).snapshot()
6967
).toMatchSnapshot()
7068
})
7169

@@ -78,14 +76,12 @@ describe('components > viewers > stop viewer', () => {
7876
const mockState = getMockInitialState()
7977
const stopId = 'TriMet:9860'
8078
mockState.otp.ui.viewedStop = { stopId }
81-
mockState.otp.transitIndex.stops[stopId] = require('./mock-otp-transit-index-data-stop-9860-48-hr.json')
79+
mockState.otp.transitIndex.stops[
80+
stopId
81+
] = require('./mock-otp-transit-index-data-stop-9860-48-hr.json')
8282

8383
expect(
84-
mockWithProvider(
85-
StopViewer,
86-
{},
87-
mockState
88-
).snapshot()
84+
mockWithProvider(StopViewer, {}, mockState).snapshot()
8985
).toMatchSnapshot()
9086
})
9187

@@ -94,14 +90,12 @@ describe('components > viewers > stop viewer', () => {
9490
mockState.otp.ui.viewedStop = {
9591
stopId: 'TriMet:715'
9692
}
97-
mockState.otp.transitIndex.stops['TriMet:715'] = require('./mock-trimet-transit-index-data.json')
93+
mockState.otp.transitIndex.stops[
94+
'TriMet:715'
95+
] = require('./mock-trimet-transit-index-data.json')
9896

9997
expect(
100-
mockWithProvider(
101-
StopViewer,
102-
{},
103-
mockState
104-
).snapshot()
98+
mockWithProvider(StopViewer, {}, mockState).snapshot()
10599
).toMatchSnapshot()
106100
})
107101
})

Diff for: __tests__/reducers/create-otp-reducer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import {getInitialState} from '../../lib/reducers/create-otp-reducer'
2-
import {restoreDateNowBehavior, setDefaultTestTime} from '../test-utils'
1+
import '../test-utils/mock-window-url'
2+
import { getInitialState } from '../../lib/reducers/create-otp-reducer'
3+
import { restoreDateNowBehavior, setDefaultTestTime } from '../test-utils'
34

45
describe('lib > reducers > create-otp-reducer', () => {
56
afterEach(restoreDateNowBehavior)

Diff for: __tests__/test-utils/mock-window-url.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Object.defineProperty(URL, 'createObjectURL', {
2+
value: jest.fn(),
3+
writable: true
4+
})

Diff for: __tests__/util/state.js

+28-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* globals describe, expect, it */
22

3-
import {queryIsValid} from '../../lib/util/state'
3+
import '../test-utils/mock-window-url'
4+
import { queryIsValid } from '../../lib/util/state'
45

56
describe('util > state', () => {
67
describe('queryIsValid', () => {
@@ -12,32 +13,38 @@ describe('util > state', () => {
1213
lat: 34,
1314
lon: 12
1415
}
15-
const testCases = [{
16-
expected: false,
17-
input: {
18-
otp: {
19-
currentQuery: {
20-
from: fakeFromLocation
16+
const testCases = [
17+
{
18+
expected: false,
19+
input: {
20+
otp: {
21+
currentQuery: {
22+
from: fakeFromLocation
23+
}
2124
}
22-
}
25+
},
26+
title: 'should not be valid with only from location'
2327
},
24-
title: 'should not be valid with only from location'
25-
}, {
26-
expected: true,
27-
input: {
28-
otp: {
29-
currentQuery: {
30-
from: fakeFromLocation,
31-
to: fakeToLocation
28+
{
29+
expected: true,
30+
input: {
31+
otp: {
32+
currentQuery: {
33+
from: fakeFromLocation,
34+
to: fakeToLocation
35+
}
3236
}
33-
}
34-
},
35-
title: 'should be valid with from and to locations'
36-
}]
37+
},
38+
title: 'should be valid with from and to locations'
39+
}
40+
]
3741

3842
testCases.forEach((testCase) => {
43+
// eslint-disable-next-line jest/valid-title
3944
it(testCase.title, () => {
40-
expect(queryIsValid(testCase.input))[testCase.expected ? 'toBeTruthy' : 'toBeFalsy']()
45+
expect(queryIsValid(testCase.input))[
46+
testCase.expected ? 'toBeTruthy' : 'toBeFalsy'
47+
]()
4148
})
4249
})
4350
})

Diff for: a11y/a11y.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import execa from 'execa'
55
import puppeteer from 'puppeteer'
66

7+
import '../__tests__/test-utils/mock-window-url'
8+
79
import routes from '../lib/util/webapp-routes'
810

911
import { mockServer } from './mock-server'

Diff for: lib/components/app/call-taker-panel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class CallTakerPanel extends Component {
220220
onClick={this._addPlace}
221221
to={to}
222222
/>
223-
<div className="search-options">
223+
<div className="search-options percy-hide">
224224
<DateTimeOptions
225225
date={date}
226226
departArrive={departArrive}

Diff for: lib/components/app/print-layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class PrintLayout extends Component<Props, State> {
123123
itinerary={itinerary}
124124
LegIcon={LegIcon}
125125
/>
126-
<TripDetails itinerary={itinerary} />
126+
<TripDetails className="percy-hide" itinerary={itinerary} />
127127
</>
128128
)}
129129
</div>

Diff for: lib/components/viewers/stop-time-cell.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const StopTimeCell = ({
9191

9292
return (
9393
<div>
94-
<div className="pull-left">
94+
<div className="pull-left percy-hide">
9595
<StyledIconWrapperTextAlign
9696
style={{ color: '#888', fontSize: '0.8em', marginRight: 2 }}
9797
>

Diff for: package.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@
3737
"@auth0/auth0-react": "^1.1.0",
3838
"@bugsnag/js": "^7.17.0",
3939
"@bugsnag/plugin-react": "^7.17.0",
40-
"@opentripplanner/base-map": "^3.0.5",
41-
"@opentripplanner/core-utils": "^7.0.9",
40+
"@opentripplanner/base-map": "^3.0.6",
41+
"@opentripplanner/core-utils": "^7.0.10",
4242
"@opentripplanner/endpoints-overlay": "2.0.5",
4343
"@opentripplanner/from-to-location-picker": "^2.1.5",
44-
"@opentripplanner/geocoder": "^1.3.2",
44+
"@opentripplanner/geocoder": "^1.3.3",
4545
"@opentripplanner/humanize-distance": "^1.2.0",
4646
"@opentripplanner/icons": "^2.0.1",
4747
"@opentripplanner/itinerary-body": "^4.1.5",
48-
"@opentripplanner/location-field": "1.12.9",
48+
"@opentripplanner/location-field": "1.12.11",
4949
"@opentripplanner/location-icon": "^1.4.0",
5050
"@opentripplanner/park-and-ride-overlay": "^2.0.4",
5151
"@opentripplanner/printable-itinerary": "^2.0.6",
52-
"@opentripplanner/route-viewer-overlay": "^2.0.6",
52+
"@opentripplanner/route-viewer-overlay": "^2.0.8",
5353
"@opentripplanner/stop-viewer-overlay": "^2.0.4",
5454
"@opentripplanner/stops-overlay": "^5.0.5",
5555
"@opentripplanner/transit-vehicle-overlay": "^4.0.0",
56-
"@opentripplanner/transitive-overlay": "^3.0.8",
57-
"@opentripplanner/trip-details": "^2.2.6",
56+
"@opentripplanner/transitive-overlay": "^3.0.9",
57+
"@opentripplanner/trip-details": "^2.2.7",
5858
"@opentripplanner/trip-form": "^3.0.1",
59-
"@opentripplanner/trip-viewer-overlay": "^2.0.3",
59+
"@opentripplanner/trip-viewer-overlay": "^2.0.4",
6060
"@opentripplanner/vehicle-rental-overlay": "^2.0.4",
6161
"@styled-icons/fa-regular": "^10.34.0",
6262
"@styled-icons/fa-solid": "^10.34.0",
@@ -125,9 +125,9 @@
125125
"@craco/craco": "^6.3.0",
126126
"@jackwilsdon/craco-use-babelrc": "^1.0.0",
127127
"@opentripplanner/scripts": "^1.0.2",
128-
"@opentripplanner/types": "^4.0.3",
129-
"@percy/cli": "^1.14.0",
130-
"@percy/puppeteer": "^2.0.0",
128+
"@opentripplanner/types": "^4.0.4",
129+
"@percy/cli": "^1.16.0",
130+
"@percy/puppeteer": "^2.0.2",
131131
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
132132
"@types/mapbox__polyline": "^1.0.2",
133133
"@types/qs": "^6.9.7",

0 commit comments

Comments
 (0)