<commit_before>describe("Deployments Modal", function() {
  function openDeploymentsModal(numDeployments = 1) {
    cy.get(".button")
      .contains(numDeployments + " deployment")
      .click();
  }

  beforeEach(function() {
    cy.configureCluster({
      mesos: "1-for-each-health",
      deployments: "one-deployment",
      nodeHealth: true
    });

    cy.visitUrl({ url: "/services/overview/" });
  });

  context("Modal Trigger", function() {
    it("has a deployments button", function() {
      cy.get(".button")
        .contains("1 deployment")
        .should("to.have.length", 1);
    });

    it("opens the modal when clicking the deployments button", function() {
      openDeploymentsModal();

      cy.get(".modal").then(function($modal) {
        expect($modal.get().length).to.equal(1);
      });
    });
  });

  context("Modal Content", function() {
    beforeEach(function() {
      openDeploymentsModal();
    });

    it("closes when the close button is clicked", function() {
      cy.get(".modal").then(function($modal) {
        expect($modal.get().length).to.equal(1);
      });
      cy.get(".modal-footer button")
        .contains("Close")
        .click();
      cy.wait(700).then(function() {
        expect(document.querySelectorAll(".modal").length).to.equal(0);
      });
    });

    it("renders the deployments count", function() {
      cy.get(".modal-header").then(function($header) {
        expect($header.get(0).textContent).to.equal("1 Active Deployment");
      });
    });

    it("renders one row per deployment", function() {
      cy.get(".modal tbody tr:visible").then(function($tableRows) {
        expect($tableRows.get().length).to.equal(1);
      });
    });

    it("renders the `id` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect(
            $tableCells.get(0).querySelector(".collapsing-string-full-string")
              .textContent
          ).to.equal(response[0].id);
        });
      });
    });

    it("renders the `started` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect(
            $tableCells
              .get(1)
              .querySelector("time")
              .getAttribute("datetime")
          ).to.equal(response[0].version);
        });
      });
    });

    it("renders the `status` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        expect(
          $tableCells.get(2).querySelectorAll(".status-bar").length
        ).to.equal(1);
      });
    });

    it("is auto-expanded to show services", function() {
      cy.get(
        ".modal tbody tr:visible td .expanding-table-child .table-cell-value"
      ).then(function($expandedChildText) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect($expandedChildText.get(0).textContent).to.equal(
            response[0].affectedApps[0].replace(/^\//, "")
          );
        });
      });
    });

    it("dismisses both modals when the rollback is performed", function() {
      cy.getAPIResponse("marathon/v2/deployments", function(response) {
        cy.route({
          method: "DELETE",
          url: /marathon\/v2\/deployments/,
          status: 400,
          response: {
            version: response[0].version,
            deploymentId: response[0].id
          }
        });

        cy.get(".modal tbody tr:visible td .dropdown").click();
        cy.get(".dropdown-menu-items")
          .contains("Rollback")
          .click();
        cy.get(".modal button")
          .contains("Continue Rollback")
          .click();

        cy.wait(700).then(function() {
          expect(document.querySelectorAll(".modal").length).to.equal(0);
        });
      });
    });
  });

  context("Rollback modal", function() {
    it("displays the rollback modal when clicked", function() {
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.get(".modal").then(function($modals) {
        expect($modals.get().length).to.equal(2);
      });
    });

    it("displays a revert message for a non-starting deployment", function() {
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.contains("revert the affected service");
    });

    it("displays a removal message for a starting deployment", function() {
      cy.server().route(
        /marathon\/v2\/deployments/,
        "fx:deployments/starting-deployment"
      );
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.contains("delete the affected service");
    });
  });

  context("Stale Deployments", function() {
    beforeEach(function() {
      cy.route(
        /marathon\/v2\/deployments/,
        "fx:deployments/two-deployments-one-stale"
      );
      openDeploymentsModal();
    });

    it("shows stale deployment in modal", function() {
      cy.get(".deployments-table-column-id").contains("spark-history-stale");
    });
    it("shows status of stale deployment", function() {
      cy.get(".deployments-table-column-status").contains("StopApplication");
    });
  });
});<commit_msg>test(react): remove unnecessarily strict constraint in helper<commit_after>describe("Deployments Modal", function() {
  function openDeploymentsModal() {
    cy.get(".button")
      .contains("deployment")
      .click();
  }

  beforeEach(function() {
    cy.configureCluster({
      mesos: "1-for-each-health",
      deployments: "one-deployment",
      nodeHealth: true
    });

    cy.visitUrl({ url: "/services/overview/" });
  });

  context("Modal Trigger", function() {
    it("has a deployments button", function() {
      cy.get(".button")
        .contains("1 deployment")
        .should("to.have.length", 1);
    });

    it("opens the modal when clicking the deployments button", function() {
      openDeploymentsModal();

      cy.get(".modal").then(function($modal) {
        expect($modal.get().length).to.equal(1);
      });
    });
  });

  context("Modal Content", function() {
    beforeEach(function() {
      openDeploymentsModal();
    });

    it("closes when the close button is clicked", function() {
      cy.get(".modal").then(function($modal) {
        expect($modal.get().length).to.equal(1);
      });
      cy.get(".modal-footer button")
        .contains("Close")
        .click();
      cy.wait(700).then(function() {
        expect(document.querySelectorAll(".modal").length).to.equal(0);
      });
    });

    it("renders the deployments count", function() {
      cy.get(".modal-header").then(function($header) {
        expect($header.get(0).textContent).to.equal("1 Active Deployment");
      });
    });

    it("renders one row per deployment", function() {
      cy.get(".modal tbody tr:visible").then(function($tableRows) {
        expect($tableRows.get().length).to.equal(1);
      });
    });

    it("renders the `id` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect(
            $tableCells.get(0).querySelector(".collapsing-string-full-string")
              .textContent
          ).to.equal(response[0].id);
        });
      });
    });

    it("renders the `started` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect(
            $tableCells
              .get(1)
              .querySelector("time")
              .getAttribute("datetime")
          ).to.equal(response[0].version);
        });
      });
    });

    it("renders the `status` column", function() {
      cy.get(".modal tbody tr:visible td").then(function($tableCells) {
        expect(
          $tableCells.get(2).querySelectorAll(".status-bar").length
        ).to.equal(1);
      });
    });

    it("is auto-expanded to show services", function() {
      cy.get(
        ".modal tbody tr:visible td .expanding-table-child .table-cell-value"
      ).then(function($expandedChildText) {
        cy.getAPIResponse("marathon/v2/deployments", function(response) {
          expect($expandedChildText.get(0).textContent).to.equal(
            response[0].affectedApps[0].replace(/^\//, "")
          );
        });
      });
    });

    it("dismisses both modals when the rollback is performed", function() {
      cy.getAPIResponse("marathon/v2/deployments", function(response) {
        cy.route({
          method: "DELETE",
          url: /marathon\/v2\/deployments/,
          status: 400,
          response: {
            version: response[0].version,
            deploymentId: response[0].id
          }
        });

        cy.get(".modal tbody tr:visible td .dropdown").click();
        cy.get(".dropdown-menu-items")
          .contains("Rollback")
          .click();
        cy.get(".modal button")
          .contains("Continue Rollback")
          .click();

        cy.wait(700).then(function() {
          expect(document.querySelectorAll(".modal").length).to.equal(0);
        });
      });
    });
  });

  context("Rollback modal", function() {
    it("displays the rollback modal when clicked", function() {
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.get(".modal").then(function($modals) {
        expect($modals.get().length).to.equal(2);
      });
    });

    it("displays a revert message for a non-starting deployment", function() {
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.contains("revert the affected service");
    });

    it("displays a removal message for a starting deployment", function() {
      cy.server().route(
        /marathon\/v2\/deployments/,
        "fx:deployments/starting-deployment"
      );
      openDeploymentsModal();
      cy.get(".modal tbody tr:visible td .dropdown").click();
      cy.get(".dropdown-menu-items")
        .contains("Rollback")
        .click();
      cy.contains("delete the affected service");
    });
  });

  context("Stale Deployments", function() {
    beforeEach(function() {
      cy.server().route(
        /marathon\/v2\/deployments/,
        "fx:deployments/two-deployments-one-stale"
      );
      openDeploymentsModal();
    });

    it("shows stale deployment in modal", function() {
      cy.get(".deployments-table-column-id").contains("spark-history-stale");
    });
    it("shows status of stale deployment", function() {
      cy.get(".deployments-table-column-status").contains("StopApplication");
    });
  });
});
{'fraction_non_alphanumeric': 0.1743111189365261, 'fraction_numerical': 0.006778765736420459, 'mean_word_length': 2.4083408340834085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7476873', 'n_tokens_mistral': 3389, 'n_tokens_neox': 3271, 'n_words': 556}