Files
OmniRoute/tests/unit/provider-quota-visibility.test.ts
Jan Leon 78d2eee914 Add per-connection Provider Quota visibility (#7360)
* feat(dashboard): add Provider Quota visibility toggle per connection

* refactor(dashboard): extract provider quota visibility controls

Move quota visibility UI and update logic into reusable components, add Portuguese translations, and remove the stale migration gap allowlist entry.

* Hide quota visibility controls for unsupported providers

* chore(ci): retrigger GitHub checks

* fix(db): renumber quota-visibility migration past release tip (121→125)

122_free_proxy_sync_errors.sql, 123_quota_auto_ping.sql, and
124_generic_session_affinity_ttl.sql have since landed on
release/v3.8.49, so 121 is now out-of-sequence and would not apply on
databases already past 122+. Renumbers to 125 (the next free slot past
the current release tip) and restores "121" in check-migration-numbering's
KNOWN_GAPS allowlist, since 121 remains a genuine unfilled gap once this
migration moves off that number.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* chore(quality): rebaseline file-size + complexity for resync merge

The release-resync merge unions two already-compliant features in the
same god-component (ConnectionRow.tsx/ConnectionsListPanel.tsx): this
PR's per-connection quota-visibility wiring and release's confirm-
delete-account wiring (#7361). Both were individually within budget
(785/786 lines); combined they land at 791. Complexity count moves
2058->2059 for the same reason (2 previously-compliant .map() render
callbacks in ConnectionsListPanel.tsx now marginally exceed the
80-line function cap). No new logic was written — see the
_rebaseline_2026_07_18_pr7360_quota_visibility_resync justification
entries in both baseline files for the full accounting. Verified via
a byte-for-byte diff of the violation lists between origin/release/
v3.8.49 tip and this merge. Structural shrink stays tracked in #3501.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* refactor(db): split _updateConnectionRow update assembly (complexity gate)

_updateConnectionRow grew past the 80-line max-lines-per-function ceiling
after this branch added quota_visible column handling. Extract the
`.run()` params assembly (field mapping/normalization, unchanged) into a
module-private `_buildUpdateConnectionRowParams` helper in the same file
so the SQL statement + call site stay in `_updateConnectionRow` while the
function itself drops back under the gate. No behavior change.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
2026-07-18 15:12:52 -03:00

19 lines
680 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import {
isProviderQuotaVisible,
supportsProviderQuota,
} from "../../src/shared/utils/providerQuotaVisibility.ts";
test("provider quota visibility is opt-out so existing connections stay visible", () => {
assert.equal(isProviderQuotaVisible({}), true);
assert.equal(isProviderQuotaVisible({ quotaVisible: true }), true);
assert.equal(isProviderQuotaVisible({ quotaVisible: false }), false);
});
test("quota visibility controls are limited to providers with quota support", () => {
assert.equal(supportsProviderQuota("codex"), true);
assert.equal(supportsProviderQuota("openai"), false);
});