Add tests

This commit is contained in:
Jorge Manrubia
2025-06-25 16:34:19 +02:00
parent c0d46390d4
commit 30103d3088
20 changed files with 16965 additions and 28424 deletions
@@ -74,6 +74,14 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
assert_command({ commands: [ "/tag #design" ] }, "tag with #design")
end
test "move cards between considering and doing" do
assert_command({ commands: [ "/consider" ] }, "consider")
assert_command({ commands: [ "/consider" ] }, "move to consider")
assert_command({ commands: [ "/do" ] }, "doing")
assert_command({ commands: [ "/do" ] }, "move to doing")
end
test "combine commands and filters" do
assert_command({ context: { assignee_ids: [ "jz" ], tag_ids: [ "design" ] }, commands: [ "/assign andy", "/tag #v2" ] }, "assign andy to the current #design cards assigned to jz and tag them with #v2")
assert_command({ context: { assignee_ids: [ "andy" ] }, commands: [ "/close", "/assign kevin" ] }, "close cards assigned to andy and assign them to kevin")
+40
View File
@@ -0,0 +1,40 @@
require "test_helper"
class Command::ConsiderTest < ActionDispatch::IntegrationTest
include CommandTestHelper
setup do
Current.session = sessions(:david)
@card = cards(:text)
@card.engage
end
test "consider card on perma" do
assert_changes -> { @card.reload.considering? }, from: false, to: true do
execute_command "/consider", context_url: collection_card_url(@card.collection, @card)
end
end
test "consider cards on index page" do
cards = cards(:logo, :text, :layout)
cards.each(&:engage)
execute_command "/consider", context_url: collection_cards_url(@card.collection)
assert cards.map(&:reload).all?(&:considering?)
end
test "undo consider" do
cards = cards(:logo, :text, :layout)
cards.each(&:engage)
command = parse_command "/consider", context_url: collection_cards_url(@card.collection)
command.execute
assert cards.map(&:reload).all?(&:considering?)
command.undo
assert cards.map(&:reload).all?(&:doing?)
end
end
+40
View File
@@ -0,0 +1,40 @@
require "test_helper"
class Command::DoTest < ActionDispatch::IntegrationTest
include CommandTestHelper
setup do
Current.session = sessions(:david)
@card = cards(:text)
@card.reconsider
end
test "do card on perma" do
assert_changes -> { @card.reload.doing? }, from: false, to: true do
execute_command "/do", context_url: collection_card_url(@card.collection, @card)
end
end
test "do cards on index page" do
cards = cards(:logo, :text, :layout)
cards.each(&:reconsider)
execute_command "/do", context_url: collection_cards_url(@card.collection)
assert cards.map(&:reload).all?(&:doing?)
end
test "undo do" do
cards = cards(:logo, :text, :layout)
cards.each(&:reconsider)
command = parse_command "/do", context_url: collection_cards_url(@card.collection)
command.execute
assert cards.map(&:reload).all?(&:doing?)
command.undo
assert cards.map(&:reload).all?(&:considering?)
end
end