improve E2E test reliability 💚

This commit is contained in:
Jannis R 2020-04-09 14:53:28 +02:00
parent 0287899d1d
commit 87e5649f89
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
21 changed files with 29 additions and 22 deletions

View file

@ -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: {}
}

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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 = {

View file

@ -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')

View file

@ -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})

View file

@ -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})

View file

@ -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 })

View file

@ -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})

View file

@ -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 })

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})

View file

@ -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})