diff --git a/test/bvg-radar.js b/test/bvg-radar.js index 4f0a3eaa..c5186e44 100644 --- a/test/bvg-radar.js +++ b/test/bvg-radar.js @@ -18,7 +18,7 @@ const opt = { frames: 3, products: null, polylines: true, - departure: '2019-08-19T21:00:00+02:00', + when: '2019-08-19T21:00:00+02:00', products: {} } diff --git a/test/e2e/bvg.js b/test/e2e/bvg.js index 97c3e429..7aaf779f 100644 --- a/test/e2e/bvg.js +++ b/test/e2e/bvg.js @@ -229,7 +229,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/cfl.js b/test/e2e/cfl.js index d5e57585..1e481ea5 100644 --- a/test/e2e/cfl.js +++ b/test/e2e/cfl.js @@ -172,7 +172,7 @@ test('trip', async (t) => { results: 1, departure: when }) - const p = journeys[0].legs[0] + const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/cmta.js b/test/e2e/cmta.js index b1ba2b52..bb19bc59 100644 --- a/test/e2e/cmta.js +++ b/test/e2e/cmta.js @@ -154,7 +154,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/db.js b/test/e2e/db.js index 5609250d..fb99b280 100644 --- a/test/e2e/db.js +++ b/test/e2e/db.js @@ -256,7 +256,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/hvv.js b/test/e2e/hvv.js index 6dfa13be..0bcc8acf 100644 --- a/test/e2e/hvv.js +++ b/test/e2e/hvv.js @@ -142,7 +142,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/insa.js b/test/e2e/insa.js index 3d98c4e8..9d5583d7 100644 --- a/test/e2e/insa.js +++ b/test/e2e/insa.js @@ -164,7 +164,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/invg.js b/test/e2e/invg.js index 9ecbafa5..35f8ca74 100644 --- a/test/e2e/invg.js +++ b/test/e2e/invg.js @@ -162,7 +162,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = journeys[0].legs.find(leg => leg.line) + const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/lib/util.js b/test/e2e/lib/util.js index 89381beb..c1d42daa 100644 --- a/test/e2e/lib/util.js +++ b/test/e2e/lib/util.js @@ -20,7 +20,7 @@ const assertValidWhen = (actual, expected, name) => { const ts = +new Date(actual) a.ok(!Number.isNaN(ts), name + ' is not parsable by Date') // the timestamps might be from long-distance trains - a.ok(isRoughlyEqual(day, +expected, ts), name + ' is out of range') + a.ok(isRoughlyEqual(day + 6 * hour, +expected, ts), name + ' is out of range') } module.exports = { diff --git a/test/e2e/lib/validators.js b/test/e2e/lib/validators.js index 83121a09..7078ae3a 100644 --- a/test/e2e/lib/validators.js +++ b/test/e2e/lib/validators.js @@ -217,11 +217,18 @@ const validateTicket = (val, ti, name = 'ticket') => { const createValidateJourneyLeg = (cfg) => { const validateJourneyLeg = (val, leg, name = 'journeyLeg') => { - const withFakeScheduleAndOperator = Object.assign({ + const fakeLeg = Object.assign({ schedule: 'foo', // todo: let hafas-client parse a schedule ID operator: 'bar' // todo: let hafas-client parse the operator }, leg) - defaultValidators.journeyLeg(val, withFakeScheduleAndOperator, name) + if (leg.cancelled) { + // FPTF doesn't support cancelled journey legs yet. + // see https://github.com/public-transport/friendly-public-transport-format/issues/27 + // todo: remove once this is resolved upstream + fakeLeg.departure = leg.formerScheduledDeparture + fakeLeg.arrival = leg.formerScheduledArrival + } + defaultValidators.journeyLeg(val, fakeLeg, name) if (leg.arrival !== null) { assertValidWhen(leg.arrival, cfg.when, name + '.arrival') diff --git a/test/e2e/nahsh.js b/test/e2e/nahsh.js index 279698c7..189daac7 100644 --- a/test/e2e/nahsh.js +++ b/test/e2e/nahsh.js @@ -214,7 +214,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/oebb.js b/test/e2e/oebb.js index ed62756a..1df3b59f 100644 --- a/test/e2e/oebb.js +++ b/test/e2e/oebb.js @@ -237,7 +237,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/pkp.js b/test/e2e/pkp.js index f246818e..b448ca7c 100644 --- a/test/e2e/pkp.js +++ b/test/e2e/pkp.js @@ -98,7 +98,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, { when }) diff --git a/test/e2e/rmv.js b/test/e2e/rmv.js index edf56935..b94ffa71 100644 --- a/test/e2e/rmv.js +++ b/test/e2e/rmv.js @@ -59,7 +59,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/saarfahrplan.js b/test/e2e/saarfahrplan.js index 56dd8d34..184e6c9f 100644 --- a/test/e2e/saarfahrplan.js +++ b/test/e2e/saarfahrplan.js @@ -198,7 +198,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, { when }) diff --git a/test/e2e/sbahn-muenchen.js b/test/e2e/sbahn-muenchen.js index ecae7d80..00f13b19 100644 --- a/test/e2e/sbahn-muenchen.js +++ b/test/e2e/sbahn-muenchen.js @@ -169,7 +169,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs.find(leg => leg.line) + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/sncb.js b/test/e2e/sncb.js index 9a25152d..7a6079c4 100644 --- a/test/e2e/sncb.js +++ b/test/e2e/sncb.js @@ -64,7 +64,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/svv.js b/test/e2e/svv.js index 91592f9b..8a069cd4 100644 --- a/test/e2e/svv.js +++ b/test/e2e/svv.js @@ -65,7 +65,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/vbb.js b/test/e2e/vbb.js index faf273d3..75fef309 100644 --- a/test/e2e/vbb.js +++ b/test/e2e/vbb.js @@ -173,7 +173,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/vbn.js b/test/e2e/vbn.js index ce1a41fa..f2f4abc1 100644 --- a/test/e2e/vbn.js +++ b/test/e2e/vbn.js @@ -59,7 +59,7 @@ test('trip details', async (t) => { results: 1, departure: when }) - const p = res.journeys[0].legs[0] + const p = res.journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when}) diff --git a/test/e2e/vsn.js b/test/e2e/vsn.js index cd87ba0e..0b73ff7e 100644 --- a/test/e2e/vsn.js +++ b/test/e2e/vsn.js @@ -92,7 +92,7 @@ test('trip', async (t) => { results: 1, departure: when }) - const p = journeys[0].legs[0] + const p = journeys[0].legs.find(l => !l.walking) t.ok(p.tripId, 'precondition failed') t.ok(p.line.name, 'precondition failed') const trip = await client.trip(p.tripId, p.line.name, {when})