Rewrite prompt to be more accurate and example-driven
This commit is contained in:
@@ -7,6 +7,8 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
@user = users(:david)
|
||||
end
|
||||
|
||||
vcr_record!
|
||||
|
||||
test "filter by assignments" do
|
||||
# List context
|
||||
assert_command({ context: { assignee_ids: [ "jz" ] } }, "cards assigned to jz")
|
||||
@@ -48,6 +50,12 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
assert_command({ context: { terms: [ "123" ] } }, "123") # Notice existing cards will be intercepted earlier
|
||||
end
|
||||
|
||||
test "filter by time ranges" do
|
||||
assert_command({ context: { closure: "thisweek", indexed_by: "closed" } }, "cards completed this week")
|
||||
assert_command({ context: { creation: "thisweek", tag_ids: [ "design" ], creator_ids: [ "jz" ] } }, "cards created this week by jz tagged as #design")
|
||||
assert_command({ context: { creation: "thismonth", creator_ids: [ "Gabriel", "Michael" ] } }, "cards created by Gabriel or Michael this month")
|
||||
end
|
||||
|
||||
test "acts on cards passing their ids" do
|
||||
assert_command({ context: { card_ids: [ 123, 456 ] }, commands: [ "/close" ] }, "close 123 and 456")
|
||||
assert_command({ context: { card_ids: [ 123 ] }, commands: [ "/close" ] }, "close 123")
|
||||
@@ -58,6 +66,11 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
assert_command({ context: { collection_ids: [ "writebook" ] } }, "writebook collection")
|
||||
end
|
||||
|
||||
test "closing soon and falling back soon" do
|
||||
assert_command({ context: { indexed_by: "falling_back_soon" } }, "cards to be reconsidered soon")
|
||||
assert_command({ context: { assignee_ids: [ users(:david).to_gid.to_s ], indexed_by: "closing_soon" } }, "my cards that are going to be auto closed")
|
||||
end
|
||||
|
||||
test "close cards" do
|
||||
# List context
|
||||
assert_command({ commands: [ "/close" ] }, "close")
|
||||
@@ -102,26 +115,6 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
assert_command({ commands: [ "/stage in progress" ] }, "move to in progress")
|
||||
end
|
||||
|
||||
test "combine commands and filters" do
|
||||
assert_command(
|
||||
{ context: { card_ids: [ 176, 170 ] }, commands: [ "/do", "/assign #{users(:david).to_gid}", "/stage Investigating" ] },
|
||||
"Move 176 and 170 to doing, assign to me and set the stage to Investigating")
|
||||
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")
|
||||
assert_command(
|
||||
{ context: { tag_ids: [ "design" ], assignee_ids: [ "jz" ] }, commands: [ "/assign andy", "/tag #v2" ] },
|
||||
"assign cards tagged with #design assigned to jz to andy and tag them with #v2")
|
||||
end
|
||||
|
||||
test "default to search" do
|
||||
assert_command({ commands: [ "/search backups" ] }, "backups")
|
||||
assert_command({ context: { terms: [ "backups" ] } }, "cards about backups")
|
||||
end
|
||||
|
||||
test "visit screens" do
|
||||
assert_command({ commands: [ "/visit #{user_path(@user, script_name: nil)}" ] }, "my profile")
|
||||
assert_command({ commands: [ "/visit #{edit_user_path(@user, script_name: nil)}" ] }, "edit my profile")
|
||||
@@ -129,6 +122,11 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
assert_command({ commands: [ "/visit #{account_settings_path(script_name: nil)}" ] }, "account settings")
|
||||
end
|
||||
|
||||
test "view users profiles" do
|
||||
assert_command({ commands: [ "/user jz" ] }, "check what jz has been up to")
|
||||
assert_command({ commands: [ "/user kevin" ] }, "view kevin")
|
||||
end
|
||||
|
||||
test "create cards" do
|
||||
assert_command({ commands: [ "/add" ] }, "add card")
|
||||
assert_command({ commands: [ "/add new task" ] }, "add card new task")
|
||||
@@ -136,27 +134,31 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
|
||||
assert_command({ commands: [ "/add urgent issue" ] }, "create card urgent issue")
|
||||
end
|
||||
|
||||
test "filter by time ranges" do
|
||||
assert_command({ context: { closure: "thisweek", indexed_by: "closed" } }, "cards completed this week")
|
||||
assert_command({ context: { creation: "thisweek", tag_ids: [ "design" ], creator_ids: [ "jz" ] } }, "cards created this week by jz tagged as #design")
|
||||
assert_command({ context: { creation: "thismonth", creator_ids: [ "Gabriel", "Michael" ] } }, "cards created by Gabriel or Michael this month")
|
||||
end
|
||||
|
||||
test "closing soon and falling back soon" do
|
||||
assert_command({ context: { indexed_by: "falling_back_soon" } }, "cards to be reconsidered soon")
|
||||
assert_command({ context: { assignee_ids: [ users(:david).to_gid.to_s ], indexed_by: "closing_soon" } }, "my cards that are going to be auto closed")
|
||||
end
|
||||
|
||||
test "view users profiles" do
|
||||
assert_command({ commands: [ "/user jz" ] }, "check what jz has been up to")
|
||||
assert_command({ commands: [ "/user kevin" ] }, "view kevin")
|
||||
end
|
||||
|
||||
test "filter by closed by" do
|
||||
assert_command({ context: { closer_ids: [ users(:david).to_gid.to_s ], indexed_by: "closed" } }, "cards closed by me")
|
||||
assert_command({ context: { closure: "thisweek", closer_ids: [ "Jorge", "Kevin" ], indexed_by: "closed" } }, "cards closed by Jorge or Kevin this week")
|
||||
end
|
||||
|
||||
test "default to search" do
|
||||
assert_command({ commands: [ "/search backups" ] }, "backups")
|
||||
assert_command({ context: { terms: [ "backups" ] } }, "cards about backups")
|
||||
end
|
||||
|
||||
test "combine commands and filters" do
|
||||
assert_command(
|
||||
{ context: { card_ids: [ 176, 170 ] }, commands: [ "/do", "/assign #{users(:david).to_gid}", "/stage Investigating" ] },
|
||||
"Move 176 and 170 to doing, assign to me and set the stage to Investigating")
|
||||
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")
|
||||
assert_command(
|
||||
{ context: { tag_ids: [ "design" ], assignee_ids: [ "jz" ] }, commands: [ "/assign andy", "/tag v2" ] },
|
||||
"assign cards tagged with #design assigned to jz to andy and tag them with #v2")
|
||||
end
|
||||
|
||||
private
|
||||
def assert_command(expected, query, context: :list)
|
||||
assert_equal expected, translate(query, context:)
|
||||
|
||||
Reference in New Issue
Block a user