Skip to content
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

Percy: GraphQL Mock Server #1063

Merged
merged 70 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
ec07eb9
correct service start time
miles-grant-ibigroup Oct 19, 2023
cb4ab89
reset date and time when ending call
miles-grant-ibigroup Oct 19, 2023
b8c733d
revert #925
miles-grant-ibigroup Oct 19, 2023
6535300
allow a mailable to be added multiple times
miles-grant-ibigroup Oct 19, 2023
bc95f37
clarify query record language
miles-grant-ibigroup Oct 19, 2023
13b9610
fix typo
miles-grant-ibigroup Oct 19, 2023
7293e77
trip viewer: sticky header, jump to first stop
miles-grant-ibigroup Oct 20, 2023
1b77a5e
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Oct 23, 2023
099fb95
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Oct 24, 2023
0dc2a84
add option to disable countdown unless realtime data present
miles-grant-ibigroup Oct 24, 2023
a091754
Merge branch 'dev' into optional-countdown
miles-grant-ibigroup Oct 25, 2023
9a2a70b
refactor(util/itinerary): Convert to TypeScript
binh-dam-ibigroup Oct 26, 2023
de9cc69
Merge branch 'dev' into optional-countdown
miles-grant-ibigroup Oct 26, 2023
3a3e8a1
Merge branch 'dev' into optional-countdown
miles-grant-ibigroup Oct 30, 2023
2ea5990
refactor(util/itinerary): Add function return types.
binh-dam-ibigroup Oct 30, 2023
6aa8217
refactor(util/itinerary): Move helper function from state to itinerar…
binh-dam-ibigroup Oct 30, 2023
9e14819
refactor(util/state): Move itin sorting out of the active itin selector.
binh-dam-ibigroup Oct 30, 2023
7c6009d
refactor(util/state): Extract itinerary sorting.
binh-dam-ibigroup Oct 30, 2023
c65bf97
refactor(narrative-itineraries): Move CO2 calculations to getActiveIt…
binh-dam-ibigroup Oct 31, 2023
f8a1ef4
refactor(narrative-itineraries): Move setting itinerary index to stat…
binh-dam-ibigroup Oct 31, 2023
37681f4
fix(narrative-itineraries): Add sort back, but only for the merged(di…
binh-dam-ibigroup Oct 31, 2023
886a487
improvement(narrative-itineraries): Avoid repeated itinerary merging.
binh-dam-ibigroup Nov 1, 2023
ee8c077
refactor(util/itinerary): Improve types
binh-dam-ibigroup Nov 1, 2023
34c175f
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Nov 1, 2023
a0cb1b8
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Nov 1, 2023
52da24d
Merge branch 'dev' into optional-countdown
miles-grant-ibigroup Nov 1, 2023
add44f7
repair `getTransitiveRouteLabel` behavior
miles-grant-ibigroup Oct 19, 2023
e54332e
correct default `getTransitiveRouteLabel `
miles-grant-ibigroup Oct 19, 2023
6e10cbb
correct color defaults
miles-grant-ibigroup Nov 1, 2023
31062cc
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Nov 1, 2023
01785e9
refactor(narrative-itineraries): Add carbon info is config enables it.
binh-dam-ibigroup Nov 1, 2023
9669354
Merge branch 'dev' into call-taker-fixes-nov-2023
miles-grant-ibigroup Nov 2, 2023
6236c49
refactor(departure-times-list): Remove redundant StartTime type.
binh-dam-ibigroup Nov 2, 2023
7522401
Merge branch 'dev' into stricter-itinerary-order
binh-dam-ibigroup Nov 2, 2023
5c2d2b3
Merge branch 'dev' into trip-viewer-header-adjustments
miles-grant-ibigroup Nov 6, 2023
a04a0f2
Merge pull request #1044 from opentripplanner/trip-viewer-header-adju…
miles-grant-ibigroup Nov 6, 2023
ced9a11
fix: update otp-ui
miles-grant-ibigroup Nov 6, 2023
8b0bfda
Merge branch 'dev' into internal-dep-updates
miles-grant-ibigroup Nov 6, 2023
1a3f88b
initial work on mocking graphql requests for percy
daniel-heppner-ibigroup Nov 7, 2023
08642ad
fix(util/state): Allow null walkDistance and transfers in itin cost c…
binh-dam-ibigroup Nov 7, 2023
4c117d0
add `mutedErrors` itinerary config feature
miles-grant-ibigroup Nov 7, 2023
5b5e1c4
Merge pull request #1046 from opentripplanner/optional-countdown
miles-grant-ibigroup Nov 7, 2023
eeef019
refactor(util/itinerary): Move more itin helper funcs from state.js.
binh-dam-ibigroup Nov 7, 2023
28562b7
refactor(util/state): Precompute sort costs/rank and use during sort.
binh-dam-ibigroup Nov 7, 2023
0f91236
refactor: Tighten up types.
binh-dam-ibigroup Nov 7, 2023
08c5413
refactor(metro-itinerary): Remove type todo comment
binh-dam-ibigroup Nov 7, 2023
020be36
Merge branch 'dev' into stricter-itinerary-order
binh-dam-ibigroup Nov 7, 2023
552cfd9
more progress on making the graphql mock work
daniel-heppner-ibigroup Nov 7, 2023
d36af32
Merge pull request #1060 from opentripplanner/internal-dep-updates
miles-grant-ibigroup Nov 7, 2023
fc88cb2
get everything working for otp-rr desktop
daniel-heppner-ibigroup Nov 7, 2023
52f7b33
Merge pull request #1043 from opentripplanner/call-taker-fixes-nov-2023
miles-grant-ibigroup Nov 8, 2023
2b09b57
add to codespell ignore
daniel-heppner-ibigroup Nov 8, 2023
affb6a1
fix issue with mock server not runnign
daniel-heppner-ibigroup Nov 8, 2023
5e3a6a7
re-add headless mode
daniel-heppner-ibigroup Nov 8, 2023
f44e8af
add percy mocks to codespell ignore
daniel-heppner-ibigroup Nov 8, 2023
f6a0749
fix port issue on server
daniel-heppner-ibigroup Nov 9, 2023
928f303
Merge branch 'dev' into allow-error-muting
miles-grant-ibigroup Nov 10, 2023
fad1057
address pr feedback
miles-grant-ibigroup Nov 10, 2023
204e799
Merge pull request #1061 from opentripplanner/allow-error-muting
miles-grant-ibigroup Nov 10, 2023
5a6e656
fix percy tests on ci
miles-grant-ibigroup Nov 13, 2023
530bf3c
Merge branch 'dev' into stricter-itinerary-order
binh-dam-ibigroup Nov 14, 2023
d5a2d8d
Merge pull request #1057 from opentripplanner/stricter-itinerary-order
binh-dam-ibigroup Nov 14, 2023
8a97f98
fix weird date bug
daniel-heppner-ibigroup Nov 14, 2023
828e0d5
fix stop ID issue for schedule viewer
daniel-heppner-ibigroup Nov 14, 2023
5c5c9df
Merge branch 'dev' into graphql-mock-server
daniel-heppner-ibigroup Nov 15, 2023
904d2fd
fix alerts bug
daniel-heppner-ibigroup Nov 15, 2023
12f839b
Merge branch 'dev' into nearby-view
daniel-heppner-ibigroup Nov 15, 2023
576a05f
add mobile nearbyview
daniel-heppner-ibigroup Nov 15, 2023
32f699d
Merge branch 'nearby-view' into graphql-mock-server
daniel-heppner-ibigroup Nov 15, 2023
13ffcb2
disable headful
daniel-heppner-ibigroup Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
# skip git, yarn, pixel test script and HAR file, and all i18n resources.
# Also, the a11y test file has a false positive and the ignore list does not work
# see https://github.com/opentripplanner/otp-react-redux/pull/436/checks?check_run_id=3369380014
skip: ./.git,yarn.lock,./a11y/a11y.test.js,./a11y/mocks,./percy/percy.test.js,./percy/mock.har,./i18n,./__tests__/mocks
skip: ./.git,yarn.lock,./a11y/a11y.test.js,./a11y/mocks,./percy/percy.test.js,./percy/mock.har,./i18n,./__tests__/mocks,otpSchema.json,./percy/mocks/*.json
4,406 changes: 2,478 additions & 1,928 deletions __tests__/components/viewers/__snapshots__/stop-viewer.js.snap

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ itinerary:
# One fare will always be shown by default
defaultFareType: { mediumId: null, riderCategoryId: null }

# List of OTP2 errors to not display. Can be a list
# mutedErrors:
# - NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW

# The following settings must be set to these values to use the new
# "Metro" UI. The settings can be used without the Metro UI, but
# this may have unexpected effects.
Expand All @@ -352,6 +356,8 @@ itinerary:
# This flag disables the dot between legs in the metro itnerary summary, replacing it with
# a gray background
disableMetroSeperatorDot: false
# If enabled, always shows departures as times ("10pm" instead of "3 min") unless realtime data is present
onlyShowCountdownForRealtime: true
# Show the number of minutes of delay or early beneath a time in the itinerary body
showScheduleDeviation: true
# Shows the duration of a leg below the leg in the metro itinerary summary
Expand Down
1 change: 1 addition & 0 deletions i18n/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ components:
companyBicycle: "{company} Bike"
companyScooter: "{company} Scooter"
error: An error occurred loading nearby amenities.
header: Nearby View
nothingNearby: There are no places nearby.
spacesAvailable: "{spacesAvailable} empty spaces available"
NewAccountWizard:
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export function findStopTimesForStop(params) {
const { date, stopId, ...otherParams } = params
let datePath = ''
if (date) {
const dateWithoutDashes = date.replace('-', '')
const dateWithoutDashes = date.replace(/-/g, '')
datePath = `/${dateWithoutDashes}`
}

Expand Down
1 change: 1 addition & 0 deletions lib/actions/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function resetForm(full = false) {
// If fully resetting form, also clear the active search, from/to
// locations, and query params.
dispatch(clearActiveSearch())
dispatch(settingQueryParam({ departArrive: 'NOW' }))
dispatch(setLocation({ location: null, locationType: 'from' }))
dispatch(setLocation({ location: null, locationType: 'to' }))
// Get query params. Delete everything except sessionId.
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getFirstStopId } from '../util/itinerary'
import { routingQuery } from './api'
import { setQueryParam } from './form'

const SERVICE_BREAK = '03:00'
const SERVICE_BREAK = '03:30'
const NINETY_SECONDS = 90000

function updateParamsAndPlan(params) {
Expand Down
39 changes: 10 additions & 29 deletions lib/components/admin/mailables-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class SelectedMailable extends Component {
updateField(index, 'largeFormat', evt.target.checked)
}

_changeSmallFormat = (evt) => {
const { index, updateField } = this.props
updateField(index, 'smallFormat', evt.target.checked)
}

_changeQuantity = (evt) => {
const { index, updateField } = this.props
updateField(index, 'quantity', evt.target.value)
Expand All @@ -62,8 +57,7 @@ class SelectedMailable extends Component {

render() {
const { index, mailable } = this.props
const largeId = `largeFormat-${index}`
const smallId = `smallFormat-${index}`
const id = `largeFormat-${index}`
return (
<SelectedMailableContainer>
<MailableLabel mailable={mailable} />
Expand All @@ -76,26 +70,15 @@ class SelectedMailable extends Component {
type="number"
value={mailable.quantity}
/>
<div style={{ marginTop: '5px' }}>
<input
checked={mailable.smallFormat}
id={smallId}
onChange={this._changeSmallFormat}
type="checkbox"
/>
<label htmlFor={smallId} style={{ marginLeft: '5px' }}>
Small format?
</label>
</div>
{mailable.largePrint && (
<div style={{ marginTop: '5px' }}>
<input
checked={mailable.largeFormat}
id={largeId}
id={id}
onChange={this._changeLargeFormat}
type="checkbox"
value={mailable.largeFormat}
/>
<label htmlFor={largeId} style={{ marginLeft: '5px' }}>
<label htmlFor={id} style={{ marginLeft: '5px' }}>
Large format?
</label>
</div>
Expand All @@ -122,11 +105,9 @@ class MailablesWindow extends Component {
}

_addMailable = (mailable) => {
if (!this.state.mailables.find((m) => m.name === mailable.name)) {
const mailables = [...this.state.mailables]
mailables.push({ ...mailable, quantity: 1, smallFormat: true })
this.setState({ mailables })
}
const mailables = [...this.state.mailables]
mailables.push({ ...mailable, quantity: 1 })
this.setState({ mailables })
}

_removeMailable = (mailable) => {
Expand Down Expand Up @@ -156,9 +137,9 @@ class MailablesWindow extends Component {
const { mailables: selectedMailables } = this.state
const { items } = mailablesConfig
if (!callTaker.mailables.visible) return null
const selectableMailables = items.filter(
(m) => !selectedMailables.find((mailable) => mailable.name === m.name)
)
// If items should not be addable twice, then this line can be amended
const selectableMailables = items

return (
<DraggableWindow
footer={
Expand Down
4 changes: 1 addition & 3 deletions lib/components/admin/query-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class QueryRecordLayout extends Component {
onClick={this._viewQuery}
>
<CallRecordIcon type="search" />
{time}
<br />
{params.from.name} to {params.to.name}
{params.from.name} to {params.to.name} at {time}
</CallRecordButton>
</li>
)
Expand Down
10 changes: 6 additions & 4 deletions lib/components/mobile/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import MobileRouteViewer from './route-viewer'
import MobileStopViewer from './stop-viewer'
import MobileTripViewer from './trip-viewer'
import MobileWelcomeScreen from './welcome-screen'
import NearbyView from '../viewers/nearby/nearby-view'

class MobileMain extends Component {
static propTypes = {
Expand Down Expand Up @@ -62,14 +63,15 @@ class MobileMain extends Component {
return <MobilePatternViewer />
}

if (uiState.mainPanelContent === MainPanelContent.NEARBY_VIEW) {
return <NearbyView mobile />
}

// check for viewed stop
if (uiState.viewedStop) return <MobileStopViewer />

// check for viewed trip
if (
uiState.viewedTrip ||
uiState.mainPanelContent === MainPanelContent.TRIP_VIEWER
)
if (uiState.mainPanelContent === MainPanelContent.TRIP_VIEWER)
return <MobileTripViewer />

switch (uiState.mobileScreen) {
Expand Down
3 changes: 1 addition & 2 deletions lib/components/narrative/default/default-itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
getAccessibilityScoreForItinerary,
itineraryHasAccessibilityScores
} from '../../../util/accessibility-routing'
import { getFare, getTotalFare } from '../../../util/state'
import { getFirstLegStartTime } from '../../../util/itinerary'
import { getFare, getFirstLegStartTime } from '../../../util/itinerary'
import { Icon, StyledIconWrapperTextAlign } from '../../util/styledIcon'
import { localizeGradationMap } from '../utils'
import FieldTripGroupSize from '../../admin/field-trip-itinerary-group-size'
Expand Down
2 changes: 2 additions & 0 deletions lib/components/narrative/default/itinerary.css
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
.otp .option.default-itin > .header .title > .summary > .mode-block {
height: 18px;
width: 18px;
color: #eee;
fill: #eee;
}

.otp .option.default-itin > .header .title > .summary > .arrow-block {
Expand Down
9 changes: 5 additions & 4 deletions lib/components/narrative/line-itin/itin-summary.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { connect } from 'react-redux'
import { FareProductSelector, Itinerary, Leg } from '@opentripplanner/types'
import { FormattedMessage, FormattedNumber } from 'react-intl'
import coreUtils from '@opentripplanner/core-utils'
import React, { Component } from 'react'
import styled from 'styled-components'
import type { Itinerary, Leg } from '@opentripplanner/types'

import { AppReduxState } from '../../../util/state-types'
import { ComponentContext } from '../../../util/contexts'
import { getFare } from '../../../util/state'
import { getFare } from '../../../util/itinerary'
import FormattedDuration from '../../util/formatted-duration'

// TODO: make this a prop
Expand Down Expand Up @@ -77,7 +78,7 @@ const ShortName = styled.div<{ leg: Leg }>`

type Props = {
currency?: string
defaultFareType: string
defaultFareType?: FareProductSelector
itinerary: Itinerary
onClick: () => void
}
Expand Down Expand Up @@ -236,7 +237,7 @@ function getRouteColorForBadge(leg: Leg): string {
return leg.routeColor ? '#' + leg.routeColor : defaultRouteColor
}

const mapStateToProps = (state: any) => {
const mapStateToProps = (state: AppReduxState) => {
return {
defaultFareType: state.otp.config.itinerary?.defaultFareType
}
Expand Down
17 changes: 4 additions & 13 deletions lib/components/narrative/metro/departure-times-list.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
import { FormattedList, useIntl } from 'react-intl'
import { Itinerary, Leg } from '@opentripplanner/types'
import React, { MouseEvent, useCallback } from 'react'

import { firstTransitLegIsRealtime } from '../../../util/viewer'
import {
getFirstLegStartTime,
getLastLegEndTime
getLastLegEndTime,
ItineraryStartTime,
ItineraryWithIndex
} from '../../../util/itinerary'
import InvisibleA11yLabel from '../../util/invisible-a11y-label'

interface ItineraryWithIndex extends Itinerary {
index: number
}

interface StartTime {
itinerary: ItineraryWithIndex
legs: Leg[]
realtime: boolean
}

export type SetActiveItineraryHandler = (payload: { index: number }) => void

type DepartureTimesProps = {
expanded?: boolean
itinerary: ItineraryWithIndex & {
allStartTimes?: StartTime[]
allStartTimes?: ItineraryStartTime[]
}
setActiveItinerary: SetActiveItineraryHandler
showArrivals?: boolean
Expand Down
32 changes: 24 additions & 8 deletions lib/components/narrative/metro/metro-error-renderer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { connect } from 'react-redux'
import { ExclamationCircle } from '@styled-icons/fa-solid/ExclamationCircle'
import { FormattedMessage, useIntl } from 'react-intl'
import React from 'react'
import styled from 'styled-components'

import { AppReduxState } from '../../../util/state-types'
import { Icon } from '../../util/styledIcon'

type Error = Record<string, string[]>
Expand Down Expand Up @@ -38,25 +40,34 @@ const Container = styled.li`
}
`

const ErrorRenderer = ({ errors }: { errors: Error }): JSX.Element => {
const ErrorRenderer = ({
errors,
mutedErrors
}: {
errors: Error
mutedErrors?: string[]
}): JSX.Element => {
const intl = useIntl()

return (
<List>
{Object.keys(errors).map((error: string) => {
// The search window is hardcoded in otp-rr and can't be changed by the user.
// Do not tell them what's happening as they can't act on the issue.
if (error === 'NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW') {
return null
}

// Don't show errors that have been muted in the config
if (mutedErrors?.includes(error)) return null

const localizedInputFieldList = Array.from(errors[error])?.map(
(inputField) =>
intl.formatMessage({
id: `components.OTP2ErrorRenderer.inputFields.${inputField}`
})
)

// The search window is hardcoded in otp-rr and can't be changed by the user.
// Do not tell them what's happening as they can't act on the issue.
if (error === 'NO_TRANSIT_CONNECTION_IN_SEARCH_WINDOW') {
return null
}

return (
<Container key={error}>
<Icon Icon={ExclamationCircle} size="3x" />
Expand All @@ -81,5 +92,10 @@ const ErrorRenderer = ({ errors }: { errors: Error }): JSX.Element => {
)
}

export default ErrorRenderer
const mapStateToProps = (state: AppReduxState) => {
const { itinerary } = state.otp.config
return { mutedErrors: itinerary?.mutedErrors }
}
export default connect(mapStateToProps)(ErrorRenderer)

export type { Error }
7 changes: 4 additions & 3 deletions lib/components/narrative/metro/metro-itinerary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import React from 'react'
import styled, { keyframes } from 'styled-components'

import * as uiActions from '../../../actions/ui'
import { AppReduxState } from '../../../util/state-types'
import { ComponentContext } from '../../../util/contexts'
import { FlexIndicator } from '../default/flex-indicator'
import {
getAccessibilityScoreForItinerary,
itineraryHasAccessibilityScores
} from '../../../util/accessibility-routing'
import { getActiveSearch, getFare } from '../../../util/state'
import { getActiveSearch } from '../../../util/state'
import { getFare } from '../../../util/itinerary'
import { IconWithText } from '../../util/styledIcon'
import { ItineraryDescription } from '../default/itinerary-description'
import { ItineraryView } from '../../../util/ui'
Expand Down Expand Up @@ -451,8 +453,7 @@ class MetroItinerary extends NarrativeItinerary {
}
}

// TODO: state type
const mapStateToProps = (state: any, ownProps: Props) => {
const mapStateToProps = (state: AppReduxState, ownProps: Props) => {
const activeSearch = getActiveSearch(state)

return {
Expand Down
Loading
Loading