From 0114f587b264cb0d5382be57dc8661074ddd360c Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 24 Aug 2021 00:43:20 +0200 Subject: [PATCH] =?UTF-8?q?adapt=20E2E=20tests=20to=20latest=20data=20?= =?UTF-8?q?=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/e2e/bvg.js | 2 +- test/e2e/cfl.js | 23 ++++++++++++----------- test/e2e/cmta.js | 10 +++++----- test/e2e/db.js | 2 +- test/e2e/hvv.js | 2 +- test/e2e/invg.js | 3 ++- test/e2e/lib/arrivals.js | 9 +++++++-- test/e2e/lib/departures.js | 9 +++++++-- test/e2e/lib/util.js | 2 +- test/e2e/mobil-nrw.js | 19 ++++++++++++++++--- test/e2e/mobiliteit-lu.js | 35 ++++++++++++++++++++--------------- test/e2e/oebb.js | 12 ++++++------ test/e2e/rejseplanen.js | 12 ++++++++++-- test/e2e/sbahn-muenchen.js | 4 ++-- 14 files changed, 91 insertions(+), 53 deletions(-) diff --git a/test/e2e/bvg.js b/test/e2e/bvg.js index 0137e018..49373a06 100644 --- a/test/e2e/bvg.js +++ b/test/e2e/bvg.js @@ -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') diff --git a/test/e2e/cfl.js b/test/e2e/cfl.js index 7c6d5c0a..86a9ba5f 100644 --- a/test/e2e/cfl.js +++ b/test/e2e/cfl.js @@ -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 }) diff --git a/test/e2e/cmta.js b/test/e2e/cmta.js index 6ddd2f4b..18aab262 100644 --- a/test/e2e/cmta.js +++ b/test/e2e/cmta.js @@ -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, diff --git a/test/e2e/db.js b/test/e2e/db.js index 2733cb1d..2da6077a 100644 --- a/test/e2e/db.js +++ b/test/e2e/db.js @@ -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 } diff --git a/test/e2e/hvv.js b/test/e2e/hvv.js index 0a0dbbd4..2251d0c1 100644 --- a/test/e2e/hvv.js +++ b/test/e2e/hvv.js @@ -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, diff --git a/test/e2e/invg.js b/test/e2e/invg.js index 5af78c46..3f8ad045 100644 --- a/test/e2e/invg.js +++ b/test/e2e/invg.js @@ -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, { diff --git a/test/e2e/lib/arrivals.js b/test/e2e/lib/arrivals.js index 3681c2ae..d4f4c07d 100644 --- a/test/e2e/lib/arrivals.js +++ b/test/e2e/lib/arrivals.js @@ -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 diff --git a/test/e2e/lib/departures.js b/test/e2e/lib/departures.js index f6cc2253..df66463d 100644 --- a/test/e2e/lib/departures.js +++ b/test/e2e/lib/departures.js @@ -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 diff --git a/test/e2e/lib/util.js b/test/e2e/lib/util.js index 24d341ab..ee18546a 100644 --- a/test/e2e/lib/util.js +++ b/test/e2e/lib/util.js @@ -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) => { diff --git a/test/e2e/mobil-nrw.js b/test/e2e/mobil-nrw.js index 2b87dd0f..a7538a0c 100644 --- a/test/e2e/mobil-nrw.js +++ b/test/e2e/mobil-nrw.js @@ -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() }) diff --git a/test/e2e/mobiliteit-lu.js b/test/e2e/mobiliteit-lu.js index 6c93e5c3..8c69d087 100644 --- a/test/e2e/mobiliteit-lu.js +++ b/test/e2e/mobiliteit-lu.js @@ -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 }) diff --git a/test/e2e/oebb.js b/test/e2e/oebb.js index 838d2620..de13f0a0 100644 --- a/test/e2e/oebb.js +++ b/test/e2e/oebb.js @@ -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') diff --git a/test/e2e/rejseplanen.js b/test/e2e/rejseplanen.js index 68058f2c..16930af0 100644 --- a/test/e2e/rejseplanen.js +++ b/test/e2e/rejseplanen.js @@ -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() }) diff --git a/test/e2e/sbahn-muenchen.js b/test/e2e/sbahn-muenchen.js index acd3fb78..ce74112e 100644 --- a/test/e2e/sbahn-muenchen.js +++ b/test/e2e/sbahn-muenchen.js @@ -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 }