mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-16 20:02:45 +03:00
* feat(combos): add select all / unselect all in Browse Catalog * fix(dashboard): guard combo Select all + test the real batch handlers (#8526) Select all had no cap — with "Show configured only" off, or a large provider catalog, one click could add hundreds of models to a combo. ModelSelectModal now confirms above SELECT_ALL_CONFIRM_THRESHOLD (20) before batch-adding, matching the native confirm() pattern already used for bulk/destructive actions elsewhere in the dashboard. Also extracts ComboFormModal's handleAddModels/handleDeselectModels batching logic into computeBatchAddModelSteps/computeBatchDeselectModelSteps (src/lib/combos/builderDraft.ts) so unit tests exercise the real implementation instead of a hand-maintained mirror that could drift from the component and stay green while production code broke. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
SELECT_ALL_CONFIRM_THRESHOLD,
|
|
shouldConfirmSelectAll,
|
|
} from "../../src/shared/components/modelSelectModalHelpers.ts";
|
|
|
|
// Regression guard for #8526: ModelSelectModal's "Select all" (Browse
|
|
// Catalog, combo builder) had no cap — turning off "Show configured only",
|
|
// or just having a large provider catalog, could add hundreds of models to a
|
|
// combo in one click. Above SELECT_ALL_CONFIRM_THRESHOLD the caller must
|
|
// confirm before batch-adding.
|
|
|
|
test("shouldConfirmSelectAll: does not require confirmation at or below the threshold", () => {
|
|
assert.equal(shouldConfirmSelectAll(0), false);
|
|
assert.equal(shouldConfirmSelectAll(1), false);
|
|
assert.equal(shouldConfirmSelectAll(SELECT_ALL_CONFIRM_THRESHOLD), false);
|
|
});
|
|
|
|
test("shouldConfirmSelectAll: requires confirmation above the threshold", () => {
|
|
assert.equal(shouldConfirmSelectAll(SELECT_ALL_CONFIRM_THRESHOLD + 1), true);
|
|
assert.equal(shouldConfirmSelectAll(500), true);
|
|
});
|
|
|
|
test("shouldConfirmSelectAll: respects a caller-supplied threshold override", () => {
|
|
assert.equal(shouldConfirmSelectAll(5, 10), false);
|
|
assert.equal(shouldConfirmSelectAll(11, 10), true);
|
|
});
|
|
|
|
test("shouldConfirmSelectAll: tolerates non-finite counts without throwing", () => {
|
|
assert.equal(shouldConfirmSelectAll(Number.NaN), false);
|
|
assert.equal(shouldConfirmSelectAll(Number.POSITIVE_INFINITY), false);
|
|
});
|