<commit_before>/// <reference types="Cypress" />
/// <reference types="testing-library__cypress" />
/// <reference path="../support/zucchiniApi.d.ts" />
/// <reference path="../support/selectors.d.ts" />

describe("Scenario", () => {
  beforeEach(() => {
    cy.log("Créer une feature");

    cy.createFilledTestRun().then(({ id }) => {
      cy.getScenariosForTestRun(id).then((scenarios) => {
        const firstScenario = scenarios.find((scenario) => scenario.status === "PASSED");
        if (!firstScenario) {
          throw new Error("No scenario found");
        }
        cy.wrap(firstScenario).as("scenario");

        cy.visit(`/ui/scenarios/${firstScenario.id}`);
      });
    });
  });

  it("should display scenario info", () => {
    cy.get("@scenario").then((scenarios) => {
      cy.get("h1").should("contain", scenarios.info.keyword).and("contain", scenarios.info.name);
    });

    cy.get("h1 .badge").should("have.text", "Succès");
  });

  it("should change the reviewed status to not analyzed", () => {
    cy.contains("button", "Marquer comme non analysé").click();

    cy.contains("button", "Marquer comme analysé").should("exist");
  });

  it("should change the reviewed status to analyzed", () => {
    cy.contains("button", "Marquer comme non analysé").click();
    cy.contains("button", "Marquer comme analysé").click();

    cy.get("[role=dialog]").within(() => {
      cy.findByLabelText("Commentaire").type("Coucou{enter}Voir https://example.org pour plus d'infos");
      cy.get("form").submit();
    });

    cy.contains("button", "Marquer comme non analysé").should("exist");
  });

  it("should change scenario status", () => {
    cy.route("PATCH", "/api/scenarii/*").as("updateScenario");
    cy.route("POST", "/api/scenarii/*/comments/create").as("addComment");
    cy.route("GET", "/api/scenarii/*").as("scenarioRefresh");

    cy.contains("button", "Modifier le statut").click();

    cy.get("[role=dialog]").within(() => {
      cy.findByLabelText("Scénario analysé ?").should("be.checked");

      cy.findByLabelText("Échec").click();

      cy.findByLabelText("Commentaire").type("Ca ne marche pas. Encore un bug, dis donc");

      cy.get("form").submit();
    });

    cy.wait("@updateScenario");
    cy.wait("@addComment");
    cy.wait("@scenarioRefresh");

    cy.get("h1 .badge").should("contain.text", "Échec");<commit_msg>Check radio box<commit_after>/// <reference types="Cypress" />
/// <reference types="testing-library__cypress" />
/// <reference path="../support/zucchiniApi.d.ts" />
/// <reference path="../support/selectors.d.ts" />

describe("Scenario", () => {
  beforeEach(() => {
    cy.log("Créer une feature");

    cy.createFilledTestRun().then(({ id }) => {
      cy.getScenariosForTestRun(id).then((scenarios) => {
        const firstScenario = scenarios.find((scenario) => scenario.status === "PASSED");
        if (!firstScenario) {
          throw new Error("No scenario found");
        }
        cy.wrap(firstScenario).as("scenario");

        cy.visit(`/ui/scenarios/${firstScenario.id}`);
      });
    });
  });

  it("should display scenario info", () => {
    cy.get("@scenario").then((scenarios) => {
      cy.get("h1").should("contain", scenarios.info.keyword).and("contain", scenarios.info.name);
    });

    cy.get("h1 .badge").should("have.text", "Succès");
  });

  it("should change the reviewed status to not analyzed", () => {
    cy.contains("button", "Marquer comme non analysé").click();

    cy.contains("button", "Marquer comme analysé").should("exist");
  });

  it("should change the reviewed status to analyzed", () => {
    cy.contains("button", "Marquer comme non analysé").click();
    cy.contains("button", "Marquer comme analysé").click();

    cy.get("[role=dialog]").within(() => {
      cy.findByLabelText("Commentaire").type("Coucou{enter}Voir https://example.org pour plus d'infos");
      cy.get("form").submit();
    });

    cy.contains("button", "Marquer comme non analysé").should("exist");
  });

  it("should change scenario status", () => {
    cy.route("PATCH", "/api/scenarii/*").as("updateScenario");
    cy.route("POST", "/api/scenarii/*/comments/create").as("addComment");
    cy.route("GET", "/api/scenarii/*").as("scenarioRefresh");

    cy.contains("button", "Modifier le statut").click();

    cy.get("[role=dialog]").within(() => {
      cy.findByLabelText("Scénario analysé ?").should("be.checked");

      cy.findByLabelText("Échec").check();

      cy.findByLabelText("Commentaire").type("Ca ne marche pas. Encore un bug, dis donc");

      cy.get("form").submit();
    });

    cy.wait("@updateScenario");
    cy.wait("@addComment");
    cy.wait("@scenarioRefresh");

    cy.get("h1 .badge").should("contain.text", "Échec");
{'fraction_non_alphanumeric': 0.22128733697938577, 'fraction_numerical': 0.0012620950778291964, 'mean_word_length': 3.6030977734753145, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 2, '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': '7247384', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1520, 'n_words': 245}