diff --git a/test/e2e/db.js b/test/e2e/db.js index 31ed956e..752996b8 100644 --- a/test/e2e/db.js +++ b/test/e2e/db.js @@ -41,6 +41,7 @@ const cfg = { maxLatitude: 55.030671, minLongitude: 6.896517, maxLongitude: 16.180237, + validateJourneyTickets: false, // don't validate a journey's tickets }; const validate = createValidate(cfg); @@ -122,17 +123,21 @@ tap.test('journeys – Berlin Schwedter Str. to München Hbf', async (t) => { }); // todo: find a journey where there pricing info is always available for (let journey of res.journeys) { - if (journey.price) { - assertValidPrice(t, journey.price); - } - if (journey.tickets) { - assertValidTickets(t, journey.tickets); - } + // It seems like the DB endpoint doesn't return (valid) prices/fares/tickets anymore. + // see https://github.com/public-transport/hafas-client/issues/331 + // if (journey.price) { + // assertValidPrice(t, journey.price); + // } + // if (journey.tickets) { + // assertValidTickets(t, journey.tickets); + // } } t.end(); }); -tap.test('refreshJourney – valid tickets', async (t) => { +// It seems like the DB endpoint doesn't return (valid) prices/fares/tickets anymore. +// see https://github.com/public-transport/hafas-client/issues/331 +tap.skip('refreshJourney – valid tickets', async (t) => { const T_MOCK = 1710831600 * 1000; // 2024-03-19T08:00:00+01:00 const when = createWhen(dbProfile.timezone, dbProfile.locale, T_MOCK); diff --git a/test/e2e/lib/validators.js b/test/e2e/lib/validators.js index 0cf07b76..778aece1 100644 --- a/test/e2e/lib/validators.js +++ b/test/e2e/lib/validators.js @@ -411,23 +411,25 @@ const createValidateJourneyLeg = (cfg) => { return validateJourneyLeg; }; -const validateJourney = (val, j, name = 'journey') => { - const withFakeId = Object.assign({ - id: 'foo', // todo: let hafas-client parse a journey ID - }, j); - defaultValidators.journey(val, withFakeId, name); - // todo: j.refreshToken - - if ('tickets' in j) { - a.ok(Array.isArray(j.tickets), name + '.tickets must be an array'); - a.ok(j.tickets.length > 0, name + '.tickets must not be empty'); - - for (let i = 0; i < j.tickets.length; i++) { - val.ticket(val, j.tickets[i], name + `.tickets[${i}]`); +const createValidateJourney = (cfg) => { + const validateJourney = (val, j, name = 'journey') => { + const withFakeId = Object.assign({ + id: 'foo', // todo: let hafas-client parse a journey ID + }, j); + defaultValidators.journey(val, withFakeId, name); + // todo: j.refreshToken + + if (cfg.validateJourneyTickets !== false && 'tickets' in j) { + a.ok(Array.isArray(j.tickets), name + '.tickets must be an array'); + a.ok(j.tickets.length > 0, name + '.tickets must not be empty'); + + for (let i = 0; i < j.tickets.length; i++) { + val.ticket(val, j.tickets[i], name + `.tickets[${i}]`); + } } - } + }; + return validateJourney; }; -const createValidateJourney = () => validateJourney; const validateJourneys = (val, js, name = 'journeys') => { a.ok(Array.isArray(js), name + ' must be an array');