mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
improve E2E test reliability 💚
This commit is contained in:
parent
0287899d1d
commit
87e5649f89
21 changed files with 29 additions and 22 deletions
|
@ -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: {}
|
||||
}
|
||||
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Add table
Reference in a new issue