<commit_before>defmodule Aelita2.ProjectControllerTest do
  use Aelita2.ConnCase

  alias Aelita2.Installation
  alias Aelita2.Batch
  alias Aelita2.LinkPatchBatch
  alias Aelita2.LinkUserProject
  alias Aelita2.Patch
  alias Aelita2.Project
  alias Aelita2.User

  setup do
    installation = Repo.insert!(%Installation{
      installation_xref: 31,
      })
    project = Repo.insert!(%Project{
      installation_id: installation.id,
      repo_xref: 13,
      name: "example/project",
      })
    {:ok, installation: installation, project: project}
  end

  test "need to log in to see this", %{conn: conn} do
    conn = get conn, project_path(conn, :index)
    assert html_response(conn, 302) =~ "auth"
  end

  def login(conn) do
    conn = get conn, auth_path(conn, :index, "github")
    assert html_response(conn, 302) =~ "MOCK_GITHUB_AUTHORIZE_URL"
    conn = get conn, auth_path(conn, :callback, "github", %{"code" => "MOCK_GITHUB_AUTHORIZE_CODE"})
    html_response(conn, 302)
    conn
  end

  test "do not list unlinked projects", %{conn: conn} do
    conn = login conn
    conn = get conn, project_path(conn, :index)
    refute html_response(conn, 200) =~ "example/project"
  end

  test "list linked projects", %{conn: conn, project: project} do
    conn = login conn
    user = Repo.get_by!(User, user_xref: 23)
    Repo.insert! %LinkUserProject{user_id: user.id, project_id: project.id}
    conn = get conn, project_path(conn, :index)
    assert html_response(conn, 200) =~ "example/project"
  end

  test "show an unbatched patch", %{conn: conn, project: project} do
    conn = login conn
    Repo.insert! %Batch{project_id: project.id}
    Repo.insert! %Patch{project_id: project.id}
    conn = get conn, project_path(conn, :show, project)
    assert html_response(conn, 200) =~ "In review"
    refute html_response(conn, 200) =~ "Waiting"
  end

  test "show a batched patch", %{conn: conn, project: project} do
    conn = login conn
    batch = Repo.insert! %Batch{project_id: project.id, commit: "BC", state: 0}
    patch = Repo.insert! %Patch{project_id: project.id, commit: "PC"}
    Repo.insert! %LinkPatchBatch{patch_id: patch.id, batch_id: batch.id}
    conn = get conn, project_path(conn, :show, project)
    refute html_response(conn, 200) =~ "In review"
    assert html_response(conn, 200) =~ "Waiting"
  end
end<commit_msg>Update test expectation for "Awaiting review"<commit_after>defmodule Aelita2.ProjectControllerTest do
  use Aelita2.ConnCase

  alias Aelita2.Installation
  alias Aelita2.Batch
  alias Aelita2.LinkPatchBatch
  alias Aelita2.LinkUserProject
  alias Aelita2.Patch
  alias Aelita2.Project
  alias Aelita2.User

  setup do
    installation = Repo.insert!(%Installation{
      installation_xref: 31,
      })
    project = Repo.insert!(%Project{
      installation_id: installation.id,
      repo_xref: 13,
      name: "example/project",
      })
    {:ok, installation: installation, project: project}
  end

  test "need to log in to see this", %{conn: conn} do
    conn = get conn, project_path(conn, :index)
    assert html_response(conn, 302) =~ "auth"
  end

  def login(conn) do
    conn = get conn, auth_path(conn, :index, "github")
    assert html_response(conn, 302) =~ "MOCK_GITHUB_AUTHORIZE_URL"
    conn = get conn, auth_path(conn, :callback, "github", %{"code" => "MOCK_GITHUB_AUTHORIZE_CODE"})
    html_response(conn, 302)
    conn
  end

  test "do not list unlinked projects", %{conn: conn} do
    conn = login conn
    conn = get conn, project_path(conn, :index)
    refute html_response(conn, 200) =~ "example/project"
  end

  test "list linked projects", %{conn: conn, project: project} do
    conn = login conn
    user = Repo.get_by!(User, user_xref: 23)
    Repo.insert! %LinkUserProject{user_id: user.id, project_id: project.id}
    conn = get conn, project_path(conn, :index)
    assert html_response(conn, 200) =~ "example/project"
  end

  test "show an unbatched patch", %{conn: conn, project: project} do
    conn = login conn
    Repo.insert! %Batch{project_id: project.id}
    Repo.insert! %Patch{project_id: project.id}
    conn = get conn, project_path(conn, :show, project)
    assert html_response(conn, 200) =~ "Awaiting review"
    refute html_response(conn, 200) =~ "Waiting"
  end

  test "show a batched patch", %{conn: conn, project: project} do
    conn = login conn
    batch = Repo.insert! %Batch{project_id: project.id, commit: "BC", state: 0}
    patch = Repo.insert! %Patch{project_id: project.id, commit: "PC"}
    Repo.insert! %LinkPatchBatch{patch_id: patch.id, batch_id: batch.id}
    conn = get conn, project_path(conn, :show, project)
    refute html_response(conn, 200) =~ "Awaiting review"
    assert html_response(conn, 200) =~ "Waiting"
  end
end
{'fraction_non_alphanumeric': 0.11905763567522086, 'fraction_numerical': 0.01809002944888515, 'mean_word_length': 3.8225152129817443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6806067', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1623, 'n_words': 448}