Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlbyrne committed May 20, 2024
1 parent 780cfd0 commit e2930de
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ group :development, :test do
gem "minitest-rails", github: "brave-intl/minitest-rails", branch: "rails71"
gem "mocha", require: false
gem "simplecov", require: false, group: :test
gem "selenium-webdriver", "~> 4.12"
gem "selenium-webdriver", "~> 4.4"
gem "solargraph"
gem "dotenv-rails", "3.1.0"
end
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ DEPENDENCIES
rotp (~> 6.3.0)
rqrcode (~> 2.2.0)
sass-rails (>= 6)
selenium-webdriver (~> 4.12)
selenium-webdriver (~> 4.4)
sendgrid-ruby (~> 6.7)
shakapacker (= 7.2.2)
sidekiq (~> 7.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ class CryptoPaymentWidget extends React.Component {
const amount = Math.round(this.calculateCryptoPrice() * Math.pow(10, decimal));
// this is the account address that will receive bat
const destinationAccountOwner = new PublicKey(this.state.addresses.SOL)
const connection = new Connection(this.state.solanaMainUrl)
console.log('https://publishers.basicattentiontoken.org/rpc')
const connection = new Connection('https://publishers.basicattentiontoken.org/rpc')
// Check to see if the sender has an associated token account
const senderAccount = await connection.getParsedTokenAccountsByOwner(sourceAccountOwner, {
mint: new PublicKey(contractAddress),
Expand Down Expand Up @@ -557,6 +558,7 @@ class CryptoPaymentWidget extends React.Component {
),
Option: CryptoPaymentOption
}}
className='crypto-currency-dropdown'
value={this.state.selectValue}
styles={{
control: (base) => ({ ...base,
Expand Down
4 changes: 2 additions & 2 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ test:
sendgrid_publishers_list_id: 3986776
slack_webhook_url: false
# Ratios, also needed for VCR tests
# bat_ratios_token: <%= ENV["BAT_RATIOS_TOKEN"] %>
# bat_ratios_url: <%= ENV["BAT_RATIOS_URL"] %>
bat_ratios_token: <%= ENV["BAT_RATIOS_TOKEN"] %>
bat_ratios_url: <%= ENV["BAT_RATIOS_URL"] %>
# Bitflyer env variables
bitflyer_host: "https://localhost/bitflyertest"
bitflyer_client_id: "client_id_abc123"
Expand Down
51 changes: 51 additions & 0 deletions test/cassettes/test_can_display_description_and_title.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions test/cassettes/test_can_select_different_currencies.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions test/cassettes/test_can_update_amounts.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions test/features/public_page_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# typed: false

require "test_helper"
require "webmock/minitest"
require "vcr"

class PublicPageTest < Capybara::Rails::TestCase
include ActionMailer::TestHelper
include Rails.application.routes.url_helpers

def setup
ActionController::Base.allow_forgery_protection = true
end

def teardown
ActionController::Base.allow_forgery_protection = false
end

test "redirects to home page if channel identifier not found" do
visit public_channel_path(public_identifier: "107zsxjfg6")
assert_content page, "Earn more for content you publish to the web"
end

test "can display description and title" do
VCR.use_cassette("test_can_display_description_and_title") do
visit public_channel_path(public_identifier: "123456dfg6")
assert_content page, "Channel Banner"
assert_content page, "Lorem Ipsum"
assert_content page, "Show your love and send a token of your gratitude"
end
end

test "can select different currencies" do
VCR.use_cassette("test_can_select_different_currencies") do
visit public_channel_path(public_identifier: "123456dfg6")
assert_content page, "20.87683 BAT"
find(".crypto-currency-dropdown", text: "ERC-20 BAT").click
find("#react-select-2-option-1-0", text: "Solana").click
assert_content page, "0.0282 SOL"
end
end

test "can update amounts" do
VCR.use_cassette("test_can_update_amounts") do
visit public_channel_path(public_identifier: "123456dfg6")
assert_content page, "20.87683 BAT"
find("button", text: "$10").click
assert_content page, "41.75365 BAT"
end
end
end

0 comments on commit e2930de

Please sign in to comment.