- Implemented the schedule import feature with a dedicated page for importing schedules from the transport website. - Added a new QualityPage to check the quality of routes, stops, schedules, and notifications without making automatic changes. - Created CSS styles for both the ScheduleImportPage and QualityPage to enhance the user interface. - Introduced API calls for fetching schedule data and quality reports. - Added error handling and loading states for better user experience during data fetching. - Included functionality for filtering quality issues and displaying detailed reports.
23 lines
1.5 KiB
JavaScript
23 lines
1.5 KiB
JavaScript
const assert = require('node:assert/strict');
|
||
const test = require('node:test');
|
||
const { buildQualityReport, qualityChecks } = require('../src/services/qualityReport');
|
||
|
||
test('quality report makes actionable, stable issues and summary', () => {
|
||
const rows = Object.fromEntries(qualityChecks.map(({ name }) => [name, []]));
|
||
rows.routesWithoutStops.push({ route_id: 8, route_number: '4', route_name: 'Вокзал → Центр', active_stops_count: 0 });
|
||
rows.missingSchedules.push({ route_id: 8, route_number: '4', route_name: 'Вокзал → Центр', day_type: 'weekday' });
|
||
rows.overlappingSchedules.push({ route_id: 9, route_number: '5', route_name: 'А → Б', day_type: 'sunday', schedule_id: 12, conflicting_schedule_id: 10 });
|
||
rows.unusedStops.push({ stop_id: 3, stop_name: 'Резервная' });
|
||
rows.expiredAlerts.push({ alert_id: 15, title: 'Временный объезд' });
|
||
|
||
const report = buildQualityReport(rows, '2026-09-16T10:00:00.000Z');
|
||
|
||
assert.deepEqual(report.summary, { total: 5, critical: 3, warning: 1, info: 1 });
|
||
assert.equal(report.checked_at, '2026-09-16T10:00:00.000Z');
|
||
assert.deepEqual(report.issues.map((issue) => issue.severity), ['critical', 'critical', 'critical', 'warning', 'info']);
|
||
assert.deepEqual(report.issues.find((issue) => issue.code === 'missing_schedule').action, {
|
||
to: '/schedules?route=8', label: 'Открыть расписания',
|
||
});
|
||
assert.match(report.issues.find((issue) => issue.code === 'overlapping_schedules').description, /№12 и №10/);
|
||
});
|