adapt E2E tests to latest data

This commit is contained in:
Jannis R 2021-08-24 00:43:20 +02:00
parent c3bdcc880f
commit 0114f587b2
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
14 changed files with 91 additions and 53 deletions

View file

@ -367,7 +367,7 @@ tap.test('nearby', async (t) => {
type: 'location',
latitude: 52.4873452,
longitude: 13.3310411
}, {distance: 200})
}, {distance: 300})
validate(t, nearby, 'locations', 'nearby')

View file

@ -70,10 +70,10 @@ const client = createClient(cflProfile, 'public-transport/hafas-client:test')
const ettelbruck = '9258199'
const mersch = '9864348'
const luxembourg = '9217081'
const luxembourgGareCentrale = '200405059'
tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
const res = await client.journeys(ettelbruck, luxembourg, {
const res = await client.journeys(ettelbruck, luxembourgGareCentrale, {
results: 4,
departure: when,
stopovers: true
@ -84,7 +84,7 @@ tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
res,
validate,
fromId: ettelbruck,
toId: luxembourg
toId: luxembourgGareCentrale
})
t.end()
})
@ -96,7 +96,7 @@ tap.test('journeys  fails with no product', (t) => {
test: t,
fetchJourneys: client.journeys,
fromId: ettelbruck,
toId: luxembourg,
toId: luxembourgGareCentrale,
when,
products
})
@ -111,7 +111,7 @@ tap.test('Luxembourg to 9071 Ettelbruck, Rue des Romains 4', async (t) => {
longitude: 6.097608
}
const res = await client.journeys(luxembourg, rueDeRomain, {
const res = await client.journeys(luxembourgGareCentrale, rueDeRomain, {
results: 3,
departure: when
})
@ -120,13 +120,14 @@ tap.test('Luxembourg to 9071 Ettelbruck, Rue des Romains 4', async (t) => {
test: t,
res,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
to: rueDeRomain
})
t.end()
})
tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
// Each journey's last leg has a destination without the ID.
tap.skip('Luxembourg to Centre Hospitalier du Nord', async (t) => {
const centreHospitalier = {
type: 'location',
id: '140701020',
@ -135,7 +136,7 @@ tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
latitude: 49.853096,
longitude: 6.094075
}
const res = await client.journeys(luxembourg, centreHospitalier, {
const res = await client.journeys(luxembourgGareCentrale, centreHospitalier, {
results: 3,
departure: when
})
@ -144,7 +145,7 @@ tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
test: t,
res,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
to: centreHospitalier
})
t.end()
@ -158,7 +159,7 @@ tap.test('earlier/later journeys', async (t) => {
test: t,
fetchJourneys: client.journeys,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
toId: ettelbruck,
when,
})
@ -167,7 +168,7 @@ tap.test('earlier/later journeys', async (t) => {
})
tap.test('trip', async (t) => {
const { journeys } = await client.journeys(luxembourg, ettelbruck, {
const { journeys } = await client.journeys(luxembourgGareCentrale, ettelbruck, {
results: 1, departure: when
})

View file

@ -92,14 +92,14 @@ tap.test('Domain to 1104 Elm Street, Austin, TX 78703', async (t) => {
t.end()
})
tap.test('Domain to Whole Foods Market - North Lamar Blvd', async (t) => {
tap.test('Domain to WHOLE FOODS MARKET - ARBOR TRAILS', async (t) => {
const wholeFoodsMarket = {
type: 'location',
id: '9830513', // or `9855231`
id: '9893387',
poi: true,
name: 'Whole Foods Market - N Lamar Blvd',
latitude: 30.270653,
longitude: -97.753564
name: 'WHOLE FOODS MARKET - ARBOR TRAILS',
latitude: 30.22026,
longitude: -97.84174,
}
const res = await client.journeys(domain, wholeFoodsMarket, {
results: 3,

View file

@ -141,7 +141,7 @@ tap.test('Berlin Schwedter Str. to ATZE Musiktheater', async (t) => {
type: 'location',
id: '991598902',
poi: true,
name: 'ATZE Musiktheater',
name: 'Berlin, Atze Musiktheater für Kinder (Kultur und U',
latitude: 52.542417,
longitude: 13.350437
}

View file

@ -98,7 +98,7 @@ tap.test('Hamburg Tiefstack to Gilbertstr. 30, Hamburg', async (t) => {
tap.test('Hamburg Tiefstack to Hamburger Meile', async (t) => {
const meile = {
type: 'location',
id: '980001831',
id: '980001841',
poi: true,
name: 'Hamburger Meile',
latitude: 53.572455,

View file

@ -174,7 +174,8 @@ tap.test('departures at Ingolstadt Hbf', async (t) => {
const ids = [
ingolstadtHbf, // station
'80301', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts"
'80302' // stop "Ingolstadt, Hauptbahnhof Stadteinwärts"
'80302', // stop "Ingolstadt, Hauptbahnhof Stadteinwärts"
'80303', // stop "Ingolstadt, Hauptbahnhof Stadtauswärts"
]
const deps = await client.departures(ingolstadtHbf, {

View file

@ -1,7 +1,8 @@
'use strict'
const testArrivals = async (cfg) => {
const {test: t, arrivals: arrs, validate, id} = cfg
const {test: t, arrivals: arrs, validate} = cfg
const ids = cfg.ids || (cfg.id ? [cfg.id] : [])
validate(t, arrs, 'arrivals', 'arrivals')
t.ok(arrs.length > 0, 'must be >0 arrivals')
@ -13,7 +14,11 @@ const testArrivals = async (cfg) => {
name += '.station'
}
t.equal(stop.id, id, name + '.id is invalid')
t.ok(
ids.includes(stop.id) ||
(stop.station && ids.includes(stop.station.id)),
name + '.id is invalid',
)
}
// todo: move into arrivals validator

View file

@ -1,7 +1,8 @@
'use strict'
const testDepartures = async (cfg) => {
const {test: t, departures: deps, validate, id} = cfg
const {test: t, departures: deps, validate} = cfg
const ids = cfg.ids || (cfg.id ? [cfg.id] : [])
validate(t, deps, 'departures', 'departures')
t.ok(deps.length > 0, 'must be >0 departures')
@ -13,7 +14,11 @@ const testDepartures = async (cfg) => {
name += '.station'
}
t.equal(stop.id, id, name + '.id is invalid')
t.ok(
ids.includes(stop.id) ||
(stop.station && ids.includes(stop.station.id)),
name + '.id is invalid',
)
}
// todo: move into deps validator

View file

@ -10,7 +10,7 @@ const hour = 60 * 60 * 1000
const day = 24 * hour
const week = 7 * day
const T_MOCK = 1619683200 * 1000 // 2021-04-29T10:00:00+02
const T_MOCK = 1629878400 * 1000 // 2021-08-25T10:00:00+02
// next Monday 10 am
const createWhen = (timezone, locale) => {

View file

@ -14,7 +14,6 @@ const testEarlierLaterJourneys = require('./lib/earlier-later-journeys')
const testRefreshJourney = require('./lib/refresh-journey')
const testDepartures = require('./lib/departures')
const testArrivals = require('./lib/arrivals')
// const testJourneysWithDetour = require('./lib/journeys-with-detour')
const testReachableFrom = require('./lib/reachable-from')
const when = createWhen(mobilNrwProfile.timezone, mobilNrwProfile.locale)
@ -149,6 +148,13 @@ tap.test('trip details', async (t) => {
})
tap.test('departures at Soest', async (t) => {
const ids = [
soest,
'906135', // Bahnhof, Soest
'904812', // Bahnhof/Brüdertor, Soest
'902737', // Bahnhof E, Soest
]
const departures = await client.departures(soest, {
duration: 10, when,
})
@ -157,7 +163,7 @@ tap.test('departures at Soest', async (t) => {
test: t,
departures,
validate,
id: soest
ids,
})
t.end()
})
@ -179,6 +185,13 @@ tap.test('departures with station object', async (t) => {
})
tap.test('arrivals at Soest', async (t) => {
const ids = [
soest,
'906135', // Bahnhof, Soest
'904812', // Bahnhof/Brüdertor, Soest
'902737', // Bahnhof E, Soest
]
const arrivals = await client.arrivals(soest, {
duration: 10, when,
})
@ -187,7 +200,7 @@ tap.test('arrivals at Soest', async (t) => {
test: t,
arrivals,
validate,
id: soest
ids,
})
t.end()
})

View file

@ -70,10 +70,10 @@ const client = createClient(mobiliteitLuProfile, 'public-transport/hafas-client:
const ettelbruck = '140701016'
const mersch = '160904011'
const luxembourg = '200405060'
const luxembourgGareCentrale = '200405060'
tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
const res = await client.journeys(ettelbruck, luxembourg, {
const res = await client.journeys(ettelbruck, luxembourgGareCentrale, {
results: 4,
departure: when,
stopovers: true
@ -84,7 +84,11 @@ tap.test('journeys  Ettelbruck to Luxembourg', async (t) => {
res,
validate,
fromId: ettelbruck,
toId: luxembourg
toIds: [
luxembourgGareCentrale,
'300030001', // Luxembourg, Gare Centrale (Tram)
'300032002', // Luxembourg, Gare Rocade
],
})
t.end()
})
@ -96,7 +100,7 @@ tap.test('journeys  fails with no product', (t) => {
test: t,
fetchJourneys: client.journeys,
fromId: ettelbruck,
toId: luxembourg,
toId: luxembourgGareCentrale,
when,
products
})
@ -111,7 +115,7 @@ tap.test('Luxembourg to Ettelbruck, Rue des Romains 4', async (t) => {
longitude: 6.097608
}
const res = await client.journeys(luxembourg, rueDeRomain, {
const res = await client.journeys(luxembourgGareCentrale, rueDeRomain, {
results: 3,
departure: when
})
@ -120,22 +124,23 @@ tap.test('Luxembourg to Ettelbruck, Rue des Romains 4', async (t) => {
test: t,
res,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
to: rueDeRomain
})
t.end()
})
tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
// Some journeys don't start or stop at the stop/POI that we queried journeys for.
tap.skip('Luxembourg to Centre Hospitalier du Nord', async (t) => {
const centreHospitalier = {
type: 'location',
id: '140701020',
id: '980050385',
poi: true,
name: 'Ettelbruck, Centre Hospitalier du Nord',
latitude: 49.853096,
longitude: 6.094075
name: 'Ettelbruck, Centre Hospitalier du Nord (CHDN)',
latitude: 49.853519,
longitude: 6.094587,
}
const res = await client.journeys(luxembourg, centreHospitalier, {
const res = await client.journeys(luxembourgGareCentrale, centreHospitalier, {
results: 3,
departure: when
})
@ -144,7 +149,7 @@ tap.test('Luxembourg to Centre Hospitalier du Nord', async (t) => {
test: t,
res,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
to: centreHospitalier
})
t.end()
@ -158,7 +163,7 @@ tap.test('earlier/later journeys', async (t) => {
test: t,
fetchJourneys: client.journeys,
validate,
fromId: luxembourg,
fromId: luxembourgGareCentrale,
toId: ettelbruck,
when,
})
@ -167,7 +172,7 @@ tap.test('earlier/later journeys', async (t) => {
})
tap.test('trip', async (t) => {
const { journeys } = await client.journeys(luxembourg, ettelbruck, {
const { journeys } = await client.journeys(luxembourgGareCentrale, ettelbruck, {
results: 1, departure: when
})

View file

@ -172,11 +172,11 @@ tap.test('journeys: via works without detour', async (t) => {
// *no need* to change trains / no need for a "detour".
const karlsplatz = '1390461'
const praterstern = '1290201'
const museumsquartier = '1390171'
const museumsquartierPassed = '901014'
const stephansplatz = '1390167'
const stephansplatzPassed = '901006'
const res = await client.journeys(karlsplatz, praterstern, {
via: museumsquartier,
via: stephansplatz,
results: 1,
departure: when,
stopovers: true
@ -186,15 +186,15 @@ tap.test('journeys: via works without detour', async (t) => {
const l1 = res.journeys[0].legs.some((leg) => {
return (
leg.destination.id === museumsquartier ||
leg.destination.id === museumsquartierPassed
leg.destination.id === stephansplatz ||
leg.destination.id === stephansplatzPassed
)
})
t.notOk(l1, 'transfer at Museumsquartier')
const l2 = res.journeys[0].legs.some((leg) => {
return leg.stopovers && leg.stopovers.some((stopover) => {
return stopover.stop.id === museumsquartierPassed
return stopover.stop.id === stephansplatzPassed
})
})
t.ok(l2, 'Museumsquartier is not being passed')

View file

@ -125,7 +125,11 @@ tap.test('departures at Næstved.', async (t) => {
test: t,
departures,
validate,
id: næstved,
ids: [
næstved,
'8650810', // Næstved St. (togbus)
'8651810', // Næstved St. (togbus)
],
})
t.end()
})
@ -139,7 +143,11 @@ tap.test('arrivals at Næstved.', async (t) => {
test: t,
arrivals,
validate,
id: næstved,
ids: [
næstved,
'8650810', // Næstved St. (togbus)
'8651810', // Næstved St. (togbus)
],
})
t.end()
})

View file

@ -110,9 +110,9 @@ tap.test('Karl-Theodor-Straße to Pötschnerstraße 3, Neuhausen', async (t) =>
tap.test('Karl-Theodor-Straße to Hofbräuhaus', async (t) => {
const hofbraeuhaus = {
type: 'location',
id: '970006201',
id: '970008829',
poi: true,
name: 'München, Hofbräuhaus',
name: 'München, Hofbräuhaus München',
latitude: 48.137739,
longitude: 11.579823
}