chore: noise in tests
This commit is contained in:
@@ -206,7 +206,8 @@ defmodule BDS.AITest do
|
||||
{:ok,
|
||||
%{
|
||||
json: %{
|
||||
"title" => "Analyzed " <> (get_in(request.messages, [Access.at(1), "content"]) || ""),
|
||||
"title" =>
|
||||
"Analyzed " <> (get_in(request.messages, [Access.at(1), "content"]) || ""),
|
||||
"excerpt" => "Analyzed excerpt",
|
||||
"slug" => "analyzed-slug"
|
||||
},
|
||||
@@ -386,17 +387,22 @@ defmodule BDS.AITest do
|
||||
|
||||
{:ok, {_address, port}} = ThousandIsland.listener_info(server)
|
||||
|
||||
assert {:error, %{kind: :invalid_json_response, reason: %Jason.DecodeError{}}} =
|
||||
BDS.AI.OpenAICompatibleRuntime.generate(
|
||||
%{url: "http://127.0.0.1:#{port}/v1", api_key: nil},
|
||||
%{
|
||||
model: "gpt-test",
|
||||
messages: [%{"role" => "user", "content" => "Hello"}],
|
||||
max_output_tokens: 128,
|
||||
tools: []
|
||||
},
|
||||
[]
|
||||
)
|
||||
log =
|
||||
capture_log(fn ->
|
||||
assert {:error, %{kind: :invalid_json_response, reason: %Jason.DecodeError{}}} =
|
||||
BDS.AI.OpenAICompatibleRuntime.generate(
|
||||
%{url: "http://127.0.0.1:#{port}/v1", api_key: nil},
|
||||
%{
|
||||
model: "gpt-test",
|
||||
messages: [%{"role" => "user", "content" => "Hello"}],
|
||||
max_output_tokens: 128,
|
||||
tools: []
|
||||
},
|
||||
[]
|
||||
)
|
||||
end)
|
||||
|
||||
assert log =~ "AI OpenAI-compatible response normalization failed"
|
||||
end
|
||||
|
||||
test "openai-compatible generation accepts title requests without tools" do
|
||||
|
||||
@@ -13,6 +13,26 @@ defmodule BDS.Desktop.ImportShellLiveTest do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(BDS.Repo)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(BDS.Repo, {:shared, self()})
|
||||
|
||||
Enum.each(BDS.Tasks.list_running_tasks(), fn task ->
|
||||
BDS.Tasks.cancel_task(task.id)
|
||||
end)
|
||||
|
||||
if :ets.whereis(:bds_ai_in_flight) != :undefined do
|
||||
Enum.each(:ets.tab2list(:bds_ai_in_flight), fn {_conversation_id, pid} ->
|
||||
Process.exit(pid, :kill)
|
||||
end)
|
||||
end
|
||||
|
||||
for {_, pid, _, _} <- DynamicSupervisor.which_children(BDS.TCP.TaskSupervisor) do
|
||||
DynamicSupervisor.terminate_child(BDS.TCP.TaskSupervisor, pid)
|
||||
end
|
||||
|
||||
for {_, pid, _, _} <- DynamicSupervisor.which_children(BDS.Tasks.TaskSupervisor) do
|
||||
DynamicSupervisor.terminate_child(BDS.Tasks.TaskSupervisor, pid)
|
||||
end
|
||||
|
||||
Process.sleep(100)
|
||||
|
||||
temp_dir =
|
||||
Path.join(System.tmp_dir!(), "bds-import-shell-live-#{System.unique_integer([:positive])}")
|
||||
|
||||
|
||||
@@ -241,7 +241,8 @@ defmodule BDS.Desktop.ShellCommandsTest do
|
||||
assert result.action == "fill_missing_translations"
|
||||
assert is_binary(result.task_id)
|
||||
|
||||
completed = wait_for_task(result.task_id, &(&1.status == :completed and is_map(&1.result)), 5_000)
|
||||
completed =
|
||||
wait_for_task(result.task_id, &(&1.status == :completed and is_map(&1.result)), 5_000)
|
||||
|
||||
assert completed.group_name == "AI"
|
||||
assert completed.result.project_id == project.id
|
||||
@@ -319,7 +320,9 @@ defmodule BDS.Desktop.ShellCommandsTest do
|
||||
})
|
||||
|
||||
assert {:ok, result} = ShellCommands.execute("fill_missing_translations")
|
||||
completed = wait_for_task(result.task_id, &(&1.status == :completed and is_map(&1.result)), 5_000)
|
||||
|
||||
completed =
|
||||
wait_for_task(result.task_id, &(&1.status == :completed and is_map(&1.result)), 5_000)
|
||||
|
||||
assert completed.result.translated_posts == 1
|
||||
assert completed.result.translated_media == 1
|
||||
@@ -530,8 +533,10 @@ defmodule BDS.Desktop.ShellCommandsTest do
|
||||
wait_for_task(
|
||||
result.task_id,
|
||||
fn task ->
|
||||
task.status in [:running, :completed] and is_number(task.progress) and task.progress > 0.2 and
|
||||
Repo.get_by(BDS.Posts.Post, project_id: project.id, file_path: post_orphan_path) != nil and
|
||||
task.status in [:running, :completed] and is_number(task.progress) and
|
||||
task.progress > 0.2 and
|
||||
Repo.get_by(BDS.Posts.Post, project_id: project.id, file_path: post_orphan_path) !=
|
||||
nil and
|
||||
Repo.get_by(BDS.Posts.Translation,
|
||||
project_id: project.id,
|
||||
file_path: post_translation_orphan_path
|
||||
@@ -545,6 +550,7 @@ defmodule BDS.Desktop.ShellCommandsTest do
|
||||
assert progressed.progress > 0.2
|
||||
|
||||
assert Repo.get_by(BDS.Posts.Post, project_id: project.id, file_path: post_orphan_path)
|
||||
|
||||
assert Repo.get_by(BDS.Posts.Translation,
|
||||
project_id: project.id,
|
||||
file_path: post_translation_orphan_path
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
defmodule BDS.Desktop.ShellLiveTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
import Phoenix.ConnTest
|
||||
import Phoenix.LiveViewTest
|
||||
|
||||
@@ -175,6 +176,26 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
:ok = Ecto.Adapters.SQL.Sandbox.checkout(BDS.Repo)
|
||||
Ecto.Adapters.SQL.Sandbox.mode(BDS.Repo, {:shared, self()})
|
||||
|
||||
Enum.each(BDS.Tasks.list_running_tasks(), fn task ->
|
||||
BDS.Tasks.cancel_task(task.id)
|
||||
end)
|
||||
|
||||
if :ets.whereis(:bds_ai_in_flight) != :undefined do
|
||||
Enum.each(:ets.tab2list(:bds_ai_in_flight), fn {_conversation_id, pid} ->
|
||||
Process.exit(pid, :kill)
|
||||
end)
|
||||
end
|
||||
|
||||
for {_, pid, _, _} <- DynamicSupervisor.which_children(BDS.TCP.TaskSupervisor) do
|
||||
DynamicSupervisor.terminate_child(BDS.TCP.TaskSupervisor, pid)
|
||||
end
|
||||
|
||||
for {_, pid, _, _} <- DynamicSupervisor.which_children(BDS.Tasks.TaskSupervisor) do
|
||||
DynamicSupervisor.terminate_child(BDS.Tasks.TaskSupervisor, pid)
|
||||
end
|
||||
|
||||
Process.sleep(100)
|
||||
|
||||
temp_dir =
|
||||
Path.join(System.tmp_dir!(), "bds-shell-live-#{System.unique_integer([:positive])}")
|
||||
|
||||
@@ -422,12 +443,16 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
|
||||
_html =
|
||||
view
|
||||
|> element("#tags-editor-shell button[phx-click='toggle_tag_selection'][phx-value-name='Alpha']")
|
||||
|> element(
|
||||
"#tags-editor-shell button[phx-click='toggle_tag_selection'][phx-value-name='Alpha']"
|
||||
)
|
||||
|> render_click()
|
||||
|
||||
_html =
|
||||
view
|
||||
|> element("#tags-editor-shell button[phx-click='toggle_tag_selection'][phx-value-name='Beta']")
|
||||
|> element(
|
||||
"#tags-editor-shell button[phx-click='toggle_tag_selection'][phx-value-name='Beta']"
|
||||
)
|
||||
|> render_click()
|
||||
|
||||
_html =
|
||||
@@ -1328,7 +1353,9 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
|
||||
html =
|
||||
view
|
||||
|> element("#settings-editor-shell button[phx-click='refresh_settings_ai_models'][phx-value-endpoint='online']")
|
||||
|> element(
|
||||
"#settings-editor-shell button[phx-click='refresh_settings_ai_models'][phx-value-endpoint='online']"
|
||||
)
|
||||
|> render_click()
|
||||
|
||||
assert html =~ ~s(<option value="gpt-4.1"></option>)
|
||||
@@ -1336,7 +1363,9 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
|
||||
html =
|
||||
view
|
||||
|> element("#settings-editor-shell button[phx-click='refresh_settings_ai_models'][phx-value-endpoint='airplane']")
|
||||
|> element(
|
||||
"#settings-editor-shell button[phx-click='refresh_settings_ai_models'][phx-value-endpoint='airplane']"
|
||||
)
|
||||
|> render_click()
|
||||
|
||||
assert html =~ ~s(<option value="llama3.3"></option>)
|
||||
@@ -2717,7 +2746,12 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
|
||||
assert html =~ "ai-suggestions-modal"
|
||||
|
||||
send(view.pid, {:ai_suggestions_error, :post, post.id, :test_error})
|
||||
_ =
|
||||
capture_log(fn ->
|
||||
send(view.pid, {:ai_suggestions_error, :post, post.id, :test_error})
|
||||
render(view)
|
||||
end)
|
||||
|
||||
html = render(view)
|
||||
|
||||
assert html =~ "ai-suggestions-modal"
|
||||
@@ -3236,6 +3270,7 @@ defmodule BDS.Desktop.ShellLiveTest do
|
||||
view
|
||||
|> element("[data-testid='chat-model-selector-button']")
|
||||
|> render_click()
|
||||
|
||||
assert selector_html =~ ~s(class="chat-model-selector-menu")
|
||||
assert selector_html =~ ~s(data-testid="chat-model-selector-option")
|
||||
assert selector_html =~ "llama-current"
|
||||
|
||||
@@ -25,7 +25,11 @@ defmodule BDS.DesktopTest do
|
||||
|
||||
defmodule FakeWindowLifecycle do
|
||||
def hide(window_id) do
|
||||
send(Application.fetch_env!(:bds, :desktop_shutdown_test_pid), {:window_hide_requested, window_id})
|
||||
send(
|
||||
Application.fetch_env!(:bds, :desktop_shutdown_test_pid),
|
||||
{:window_hide_requested, window_id}
|
||||
)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
|
||||
@@ -213,6 +213,8 @@ defmodule BDS.UI.SidebarTest do
|
||||
Repo.update_all(
|
||||
from(definition in BDS.ImportDefinitions.ImportDefinition,
|
||||
where: definition.id == ^definition_id
|
||||
), set: [updated_at: updated_at])
|
||||
),
|
||||
set: [updated_at: updated_at]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user