Adds speedtest pg-boss worker with injectable runner for testing, hourly cron enqueue, and /api/speedtest/history (GET) + /run (POST, owner-only) routes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 lines
718 B
JavaScript
16 lines
718 B
JavaScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import request from 'supertest';
|
|
import { setup } from './helpers.js';
|
|
import * as repo from '../../lib/db/repos/speedtest.js';
|
|
|
|
let app, ownerHeaders;
|
|
beforeAll(async () => { ({ app, ownerHeaders } = await setup()); await repo.record({ down_mbps: 50, up_mbps: 10, ping_ms: 12 }); });
|
|
describe('speedtest api', () => {
|
|
it('401 without auth', async () => expect((await request(app).get('/api/speedtest/history')).status).toBe(401));
|
|
it('history returns rows', async () => {
|
|
const res = await request(app).get('/api/speedtest/history').set(ownerHeaders);
|
|
expect(res.status).toBe(200);
|
|
expect(res.body.length).toBeGreaterThanOrEqual(1);
|
|
});
|
|
});
|