From 3f9990d877964c3d7c1fc69335677917b92c8252 Mon Sep 17 00:00:00 2001 From: 24c02 <163450896+24c02@users.noreply.github.com> Date: Tue, 9 Dec 2025 21:32:27 -0500 Subject: [PATCH] try to untangle this mess? --- app/models/onboarding_scenarios/flavortown.rb | 12 ++--- .../03_taste_test.slack_message.slocks | 13 +++--- ...s => 03b_taste_retry.slack_message.slocks} | 12 +++-- ... => 03c_taste_reveal.slack_message.slocks} | 0 .../onboarding_scenarios/flavortown_spec.rb | 45 +++++++++---------- 5 files changed, 37 insertions(+), 45 deletions(-) rename app/views/slack/flavortown/{03b_taste_wrong.slack_message.slocks => 03b_taste_retry.slack_message.slocks} (65%) rename app/views/slack/flavortown/{03c_taste_incredibly_wrong.slack_message.slocks => 03c_taste_reveal.slack_message.slocks} (100%) diff --git a/app/models/onboarding_scenarios/flavortown.rb b/app/models/onboarding_scenarios/flavortown.rb index e4805ee..fd645f5 100644 --- a/app/models/onboarding_scenarios/flavortown.rb +++ b/app/models/onboarding_scenarios/flavortown.rb @@ -48,8 +48,8 @@ module OnboardingScenarios welcome: "flavortown/01_welcome", kitchen_code: "flavortown/02_kitchen_code", taste_test: "flavortown/03_taste_test", - taste_wrong: "flavortown/03b_taste_wrong", - taste_gave_up: "flavortown/03c_taste_incredibly_wrong", + taste_retry: "flavortown/03b_taste_retry", + taste_reveal: "flavortown/03c_taste_reveal", taste_terrible: "flavortown/03d_taste_terrible", dino_nuggets: "flavortown/03e_dino_nuggets", promoted: "flavortown/04_promoted" @@ -61,10 +61,10 @@ module OnboardingScenarios when "flavortown_continue" then :kitchen_code when "flavortown_agree" then :taste_test when "flavortown_taste_correct" then { step: :promoted, promote: true } - when /\Aflavortown_taste_wrong_[wt]\d+\z/ then :taste_wrong - when "flavortown_try_again" then :taste_test - when /\Aflavortown_taste_wrong_again_[wt]\d+\z/ then :taste_gave_up - when /\Aflavortown_taste_incredibly_wrong_[wt]\d+\z/ then :taste_terrible + when /\Aflavortown_retry_[wt]\d+\z/ then :taste_retry + when "flavortown_try_again" then :taste_retry + when /\Aflavortown_final_[wt]\d+\z/ then :taste_reveal + when /\Aflavortown_terrible_t\d+\z/ then :taste_terrible when "flavortown_dino_nuggets" then :dino_nuggets end end diff --git a/app/views/slack/flavortown/03_taste_test.slack_message.slocks b/app/views/slack/flavortown/03_taste_test.slack_message.slocks index 3b7e7e5..6de3b98 100644 --- a/app/views/slack/flavortown/03_taste_test.slack_message.slocks +++ b/app/views/slack/flavortown/03_taste_test.slack_message.slocks @@ -8,13 +8,10 @@ section <<~MSG, markdown: true *What makes a dish truly great?* MSG -wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, action, opts), i| button(label, "#{action}_w#{i}", **opts) } -terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, action, opts), i| button(label, "#{action}_t#{i}", **opts) } +wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_retry_w#{i}", **(opts || {})) } +terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_terrible_t#{i}", **(opts || {})) } dino_nuggets = OnboardingScenarios::Flavortown::DINO_NUGGETS.then { |(label, action, opts)| button(label, action, **opts) } -actions [ - button("Love", "flavortown_taste_correct", style: "primary"), - *wrong_answers.sample(2), - *terrible_answers.sample(3), - dino_nuggets -].shuffle +love = button("Love", "flavortown_taste_correct", style: "primary") +first_five = [love, *wrong_answers.sample(2), *terrible_answers.sample(2)].shuffle +actions [*first_five, terrible_answers.sample(1).first, dino_nuggets].compact diff --git a/app/views/slack/flavortown/03b_taste_wrong.slack_message.slocks b/app/views/slack/flavortown/03b_taste_retry.slack_message.slocks similarity index 65% rename from app/views/slack/flavortown/03b_taste_wrong.slack_message.slocks rename to app/views/slack/flavortown/03b_taste_retry.slack_message.slocks index 233029f..642cb46 100644 --- a/app/views/slack/flavortown/03b_taste_wrong.slack_message.slocks +++ b/app/views/slack/flavortown/03b_taste_retry.slack_message.slocks @@ -10,11 +10,9 @@ section <<~MSG, markdown: true *What makes a dish truly great?* MSG -wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_taste_wrong_again_w#{i}", **opts) } -terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_taste_wrong_again_t#{i}", **opts) } +wrong_answers = OnboardingScenarios::Flavortown::WRONG_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_final_w#{i}", **(opts || {})) } +terrible_answers = OnboardingScenarios::Flavortown::TERRIBLE_ANSWERS.map.with_index { |(label, _, opts), i| button(label, "flavortown_final_t#{i}", **(opts || {})) } -actions [ - button("Love", "flavortown_taste_correct", style: "primary"), - *wrong_answers.sample(3), - *terrible_answers.sample(2), -].shuffle +love = button("Love", "flavortown_taste_correct", style: "primary") +first_five = [love, *wrong_answers.sample(2), *terrible_answers.sample(2)].shuffle +actions [*first_five, terrible_answers.sample(1).first].compact diff --git a/app/views/slack/flavortown/03c_taste_incredibly_wrong.slack_message.slocks b/app/views/slack/flavortown/03c_taste_reveal.slack_message.slocks similarity index 100% rename from app/views/slack/flavortown/03c_taste_incredibly_wrong.slack_message.slocks rename to app/views/slack/flavortown/03c_taste_reveal.slack_message.slocks diff --git a/spec/models/onboarding_scenarios/flavortown_spec.rb b/spec/models/onboarding_scenarios/flavortown_spec.rb index 4eabf06..0207248 100644 --- a/spec/models/onboarding_scenarios/flavortown_spec.rb +++ b/spec/models/onboarding_scenarios/flavortown_spec.rb @@ -16,8 +16,8 @@ RSpec.describe OnboardingScenarios::Flavortown do :welcome, :kitchen_code, :taste_test, - :taste_wrong, - :taste_gave_up, + :taste_retry, + :taste_reveal, :taste_terrible, :dino_nuggets, :promoted @@ -28,8 +28,8 @@ RSpec.describe OnboardingScenarios::Flavortown do expect(scenario.dialogue_flow[:welcome]).to eq("flavortown/01_welcome") expect(scenario.dialogue_flow[:kitchen_code]).to eq("flavortown/02_kitchen_code") expect(scenario.dialogue_flow[:taste_test]).to eq("flavortown/03_taste_test") - expect(scenario.dialogue_flow[:taste_wrong]).to eq("flavortown/03b_taste_wrong") - expect(scenario.dialogue_flow[:taste_gave_up]).to eq("flavortown/03c_taste_incredibly_wrong") + expect(scenario.dialogue_flow[:taste_retry]).to eq("flavortown/03b_taste_retry") + expect(scenario.dialogue_flow[:taste_reveal]).to eq("flavortown/03c_taste_reveal") expect(scenario.dialogue_flow[:taste_terrible]).to eq("flavortown/03d_taste_terrible") expect(scenario.dialogue_flow[:dino_nuggets]).to eq("flavortown/03e_dino_nuggets") expect(scenario.dialogue_flow[:promoted]).to eq("flavortown/04_promoted") @@ -59,22 +59,22 @@ RSpec.describe OnboardingScenarios::Flavortown do end context "wrong answers" do - it "goes to taste_wrong on first wrong answer" do - expect(scenario.handle_action("flavortown_taste_wrong_w0")).to eq(:taste_wrong) + it "goes to taste_retry on first wrong answer" do + expect(scenario.handle_action("flavortown_retry_w0")).to eq(:taste_retry) end - it "allows retry from taste_wrong" do - expect(scenario.handle_action("flavortown_try_again")).to eq(:taste_test) + it "allows retry from scolding screens" do + expect(scenario.handle_action("flavortown_try_again")).to eq(:taste_retry) end - it "gives up after second wrong answer" do - expect(scenario.handle_action("flavortown_taste_wrong_again_w0")).to eq(:taste_gave_up) + it "reveals answer after second wrong answer" do + expect(scenario.handle_action("flavortown_final_w0")).to eq(:taste_reveal) end end context "terrible answers" do it "goes to taste_terrible on incredibly wrong answer" do - expect(scenario.handle_action("flavortown_taste_incredibly_wrong_t0")).to eq(:taste_terrible) + expect(scenario.handle_action("flavortown_terrible_t0")).to eq(:taste_terrible) end it "goes to dino_nuggets on dino nuggets answer" do @@ -140,25 +140,22 @@ RSpec.describe OnboardingScenarios::Flavortown do step = scenario.handle_action("flavortown_agree") expect(step).to eq(:taste_test) - step = scenario.handle_action("flavortown_taste_wrong_w0") - expect(step).to eq(:taste_wrong) - - step = scenario.handle_action("flavortown_try_again") - expect(step).to eq(:taste_test) + step = scenario.handle_action("flavortown_retry_w0") + expect(step).to eq(:taste_retry) result = scenario.handle_action("flavortown_taste_correct") expect(result).to eq({ step: :promoted, promote: true }) end - it "can complete the gave-up path (wrong twice)" do + it "can complete the reveal path (wrong twice)" do scenario.handle_action("flavortown_continue") scenario.handle_action("flavortown_agree") - step = scenario.handle_action("flavortown_taste_wrong_w0") - expect(step).to eq(:taste_wrong) + step = scenario.handle_action("flavortown_retry_w0") + expect(step).to eq(:taste_retry) - step = scenario.handle_action("flavortown_taste_wrong_again_w0") - expect(step).to eq(:taste_gave_up) + step = scenario.handle_action("flavortown_final_w0") + expect(step).to eq(:taste_reveal) end it "can complete the dino nuggets path" do @@ -169,18 +166,18 @@ RSpec.describe OnboardingScenarios::Flavortown do expect(step).to eq(:dino_nuggets) step = scenario.handle_action("flavortown_try_again") - expect(step).to eq(:taste_test) + expect(step).to eq(:taste_retry) end it "can complete the terrible answer path" do scenario.handle_action("flavortown_continue") scenario.handle_action("flavortown_agree") - step = scenario.handle_action("flavortown_taste_incredibly_wrong_t0") + step = scenario.handle_action("flavortown_terrible_t0") expect(step).to eq(:taste_terrible) step = scenario.handle_action("flavortown_try_again") - expect(step).to eq(:taste_test) + expect(step).to eq(:taste_retry) end end end