testing the filters in controller tests instead of feature tests

pull/1133/head
Gustavo Santos Ferreira 6 years ago
parent 51a8654fde
commit 2fbfaa1994
  1. 84
      apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs
  2. 88
      apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs

@ -69,6 +69,90 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
end)
end
test "returns internal transactions coming from the address", %{conn: conn} do
address = insert(:address)
transaction =
:transaction
|> insert()
|> with_block(insert(:block, number: 1))
from_internal_transaction =
insert(:internal_transaction,
transaction: transaction,
from_address: address,
index: 1,
block_number: transaction.block_number,
transaction_index: transaction.index
)
to_internal_transaction =
insert(:internal_transaction,
transaction: transaction,
to_address: address,
index: 2,
block_number: transaction.block_number,
transaction_index: transaction.index
)
path = address_internal_transaction_path(conn, :index, address, %{"filter" => "from", "type" => "JSON"})
conn = get(conn, path)
internal_transaction_tiles = json_response(conn, 200)["items"]
assert Enum.any?(internal_transaction_tiles, fn tile ->
String.contains?(tile, to_string(from_internal_transaction.transaction_hash)) &&
String.contains?(tile, "data-internal-transaction-index=\"#{from_internal_transaction.index}\"")
end)
refute Enum.any?(internal_transaction_tiles, fn tile ->
String.contains?(tile, to_string(to_internal_transaction.transaction_hash)) &&
String.contains?(tile, "data-internal-transaction-index=\"#{to_internal_transaction.index}\"")
end)
end
test "returns internal transactions going to the address", %{conn: conn} do
address = insert(:address)
transaction =
:transaction
|> insert()
|> with_block(insert(:block, number: 1))
from_internal_transaction =
insert(:internal_transaction,
transaction: transaction,
from_address: address,
index: 1,
block_number: transaction.block_number,
transaction_index: transaction.index
)
to_internal_transaction =
insert(:internal_transaction,
transaction: transaction,
to_address: address,
index: 2,
block_number: transaction.block_number,
transaction_index: transaction.index
)
path = address_internal_transaction_path(conn, :index, address, %{"filter" => "to", "type" => "JSON"})
conn = get(conn, path)
internal_transaction_tiles = json_response(conn, 200)["items"]
assert Enum.any?(internal_transaction_tiles, fn tile ->
String.contains?(tile, to_string(to_internal_transaction.transaction_hash)) &&
String.contains?(tile, "data-internal-transaction-index=\"#{to_internal_transaction.index}\"")
end)
refute Enum.any?(internal_transaction_tiles, fn tile ->
String.contains?(tile, to_string(from_internal_transaction.transaction_hash)) &&
String.contains?(tile, "data-internal-transaction-index=\"#{from_internal_transaction.index}\"")
end)
end
test "returns next page of results based on last seen internal transaction", %{conn: conn} do
address = insert(:address)

@ -147,36 +147,6 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
|> assert_has(AddressPage.transaction(transactions.from_taft))
end
@tag :skip
test "contract creation is shown for to_address on list page", %{
addresses: addresses,
block: block,
session: session
} do
lincoln = addresses.lincoln
contract_address = insert(:contract_address)
from_lincoln =
:transaction
|> insert(from_address: lincoln, to_address: nil)
|> with_contract_creation(contract_address)
|> with_block(block)
internal_transaction =
:internal_transaction_create
|> insert(
transaction: from_lincoln,
from_address: lincoln,
index: 1
)
|> with_contract_creation(contract_address)
session
|> AddressPage.visit_page(addresses.lincoln)
|> assert_has(AddressPage.contract_creation(internal_transaction))
end
test "only addresses not matching the page are links", %{
addresses: addresses,
session: session,
@ -214,32 +184,6 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
{:ok, %{internal_transaction_lincoln_to_address: internal_transaction_lincoln_to_address}}
end
@tag :skip
test "can see internal transactions for an address", %{addresses: addresses, session: session} do
session
|> AddressPage.visit_page(addresses.lincoln)
|> AddressPage.click_internal_transactions()
|> assert_has(AddressPage.internal_transactions(count: 2))
end
@tag :skip
test "can filter to only see internal transactions from an address", %{addresses: addresses, session: session} do
session
|> AddressPage.visit_page(addresses.lincoln)
|> AddressPage.click_internal_transactions()
|> AddressPage.apply_filter("From")
|> assert_has(AddressPage.internal_transactions(count: 1))
end
@tag :skip
test "can filter to only see internal transactions to an address", %{addresses: addresses, session: session} do
session
|> AddressPage.visit_page(addresses.lincoln)
|> AddressPage.click_internal_transactions()
|> AddressPage.apply_filter("To")
|> assert_has(AddressPage.internal_transactions(count: 1))
end
@tag :skip
test "only addresses not matching the page are links", %{
addresses: addresses,
@ -282,38 +226,6 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
end
end
@tag :skip
test "contract creation is shown for to_address on list page", %{
addresses: addresses,
block: block,
session: session
} do
lincoln = addresses.lincoln
contract_address = insert(:contract_address)
from_lincoln =
:transaction
|> insert(from_address: lincoln, to_address: nil)
|> with_block(block)
|> with_contract_creation(contract_address)
internal_transaction =
:internal_transaction_create
|> insert(
transaction: from_lincoln,
from_address: lincoln,
index: 1,
block_number: from_lincoln.block_number,
transaction_index: from_lincoln.index
)
|> with_contract_creation(contract_address)
session
|> AddressPage.visit_page(addresses.lincoln)
|> AddressPage.click_internal_transactions()
|> assert_has(AddressPage.contract_creation(internal_transaction))
end
describe "viewing token transfers" do
test "contributor can see all token transfers that he sent", %{
addresses: addresses,

Loading…
Cancel
Save