diff --git a/src/elements-experimental/core/timetable/access-leg-helper.spec.ts b/src/elements-experimental/core/timetable/access-leg-helper.spec.ts index 25ddf7dd83..79c501e5b1 100644 --- a/src/elements-experimental/core/timetable/access-leg-helper.spec.ts +++ b/src/elements-experimental/core/timetable/access-leg-helper.spec.ts @@ -1,6 +1,7 @@ import { expect } from '@open-wc/testing'; import { + connectionTrip, defaultTrip, extendedEnterTimeTrip, } from '../../timetable-row/timetable-row.sample-data.js'; @@ -39,6 +40,43 @@ describe('getDepartureArrivalTimeAttribute', () => { }); }); + it('should return correct a11y time attributes', () => { + const { departureTimeAttribute, arrivalTimeAttribute } = getDepartureArrivalTimeAttribute( + defaultTrip.legs as Leg[], + 10, + 10, + 'en', + true, + ); + + expect(departureTimeAttribute).to.be.deep.equal({ + duration: 10, + icon: 'wheelchair-small', + text: 'minutes of walking time before departure:', + }); + expect(arrivalTimeAttribute).to.be.deep.equal({ + duration: 10, + icon: 'wheelchair-small', + text: 'minutes of walking time after arrival:', + }); + }); + + it('should return correct time attribute for connection-leg', () => { + const { departureTimeAttribute } = getDepartureArrivalTimeAttribute( + connectionTrip.legs as Leg[], + 10, + 0, + 'en', + true, + ); + + expect(departureTimeAttribute).to.be.deep.equal({ + duration: 30, + icon: 'walk-small', + text: 'Zu Fuss', + }); + }); + it('should returns extended departure time attribute', () => { const { departureTimeAttribute } = getDepartureArrivalTimeAttribute( extendedEnterTimeTrip.legs as Leg[], @@ -68,4 +106,20 @@ describe('getDepartureArrivalTimeAttribute', () => { text: 'Extended boarding time ', }); }); + + it('should return correct a11y time attribute with extended departure time', () => { + const { departureTimeAttribute } = getDepartureArrivalTimeAttribute( + extendedEnterTimeTrip.legs as Leg[], + 0, + 0, + 'en', + true, + ); + + expect(departureTimeAttribute).to.be.deep.equal({ + duration: 45, + icon: 'wheelchair-small', + text: 'minutes of walking time before departure:', + }); + }); }); diff --git a/src/elements-experimental/core/timetable/access-leg-helper.ts b/src/elements-experimental/core/timetable/access-leg-helper.ts index fe638ffa10..e9c7cfbf73 100644 --- a/src/elements-experimental/core/timetable/access-leg-helper.ts +++ b/src/elements-experimental/core/timetable/access-leg-helper.ts @@ -50,6 +50,8 @@ function getPTConnectionAttribute( function getFirstExtendedLegAttribute( leg: PtRideLeg | PtConnectionLeg, departureWalk: number, + a11yFootpath: boolean | undefined, + currentLanguage: string, ): IAccessAttribute | null { // Extended enter const extendedFirstLeg = isRideLeg(leg) @@ -64,8 +66,10 @@ function getFirstExtendedLegAttribute( return extendedFirstLeg ? { duration: (extractTimeAndString?.duration || 0) + (departureWalk || 0), - text: extractTimeAndString?.text || '', - icon: `sa-${extendedFirstLeg?.name?.toLowerCase()}`, + text: a11yFootpath + ? i18nWalkingDistanceDeparture[currentLanguage] + : extractTimeAndString?.text || '', + icon: a11yFootpath ? 'wheelchair-small' : `sa-${extendedFirstLeg?.name?.toLowerCase()}`, } : null; } @@ -73,7 +77,12 @@ function getFirstExtendedLegAttribute( /** * @returns the extended exit attribute of the PTRideLeg */ -function getLastExtendedLegAttribute(leg: Leg, arrivalWalk: number): IAccessAttribute | null { +function getLastExtendedLegAttribute( + leg: Leg, + arrivalWalk: number, + a11yFootpath: boolean | undefined, + currentLanguage: string, +): IAccessAttribute | null { // Extended exit const extendedLastLeg = isRideLeg(leg) ? (leg as PtRideLeg)?.serviceJourney?.notices?.filter((notice) => @@ -87,8 +96,10 @@ function getLastExtendedLegAttribute(leg: Leg, arrivalWalk: number): IAccessAttr return extendedLastLeg ? { duration: (extractTimeAndString?.duration || 0) + (arrivalWalk || 0), - text: extractTimeAndString?.text || '', - icon: `sa-${extendedLastLeg?.name?.toLowerCase()}`, + text: a11yFootpath + ? i18nWalkingDistanceArrival[currentLanguage] + : extractTimeAndString?.text || '', + icon: a11yFootpath ? 'wheelchair-small' : `sa-${extendedLastLeg?.name?.toLowerCase()}`, } : null; } @@ -104,7 +115,7 @@ function renderTransferTime( type?: 'departure' | 'arrival', ): TemplateResult { return html` - +