Skip to content

Commit

Permalink
Add a non-working generate test
Browse files Browse the repository at this point in the history
  • Loading branch information
dem4ron committed Nov 8, 2024
1 parent 2487590 commit 7c92496
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function BootcampAffiliateCouponForm({
<CopyToClipboardButton textToCopy={couponCode} />
) : (
<button
id="generate-affiliate-coupon-code-button"
onClick={generateCouponCode}
disabled={!isInsider || loading}
type="button"
Expand Down
34 changes: 33 additions & 1 deletion test/system/flows/settings/user_visits_insiders_settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UserVisitsInsidersSettingsTest < ApplicationSystemTestCase
assert change_button[:disabled]

assert_text "Bootcamp Affiliate Coupon"
generate_button = find("button", text: "Click to generate code")
generate_button = find("#generate-affiliate-coupon-code-button", text: "Click to generate code")
assert generate_button[:disabled]
refute_text "Bootcamp Free Coupon"
end
Expand Down Expand Up @@ -104,6 +104,38 @@ class UserVisitsInsidersSettingsTest < ApplicationSystemTestCase
assert_text "Bootcamp Free Coupon"
end
end

test "user changes hide adverts successfully" do
user = create :user, insiders_status: :active_lifetime
use_capybara_host do
sign_in!(user)

visit insiders_settings_path
sleep(2)

find(:xpath, "//*[text()='Hide website adverts']").click
click_on "Change preferences"
assert_text "Your preferences have been updated"
end
end

test "user generates code successfully" do
user = create :user, insiders_status: :active_lifetime

stub_request(:post, "https://api.stripe.com/v1/promotion_codes").
with(body: { "coupon" => "NRp5SOVV", "metadata" => { "user_id" => "37" } }).
to_return(status: 200, body: { coupon_code: 'test_code' }.to_json, headers: {})

use_capybara_host do
sign_in!(user)

visit insiders_settings_path
sleep(2)

find("#generate-affiliate-coupon-code-button").click
assert_text "test_code"
end
end
end
end
end

0 comments on commit 7c92496

Please sign in to comment.