From ca4628b457e6a2aa1602fad9b4988fde9925c827 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 3 Jul 2025 12:46:36 +0200 Subject: [PATCH] Add more tests and fix failing ones --- app/models/command/ai/translator.rb | 4 +- app/models/command/parser/context.rb | 4 +- .../prompts/collections/users/_user.html.erb | 2 +- .../prompts/cards_controller_test.rb | 12 + .../collections/users_controller_test.rb | 13 + .../prompts/commands_controller_test.rb | 12 + .../prompts/tags_controller_test.rb | 12 + .../prompts/users_controller_test.rb | 12 + test/models/command/ai/parser_test.rb | 5 +- test/models/command/ai/translator_test.rb | 7 +- test/models/command/go_to_card_test.rb | 5 +- test/models/command/parser/context_test.rb | 63 + ...and_containing_the_individual_commands.yml | 3736 +++ ...st_resolve_filter_string_params_as_ids.yml | 3762 +++ .../ai/translator_test-test_assign_cards.yml | 7102 +++++ ...slator_test-test_assign_stages_to_card.yml | 8237 +++++ .../ai/translator_test-test_close_cards.yml | 16455 ++++++++++ ...est_closing_soon_and_falling_back_soon.yml | 9396 ++++++ ...test-test_combine_commands_and_filters.yml | 8696 ++++++ .../ai/translator_test-test_create_cards.yml | 14589 +++++++++ ...translator_test-test_default_to_search.yml | 7098 +++++ ...slator_test-test_filter_by_assignments.yml | 20606 +++++++++++++ ...translator_test-test_filter_by_card_id.yml | 12349 ++++++++ ...slator_test-test_filter_by_collections.yml | 4127 +++ ...nslator_test-test_filter_by_indexed_by.yml | 24723 ++++++++++++++++ .../ai/translator_test-test_filter_by_tag.yml | 14622 +++++++++ ...slator_test-test_filter_by_time_ranges.yml | 10898 +++++++ ...ve_cards_between_considering_and_doing.yml | 15676 ++++++++++ .../ai/translator_test-test_tag_cards.yml | 3367 +++ ...anslator_test-test_view_users_profiles.yml | 6738 +++++ .../ai/translator_test-test_visit_screens.yml | 14604 +++++++++ ...ular_search_if_the_card_does_not_exist.yml | 3746 +++ ...e_parsed_command_contains_the_raw_line.yml | 3001 ++ ...quiring_a_confirmation_with_a_redirect.yml | 3740 +++ 34 files changed, 217406 insertions(+), 13 deletions(-) create mode 100644 test/controllers/prompts/cards_controller_test.rb create mode 100644 test/controllers/prompts/collections/users_controller_test.rb create mode 100644 test/controllers/prompts/commands_controller_test.rb create mode 100644 test/controllers/prompts/tags_controller_test.rb create mode 100644 test/controllers/prompts/users_controller_test.rb diff --git a/app/models/command/ai/translator.rb b/app/models/command/ai/translator.rb index 1ad57106a..f31d3edf6 100644 --- a/app/models/command/ai/translator.rb +++ b/app/models/command/ai/translator.rb @@ -132,7 +132,7 @@ class Command::Ai::Translator – Do NOT infer unassigned just because an assignment follows. * **Possessive “my” in front of “card” or “cards”*** → assignee_ids: [ #{user.to_gid} ] — applies **even when other filters are present*** - (e.g., “my cards closing soon”, “my stalled cards”, “my cards created yesterday”). + (e.g., “my cards closing soon”, “my stalled cards”, “my cards created yesterday”, "cards assigned to me"). * “Recent cards” (i.e., newly created) → indexed_by: "newest" * “Cards with recent activity”, “recently updated cards” → indexed_by: "latest" – Only use "latest" if the user mentions activity, updates, or changes @@ -157,6 +157,7 @@ class Command::Ai::Translator * /consider → move card back to "considering" (reconsider) * Unless a clear command applies, fallback to /search with the verbatim text. * When searching for nouns (non-person), prefer /search over terms. + * When the person to pass to a command is "me" or "myself", use "#{user.to_gid}" * Respect the spoken order of commands. * "close as [reason]" or "close because [reason]" → /close [reason] – Remove "as" or "because" from the actual command @@ -193,6 +194,7 @@ class Command::Ai::Translator * Never use names, tags, or stage names mentioned **inside commands** (like /assign, /tag, /stage) as filters. * Never duplicate the assignee in both commands and context. * Never add properties tied to UI view ("card", "list", etc.). + * When using infinitive verbs such as "assign" or "close", always use the corresponding command, NEVER a filter. * To filter completed or closed cards, use "indexed_by: closed"; don't set a "closure" filter unless the user is asking for cards completed in a specific window of time. * When you see a word with a # prefix, assume it refers to a tag (either a filter or a command argument, but don't search for it). * All filters, including terms, must live **inside** context. diff --git a/app/models/command/parser/context.rb b/app/models/command/parser/context.rb index 1908f1db4..c5148bd0c 100644 --- a/app/models/command/parser/context.rb +++ b/app/models/command/parser/context.rb @@ -40,7 +40,7 @@ class Command::Parser::Context def find_workflow_stage(string) candidate_stages.find do |stage| - stage.name.downcase.include?(combined_arguments.downcase) + stage.name.downcase.include?(string.downcase) end end @@ -54,7 +54,7 @@ class Command::Parser::Context end def find_collection(string) - Collection.where("lower(name) like ?", "%#{name.downcase}%").first + Collection.where("lower(name) like ?", "%#{string.downcase}%").first end private diff --git a/app/views/prompts/collections/users/_user.html.erb b/app/views/prompts/collections/users/_user.html.erb index 836467bca..ad4b917b2 100644 --- a/app/views/prompts/collections/users/_user.html.erb +++ b/app/views/prompts/collections/users/_user.html.erb @@ -1,4 +1,4 @@ -" sgid="<%= user.attachable_sgid %>"> +" sgid="<%= user.attachable_sgid %>">