style: format server and shared with prettier

A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
This commit is contained in:
Maurice
2026-10-10 21:23:37 +02:00
parent f4e518b2df
commit 724c88c201
1978 changed files with 78448 additions and 39347 deletions
@@ -8,10 +8,17 @@
* compare (the run fails on it, see report.test.ts), and --update never
* raises or adds.
*/
import {
compareWithBaseline,
countsTowardRatchet,
formatBaseline,
lowerBaseline,
parseBaseline,
} from '../../../../scripts/pg-probe/baseline';
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
import { compareWithBaseline, countsTowardRatchet, formatBaseline, lowerBaseline, parseBaseline } from '../../../../scripts/pg-probe/baseline';
const now = (entries: Record<string, number>): Map<string, number> => new Map(Object.entries(entries));
const none = new Set<string>();
@@ -35,21 +42,31 @@ describe('pg-probe baseline', () => {
expect(() => parseBaseline('{"failing": {"listByUser": 1}}', 'b.json')).toThrow(/not a Class.method key/);
expect(() => parseBaseline('{"failing": {"A.b": 0}}', 'b.json')).toThrow(/expected a positive integer/);
expect(() => parseBaseline('{"failing": {"A.b": 1.5}}', 'b.json')).toThrow(/expected a positive integer/);
expect(() => parseBaseline('{"failing": {}, "uncovered": {}}', 'b.json')).toThrow(/"uncovered" must be null or an array/);
expect(() => parseBaseline('{"failing": {}, "uncovered": ["nodot"]}', 'b.json')).toThrow(/expected a Class.method name/);
expect(() => parseBaseline('{"failing": {}, "uncovered": {}}', 'b.json')).toThrow(
/"uncovered" must be null or an array/,
);
expect(() => parseBaseline('{"failing": {}, "uncovered": ["nodot"]}', 'b.json')).toThrow(
/expected a Class.method name/,
);
expect(() => parseBaseline('{"failing": {}, "uncovered": [1]}', 'b.json')).toThrow(/expected a Class.method name/);
expect(() => parseBaseline('{"failing": {}, "uncovered": ["A.b", "A.b"]}', 'b.json')).toThrow(/lists A.b twice/);
});
it('PGPROBE-003: an unmeasured baseline (either part null) is flagged instead of compared', () => {
const flagged = { unseeded: true, grown: [], stale: [], newlyUncovered: [], nowCovered: [] };
expect(compareWithBaseline({ failing: null, uncovered: null }, now({ 'A.b': 3 }), new Set(['C.d']))).toEqual(flagged);
expect(compareWithBaseline({ failing: null, uncovered: null }, now({ 'A.b': 3 }), new Set(['C.d']))).toEqual(
flagged,
);
expect(compareWithBaseline({ failing: { 'A.b': 1 }, uncovered: null }, now({ 'A.b': 3 }), none)).toEqual(flagged);
expect(compareWithBaseline({ failing: null, uncovered: [] }, now({ 'A.b': 3 }), none)).toEqual(flagged);
});
it('PGPROBE-004: a method failing more statements than its entry (or any without one) fails', () => {
const verdict = compareWithBaseline({ failing: { 'A.b': 1 }, uncovered: [] }, now({ 'A.b': 2, 'C.d': 1, 'E.f': 0 }), none);
const verdict = compareWithBaseline(
{ failing: { 'A.b': 1 }, uncovered: [] },
now({ 'A.b': 2, 'C.d': 1, 'E.f': 0 }),
none,
);
expect(verdict.grown).toEqual([
{ method: 'A.b', allowed: 1, now: 2 },
{ method: 'C.d', allowed: 0, now: 1 },
@@ -58,7 +75,11 @@ describe('pg-probe baseline', () => {
});
it('PGPROBE-005: an entry above what its method fails now is stale, also when the method is gone', () => {
const verdict = compareWithBaseline({ failing: { 'A.b': 2, 'Gone.away': 1 }, uncovered: [] }, now({ 'A.b': 1 }), none);
const verdict = compareWithBaseline(
{ failing: { 'A.b': 2, 'Gone.away': 1 }, uncovered: [] },
now({ 'A.b': 1 }),
none,
);
expect(verdict.grown).toEqual([]);
expect(verdict.stale).toEqual([
{ method: 'A.b', allowed: 2, now: 1 },
@@ -79,7 +100,10 @@ describe('pg-probe baseline', () => {
newlyUncovered: ['New.callback', 'Old.throws'],
nowCovered: ['Gone.away', 'Now.measured'],
});
expect(compareWithBaseline({ failing: {}, uncovered: ['A.b'] }, now({}), new Set(['A.b']))).toMatchObject({ newlyUncovered: [], nowCovered: [] });
expect(compareWithBaseline({ failing: {}, uncovered: ['A.b'] }, now({}), new Set(['A.b']))).toMatchObject({
newlyUncovered: [],
nowCovered: [],
});
});
it('PGPROBE-006: --update lowers and drops entries but never raises or adds one, in either part', () => {
@@ -92,19 +116,25 @@ describe('pg-probe baseline', () => {
});
it('PGPROBE-007: the first --update seeds an unmeasured baseline with what fails and what went unmeasured, sorted', () => {
expect(lowerBaseline({ failing: null, uncovered: null }, now({ 'Z.z': 1, 'A.a': 2, 'M.m': 0 }), new Set(['Y.y', 'B.b']))).toEqual({
expect(
lowerBaseline({ failing: null, uncovered: null }, now({ 'Z.z': 1, 'A.a': 2, 'M.m': 0 }), new Set(['Y.y', 'B.b'])),
).toEqual({
failing: { 'A.a': 2, 'Z.z': 1 },
uncovered: ['B.b', 'Y.y'],
});
expect(lowerBaseline({ failing: { 'A.a': 3 }, uncovered: null }, now({ 'A.a': 2, 'N.n': 1 }), new Set(['B.b']))).toEqual({
expect(
lowerBaseline({ failing: { 'A.a': 3 }, uncovered: null }, now({ 'A.a': 2, 'N.n': 1 }), new Set(['B.b'])),
).toEqual({
failing: { 'A.a': 2 },
uncovered: ['B.b'],
});
});
it('PGPROBE-010: only syntax and feature errors count toward the ratchet, not data errors from the sample values', () => {
for (const code of ['42601', '42883', '42804', '42P01', '42703', '0A000']) expect(countsTowardRatchet(code)).toBe(true);
for (const code of ['22P02', '22007', '22008', '23505', '57014', 'NOSQLSTATE']) expect(countsTowardRatchet(code)).toBe(false);
for (const code of ['42601', '42883', '42804', '42P01', '42703', '0A000'])
expect(countsTowardRatchet(code)).toBe(true);
for (const code of ['22P02', '22007', '22008', '23505', '57014', 'NOSQLSTATE'])
expect(countsTowardRatchet(code)).toBe(false);
});
it('PGPROBE-008: the checked-in baseline parses and formats back to itself', () => {