fix(dashboard): implement missing handleToggleSource on Free Pool tab (#7161) (#7200)

This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-14 21:15:54 -03:00
committed by GitHub
parent cdb4998ea4
commit d84ccbc67c
3 changed files with 15 additions and 3 deletions

View File

@@ -0,0 +1 @@
- fix(dashboard): implement missing `handleToggleSource` callback on the Free Pool tab so the page no longer crashes with a `ReferenceError` (#7161)

View File

@@ -139,6 +139,16 @@ export default function FreePoolTab() {
});
};
const handleToggleSource = (source: SourceId) => {
setDisabledSources((prev) => {
const next = new Set(prev);
if (next.has(source)) next.delete(source);
else next.add(source);
saveDisabledSources(next);
return next;
});
};
const handleToggleSelect = (id: string) => {
setSelected((prev) => {
const next = new Set(prev);

View File

@@ -91,13 +91,13 @@ afterEach(() => {
// ── Tests ─────────────────────────────────────────────────────────────────────
describe("FreePoolTab source toggles", () => {
it("renders a toggle group with exactly 3 buttons", async () => {
it("renders a toggle group with exactly 4 buttons", async () => {
const el = renderTab();
await waitForCondition(() => el.querySelector("[role='group']") !== null);
const bar = el.querySelector("[role='group']")!;
expect(bar).toBeTruthy();
const buttons = bar.querySelectorAll("button");
expect(buttons.length).toBe(3);
expect(buttons.length).toBe(4);
});
it("all toggles start enabled (aria-pressed=true)", async () => {
@@ -160,7 +160,7 @@ describe("FreePoolTab source toggles", () => {
expect(stored).toContain("1proxy");
});
it("button labels are 1proxy, Proxifly, IPLocate", async () => {
it("button labels are 1proxy, Proxifly, IPLocate, Webshare", async () => {
const el = renderTab();
await waitForCondition(() => el.querySelector("[role='group']") !== null);
const texts = Array.from(el.querySelector("[role='group']")!.querySelectorAll("button")).map(
@@ -169,6 +169,7 @@ describe("FreePoolTab source toggles", () => {
expect(texts).toContain("1proxy");
expect(texts).toContain("Proxifly");
expect(texts).toContain("IPLocate");
expect(texts).toContain("Webshare");
});
});