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

refactor(timetable-row): remove service product logic #2509

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/components/core/timetable/timetable-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ export type Occupancy = {
* provided and operated by a certain Operator allocated to a concrete ServiceJourney
*/
export type ServiceProduct = {
/**
* Corporate Identity Icon for e.g. Train 'SBB_oev_b_t02'
* // TODO - Ist diese Info zum Icon nützlich oder wäre die Art des Transportmittel (ZUg, Bus, ..) nützlicher
*/
/** Icon-identifier to represent the specific submode e.g. the symbol for an EC 1 */
corporateIdentityIcon?: string | null;

/** Corporate Identity Pictogram for e.g. Train 'SBB_oev_b_t02' */
corporateIdentityPictogram?: string;
/**
* Usually referring to a specific commercial PT route (where direction might be either way), shown on vehicle displays. If this value is missing, it is probably a single-journey (de:Einzelfahrt)
* example: 1
Expand Down
29 changes: 26 additions & 3 deletions src/components/timetable-row/timetable-row.sample-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const defaultTrip: DeepPartial<ITripItem> = {
line: '37',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-37',
corporateIdentityPictogram: 'train-right',
},
},
};
Expand All @@ -52,6 +54,8 @@ export const cancelledTrip: DeepPartial<ITripItem> = {
line: '37',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-37',
corporateIdentityPictogram: 'train-right',
},
tripStatus: {
cancelled: true,
Expand Down Expand Up @@ -79,6 +83,8 @@ export const progressTrip: DeepPartial<ITripItem> = {
line: '37',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-37',
corporateIdentityPictogram: 'train-right',
},
},
};
Expand All @@ -99,6 +105,8 @@ export const partiallyCancelled: DeepPartial<ITripItem> = {
line: '37',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-37',
corporateIdentityPictogram: 'train-right',
},
tripStatus: {
partiallyCancelled: true,
Expand All @@ -123,6 +131,8 @@ export const pastTrip: DeepPartial<ITripItem> = {
line: '37',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-37',
corporateIdentityPictogram: 'train-right',
},
tripStatus: {
partiallyCancelled: false,
Expand All @@ -145,6 +155,7 @@ export const skippedLastArrivalStopTrip: DeepPartial<ITripItem> = {
line: '502',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
},
};
Expand All @@ -164,6 +175,7 @@ export const skippedArrivalStopTrip: DeepPartial<ITripItem> = {
line: '502',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
},
};
Expand All @@ -183,6 +195,7 @@ export const skippedDepartureStopTrip: DeepPartial<ITripItem> = {
line: '502',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
},
};
Expand All @@ -202,6 +215,7 @@ export const skippedFirstDepartureStopTrip: DeepPartial<ITripItem> = {
line: '502',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
},
};
Expand Down Expand Up @@ -255,6 +269,7 @@ export const disturbanceTrip: DeepPartial<ITripItem> = {
number: '2204',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
occupancy: {
firstClass: 'MEDIUM',
Expand Down Expand Up @@ -306,6 +321,7 @@ export const quayChangeTrip: DeepPartial<ITripItem> = {
number: '2204',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityPictogram: 'bus-right',
},
occupancy: {
firstClass: 'MEDIUM',
Expand Down Expand Up @@ -338,6 +354,8 @@ export const trainTrip: DeepPartial<ITripItem> = {
number: '2377',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ic-35',
corporateIdentityPictogram: 'train-right',
},
occupancy: {
firstClass: 'LOW',
Expand All @@ -364,12 +382,12 @@ export const busTrip: DeepPartial<ITripItem> = {
departureWalk: 0,
direction: 'Spiegel, Blinzern',
product: {
name: 'B 19 27014',
name: 'B 19',
line: '19',
number: '27014',
vehicleMode: 'BUS',
vehicleSubModeShortName: 'B',
corporateIdentityIcon: 'SBB_oev_b_t06',
corporateIdentityPictogram: 'bus-right',
},
occupancy: {
firstClass: 'LOW',
Expand Down Expand Up @@ -398,6 +416,7 @@ export const shipTrip: DeepPartial<ITripItem> = {
product: {
line: null,
vehicleMode: 'SHIP',
corporateIdentityPictogram: 'jetty-right',
},
tripStatus: {},
},
Expand Down Expand Up @@ -543,7 +562,7 @@ export const walkTimeTrip: DeepPartial<ITripItem> = {
number: '2258',
vehicleMode: 'TRAMWAY',
vehicleSubModeShortName: 'T',
corporateIdentityIcon: 'SBB_oev_b_t04',
corporateIdentityPictogram: 'tram-right',
},
occupancy: {
firstClass: 'LOW',
Expand Down Expand Up @@ -581,6 +600,8 @@ export const extendedEnterTimeTrip: DeepPartial<ITripItem> = {
number: '2377',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-35',
corporateIdentityPictogram: 'train-right',
},
occupancy: {},
tripStatus: {},
Expand Down Expand Up @@ -664,6 +685,8 @@ export const noticesTrip: DeepPartial<ITripItem> = {
number: '2377',
vehicleMode: 'TRAIN',
vehicleSubModeShortName: 'IR',
corporateIdentityIcon: 'ir-35',
corporateIdentityPictogram: 'train-right',
},
occupancy: {
firstClass: 'LOW',
Expand Down
100 changes: 47 additions & 53 deletions src/components/timetable-row/timetable-row.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ import { waitForLitRender } from '../core/testing';
import type { ITripItem, Notice, PtSituation } from '../core/timetable';

import type { SbbTimetableRowElement } from './timetable-row';
import {
filterNotices,
getCus,
getHimIcon,
getTransportIcon,
isProductIcon,
sortSituation,
} from './timetable-row';
import { filterNotices, getCus, getHimIcon, sortSituation } from './timetable-row';
import {
defaultTrip,
busTrip,
Expand All @@ -39,32 +32,69 @@ describe('sbb-timetable-row', () => {
`);

expect(element).shadowDom.to.be.equal(`
<sbb-card color="white" data-action-role="button" data-has-action size="l">
<sbb-card-button dir="ltr" role="button" slot="action" tabindex="0" data-action data-button>
<sbb-card
color="white"
data-action-role="button"
data-has-action=""
size="l"
>
<sbb-card-button
data-action=""
data-button=""
dir="ltr"
role="button"
slot="action"
tabindex="0"
>
Departure: 11:08, Train, IR 37, Direction Basel SBB, Arrival: 12:13, Travel time 1 Hour 15 Minutes,
</sbb-card-button>
<div class="sbb-timetable__row" role="row">
<div class="sbb-timetable__row-header" role="gridcell">
<div
class="sbb-timetable__row"
role="row"
>
<div
class="sbb-timetable__row-header"
role="gridcell"
>
<div class="sbb-timetable__row-details">
<span class="sbb-timetable__row-transport-wrapper">
<sbb-icon aria-hidden="true" data-namespace="picto" role="img" class="sbb-timetable__row-transport-icon" name="picto:train-right"></sbb-icon>
<sbb-icon
aria-hidden="true"
class="sbb-timetable__row-transport-icon"
data-namespace="picto"
name="picto:train-right"
role="img"
>
</sbb-icon>
<span class="sbb-screenreaderonly">
Train
</span>
</span>
<span class="sbb-timetable__row-transport">
<sbb-icon aria-hidden="true" data-namespace="default" role="img" name="ir-37"></sbb-icon>
<sbb-icon
aria-hidden="true"
data-namespace="default"
name="ir-37"
role="img"
>
</sbb-icon>
<span class="sbb-screenreaderonly">
ir-37
</span>
</span>
</div>
<p>
Direction Basel SBB
</p>
</div>
<sbb-pearl-chain-time data-now="1660662000000" role="gridcell"></sbb-pearl-chain-time>
<div class="sbb-timetable__row-footer" role="gridcell">
<sbb-pearl-chain-time
data-now="1660662000000"
role="gridcell"
>
</sbb-pearl-chain-time>
<div
class="sbb-timetable__row-footer"
role="gridcell"
>
<time>
<span class="sbb-screenreaderonly">
Travel time 1 Hour 15 Minutes
Expand Down Expand Up @@ -179,42 +209,6 @@ describe('sbb-timetable-row', () => {
});
});

describe('getTransportIcon', () => {
it('should return ship / jetty', () => {
expect(getTransportIcon('SHIP', '', 'de')).to.be.equal('jetty-right');
});

it('should return empty string', () => {
expect(getTransportIcon('UNKNOWN', '', 'de')).to.be.equal('');
});

it('should return metro string', () => {
expect(getTransportIcon('METRO', 'PB', 'fr')).to.be.equal('metro-right-fr');
});

it('should return metro en string', () => {
expect(getTransportIcon('METRO', 'PB', 'en')).to.be.equal('metro-right-de');
});

it('should return cableway string', () => {
expect(getTransportIcon('GONDOLA', 'PB', 'de')).to.be.equal('cableway-right');
});

it('should return gondola string', () => {
expect(getTransportIcon('GONDOLA', 'GB', 'de')).to.be.equal('gondola-lift-right');
});
});

describe('isProductIcon', () => {
it('should return true', () => {
expect(isProductIcon('ic')).to.be.equal(true);
});

it('should return false', () => {
expect(isProductIcon('icc')).to.be.equal(false);
});
});

describe('sortSituation', () => {
it('should return sorted array', () => {
expect(
Expand Down
Loading
Loading