forked from yvv/decision
Chaque section du lecteur finit par l'ordre de ses articles (inertie 2) : ses articles numérotés, son vote déplié, « Proposer un autre ordre » — une liste où l'on clique un article puis sa place, ses flèches, ou le clavier. Le titre du document (inertie 4) se vote et se propose sous le titre, « traduction à revoir » quand il a changé. Les deux sont dans la liste des propositions, le panier et la chaîne Ğ1 ; un nouvel article se propose dans une section, à sa fin. La liste du groupe compte les propositions ouvertes des modules. Restes mineurs : la participation ramenée se dit en deux temps (la mesure, puis ce que le groupe demande), les lignes « habituelle » des réglages resserrées, le sélecteur d'inertie se parcourt aux flèches (le cran actuel atteignable, jamais choisi), la marque « seed a minima » porte le vrai nombre de votes. Contrôles : C25 (ordre, dont la chaîne et le téléphone), C26 (titre), C27 (participation ramenée) ; C3, C17 (41 modules), C20 mis à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
// What the formula settings say about the usual participation (relecture of a576b68):
|
|
// the measured median, or twice C, even when the scale brings it back within its bounds.
|
|
import { describe, expect, it } from 'vitest';
|
|
import { usualShown } from '../../src/lib/participation';
|
|
import type { ParticipationInfo } from '../../src/lib/types';
|
|
|
|
const base: ParticipationInfo = {
|
|
ratio: 0.3,
|
|
source: 'median',
|
|
sample: 5,
|
|
median: 3,
|
|
bounded: false,
|
|
voters: 3,
|
|
minSample: 5,
|
|
windowDays: 365,
|
|
everyHours: 24,
|
|
bounds: [0.01, 0.5],
|
|
measuredAt: null,
|
|
};
|
|
|
|
describe('usual participation as shown', () => {
|
|
it('is the scale itself when nothing was bounded', () => {
|
|
expect(usualShown(base, 10, 1)).toEqual({ voters: 3, ratio: 0.3 });
|
|
});
|
|
it('is the real median when the scale raised it to its floor', () => {
|
|
const p = { ...base, median: 1, ratio: 0.01, voters: 57, bounded: true };
|
|
expect(usualShown(p, 5745, 50)).toEqual({ voters: 1, ratio: 1 / 5745 });
|
|
});
|
|
it('is twice C for the reference, even when the scale lowered it to its ceiling', () => {
|
|
const p = { ...base, source: 'reference' as const, median: null, sample: 0, ratio: 0.5, voters: 1, bounded: true };
|
|
expect(usualShown(p, 2, 1)).toEqual({ voters: 2, ratio: 1 });
|
|
});
|
|
it('rounds a median between two numbers of voters, never its share', () => {
|
|
const p = { ...base, median: 2.5, ratio: 0.01, voters: 57, bounded: true };
|
|
expect(usualShown(p, 5745, 50).voters).toBe(3);
|
|
// Relecture of 71819f9: the share is that of the median itself — 2,5 voters out of 4 is
|
|
// 62,5 %, not 3 out of 4 (75 %).
|
|
const q = { ...base, median: 2.5, ratio: 0.5, voters: 2, bounded: true };
|
|
expect(usualShown(q, 4, 1)).toEqual({ voters: 3, ratio: 0.625 });
|
|
});
|
|
it('takes the share of twice C as it is, whatever the rounding', () => {
|
|
const p = { ...base, source: 'reference' as const, median: null, sample: 0, ratio: 0.5, voters: 2, bounded: true };
|
|
expect(usualShown(p, 3, 0.75)).toEqual({ voters: 2, ratio: 0.5 });
|
|
});
|
|
});
|