import {
  detectGte
} from "./chunk-DJQTUDJM.js";
import {
  getRunPp
} from "./chunk-W55XSG6K.js";
import {
  require_tape
} from "./chunk-QWOE5YTB.js";
import "./chunk-74ZU4BT6.js";
import "./chunk-IW57W7EQ.js";
import "./chunk-ZTYNN6G5.js";
import "./chunk-DKVUOBIE.js";
import "./chunk-PRZWSBMA.js";
import "./chunk-LTOBEUM2.js";
import "./chunk-MKAF2BHB.js";
import "./chunk-WKNI3HRQ.js";
import "./chunk-VGYTAYFK.js";
import "./chunk-67DBIM6H.js";
import "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import "./chunk-LSEFWW72.js";
import "./chunk-SKREEF3H.js";
import "./chunk-HYOEWQ5P.js";
import "./chunk-HBW42TDT.js";
import "./chunk-G6O3URDN.js";
import "./chunk-FN5XPUPH.js";
import "./chunk-IIT367QZ.js";
import "./chunk-RZGEKL77.js";
import "./chunk-UI7OCM2A.js";
import "./chunk-YZK37YCC.js";
import "./chunk-7EMWHCVW.js";
import "./chunk-7IYJZZQI.js";
import "./chunk-M3J4MINX.js";
import "./chunk-PF4DSFDR.js";
import "./chunk-QH6W3NVF.js";
import "./chunk-NOEAT6CX.js";
import "./chunk-4UWS5Y3N.js";
import "./chunk-DD4R5P6W.js";
import "./chunk-JNITUVXP.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-TLT4YIG3.js";
import "./chunk-KYBIQBXE.js";
import "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import {
  __toESM
} from "./chunk-HFNDKYVF.js";

// plots/test/dataDownload.integration.spec.js
var import_tape = __toESM(require_tape(), 1);
var runpp = getRunPp("mass", {
  state: {
    nav: {
      header_mode: "hide_search",
      activeTab: 1
    },
    vocab: {
      dslabel: "TermdbTest",
      genome: "hg38-test"
    }
  },
  debug: 1
});
(0, import_tape.default)("\n", (test) => {
  test.comment("-***- plots/dataDownload -***-");
  test.end();
});
(0, import_tape.default)("Data download with no selected terms", (test) => {
  test.timeoutAfter(1e3);
  runpp({
    state: {
      plots: [
        {
          chartType: "dataDownload"
        }
      ]
    },
    dataDownload: {
      callbacks: {
        "postRender.test": runTests
      }
    }
  });
  function runTests(dataDownload) {
    dataDownload.on("postRender.test", null);
    const ddDom = dataDownload.Inner.dom;
    test.equal(ddDom.terms.node().querySelectorAll(".term_name_btn").length, 0, `Should render no term pills`);
    test.equal(
      ddDom.terms.node().querySelectorAll(".sja_filter_tag_btn.add_term_btn").length,
      1,
      `Should render 1 'Add variable' button`
    );
    test.equal(
      ddDom.submitNote.node().innerText,
      `no sample data`,
      `Should render "no sample data" next to Download button`
    );
    test.ok(ddDom.submitBtn.node().disabled, `Should show Download button as disabled`);
    if (test._ok) dataDownload.Inner.app.destroy();
    test.end();
  }
});
(0, import_tape.default)("Data download with terms selected", (test) => {
  test.timeoutAfter(2e3);
  const terms = [
    { $id: 0, id: "sex" },
    { $id: 1, id: "agedx" },
    { $id: 2, id: "genetic_race" },
    { $id: 3, id: "aaclassic_5" },
    { $id: 4, id: "Arrhythmias" }
  ];
  runpp({
    state: {
      plots: [
        {
          chartType: "dataDownload",
          terms
        }
      ]
    },
    dataDownload: {
      callbacks: {
        "postRender.test": runTests
      }
    }
  });
  async function runTests(dataDownload) {
    dataDownload.on("postRender.test", null);
    const ddDom = dataDownload.Inner.dom;
    await detectGte({
      elem: ddDom.terms.node(),
      selector: ".term_name_btn",
      count: 5
    });
    test.equal(
      ddDom.terms.node().querySelectorAll(".term_name_btn").length,
      terms.length,
      `Should render ${terms.length} term pills`
    );
    test.equal(
      ddDom.submitNote.node().innerText,
      `${dataDownload.Inner.activeSamples.length} samples`,
      `Should render "${dataDownload.Inner.activeSamples.length} samples" next to Download button`
    );
    if (test._ok) dataDownload.Inner.app.destroy();
    test.end();
  }
});
(0, import_tape.default)("protected dataset", (test) => {
  test.timeoutAfter(3e3);
  const runpp2 = getRunPp("mass", {
    state: {
      nav: {
        header_mode: "hide_search",
        activeTab: 1
      },
      vocab: {
        dslabel: "ProtectedTest",
        genome: "hg38-test"
      }
    },
    debug: 1
  });
  runpp2({
    state: {
      plots: [
        {
          chartType: "dataDownload"
        }
      ]
    },
    dataDownload: {
      callbacks: {
        "postRender.test": runTests
      }
    }
  });
  async function runTests(dataDownload) {
    dataDownload.on("postRender.test", null);
    test.true(
      dataDownload.Inner.dom.titleDiv.text().includes("Requires sign-in"),
      "should not open by default for protected dataset"
    );
    if (test._ok) dataDownload.Inner.app.destroy();
    test.end();
  }
});
//# sourceMappingURL=dataDownload.integration.spec-2PKYZ2AY.js.map
