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

feat(sbb-timetable-row): enhance trip status and display logic #2680

Merged
merged 17 commits into from
Jun 26, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@open-wc/testing';
import { fixture } from '@sbb-esta/lyne-elements/core/testing/private.js';
import { waitForLitRender } from '@sbb-esta/lyne-elements/core/testing.js';
import { html } from 'lit/static-html.js';

import type { PtRideLeg } from '../core/timetable.js';
Expand All @@ -17,16 +16,16 @@ describe(`sbb-pearl-chain-time`, () => {
<sbb-pearl-chain-time
departure-time="2022-08-16T12:00:00"
arrival-time="2022-08-16T15:00:00"
.now="${now}"
.now=${now}
.legs=${[
{
__typename: 'PTRideLeg',
} as PtRideLeg,
]}
>
</sbb-pearl-chain-time>
`);
element.legs = [
{
__typename: 'PTRideLeg',
} as PtRideLeg,
];
await waitForLitRender(element);

expect(element).dom.to.be.equal(`
<sbb-pearl-chain-time arrival-time="2022-08-16T15:00:00" departure-time="2022-08-16T12:00:00">
</sbb-pearl-chain-time>
Expand Down Expand Up @@ -56,16 +55,16 @@ describe(`sbb-pearl-chain-time`, () => {
departure-time="2022-08-16T12:00:00"
arrival-time="2022-08-16T15:00:00"
departure-walk="10"
.now="${now}"
.now=${now}
.legs=${[
{
__typename: 'PTRideLeg',
} as PtRideLeg,
]}
>
</sbb-pearl-chain-time>
`);
element.legs = [
{
__typename: 'PTRideLeg',
} as PtRideLeg,
];
await waitForLitRender(element);

expect(element).dom.to.be.equal(`
<sbb-pearl-chain-time departure-time='2022-08-16T12:00:00' arrival-time='2022-08-16T15:00:00' departure-walk="10">
</sbb-pearl-chain-time>
Expand Down Expand Up @@ -112,16 +111,16 @@ describe(`sbb-pearl-chain-time`, () => {
departure-time="2022-08-16T12:00:00"
arrival-time="2022-08-16T15:00:00"
arrival-walk="10"
.now="${now}"
.now=${now}
.legs=${[
{
__typename: 'PTRideLeg',
} as PtRideLeg,
]}
>
</sbb-pearl-chain-time>
`);
element.legs = [
{
__typename: 'PTRideLeg',
} as PtRideLeg,
];
await waitForLitRender(element);

expect(element).dom.to.be.equal(`
<sbb-pearl-chain-time arrival-time="2022-08-16T15:00:00" departure-time="2022-08-16T12:00:00" arrival-walk="10">
</sbb-pearl-chain-time>
Expand Down Expand Up @@ -169,16 +168,16 @@ describe(`sbb-pearl-chain-time`, () => {
arrival-time="2022-08-16T15:00:00"
departure-walk="20"
arrival-walk="10"
.now="${now}"
.now=${now}
.legs=${[
{
__typename: 'PTRideLeg',
} as PtRideLeg,
]}
>
</sbb-pearl-chain-time>
`);
element.legs = [
{
__typename: 'PTRideLeg',
} as PtRideLeg,
];
await waitForLitRender(element);

expect(element).dom.to.be.equal(`
<sbb-pearl-chain-time arrival-time="2022-08-16T15:00:00" departure-time="2022-08-16T12:00:00" departure-walk="20" arrival-walk="10">
</sbb-pearl-chain-time>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ const future = '2022-12-07T12:11:00+01:00';
const future2 = '2022-12-11T12:13:00+01:00';

const defaultService = {
quayTypeName: 'platform',
quayTypeShortName: 'Pl.',
serviceAlteration: {
cancelled: false,
delayText: 'string',
reachable: true,
unplannedStopPointsText: '',
},
};
const cancelledService = { serviceAlteration: { cancelled: true } };
const delayedService = { serviceAlteration: { delay: true } };
const isNotReachableService = { serviceAlteration: { reachable: false } };
const unplannedStopService = { serviceAlteration: { unplannedStopPointsText: 'unplannedStop' } };
const redirectedService = { serviceAlteration: { redirectedText: 'Ausnahmsweise kein Halt' } };

const busService = { ...defaultService, quayTypeName: 'Stand', quayTypeShortName: 'Stand' };
const cancelledService = { ...defaultService, serviceAlteration: { cancelled: true } };
const delayedService = { ...defaultService, serviceAlteration: { delay: true } };
const isNotReachableService = { ...defaultService, serviceAlteration: { reachable: false } };
const unplannedStopService = {
...defaultService,
serviceAlteration: { unplannedStopPointsText: 'unplannedStop' },
};
const redirectedService = {
...defaultService,
serviceAlteration: { redirectedText: 'Exceptionally no stop' },
};
const departureNotServiced = {
...defaultService,
stopPoints: [{ stopStatus: 'NOT_SERVICED' }, { stopStatus: 'PLANNED' }],
};
const arrivalNotServiced = {
Expand Down Expand Up @@ -68,6 +79,34 @@ export const pastLeg: any = {
serviceJourney: defaultService,
};

export const defaultBusLeg: any = {
...futureLeg,
serviceJourney: busService,
};

export const pastBusLeg: any = {
...pastLeg,
serviceJourney: busService,
};

export const defaultShipLeg: any = {
...futureLeg,
serviceJourney: {
...defaultService,
quayTypeName: 'Pier',
quayTypeShortName: 'Pier',
},
};

export const defaultTramLeg: any = {
...futureLeg,
serviceJourney: {
...defaultService,
quayTypeName: 'Stand',
quayTypeShortName: 'Stand',
},
};

export const delayedLeg = {
__typename: 'PTRideLeg',
arrival: { time: future2 },
Expand All @@ -94,8 +133,8 @@ export const redirectedOnDepartureLeg = {
arrival: { time: future2 },
departure: { time: future },
serviceJourney: {
...redirectedService,
...departureNotServiced,
...redirectedService,
},
};

Expand Down
Loading
Loading