chore: noise in tests

This commit is contained in:
2026-05-04 06:18:06 +02:00
parent 4de8492c4f
commit 43a4610ce7
48 changed files with 619 additions and 239 deletions

View File

@@ -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])}")

View File

@@ -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

View File

@@ -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"