@ -20,53 +20,81 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
{ :ok , first_shown_block : newest_block , last_shown_block : oldest_block }
end
test " show block detail page " , %{ session : session } do
block = insert ( :block , number : 42 )
test " viewing the blocks index page " , %{ first_shown_block : block , session : session } do
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . detail_number ( block ) )
|> BlockListPage . visit_page ( )
|> assert_has ( BlockList Page . block ( block ) )
end
test " block detail page has transactions " , %{ session : session } do
block = insert ( :block , number : 42 )
describe " block details page " do
test " show block detail page " , %{ session : session } do
block = insert ( :block , number : 42 )
transaction =
:transaction
|> insert ( )
|> with_block ( block )
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . detail_number ( block ) )
end
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . detail_number ( block ) )
|> assert_has ( BlockPage . transaction ( transaction ) )
|> assert_has ( BlockPage . transaction_status ( transaction ) )
end
test " block detail page has transactions " , %{ session : session } do
block = insert ( :block , number : 42 )
test " contract creation is shown for to_address in transaction list " , %{ session : session } do
block = insert ( :block , number : 42 )
transaction =
:transaction
|> insert ( )
|> with_block ( block )
contract_address = insert ( :contract_address )
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . detail_number ( block ) )
|> assert_has ( BlockPage . transaction ( transaction ) )
|> assert_has ( BlockPage . transaction_status ( transaction ) )
end
transaction =
:transaction
|> insert ( to_address : nil )
|> with_contract_creation ( contract_address )
|> with_block ( block )
test " contract creation is shown for to_address in transaction list " , %{ session : session } do
block = insert ( :block , number : 42 )
internal_transaction =
:internal_transaction_create
|> insert ( transaction : transaction , index : 0 )
|> with_contract_creation ( contract_address )
contract_address = insert ( :contract_address )
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . contract_creation ( internal_transaction ) )
end
transaction =
:transaction
|> insert ( to_address : nil )
|> with_contract_creation ( contract_address )
|> with_block ( block )
test " viewing the blocks index page " , %{ first_shown_block : block , session : session } do
session
|> BlockListPage . visit_page ( )
|> assert_has ( BlockListPage . block ( block ) )
internal_transaction =
:internal_transaction_create
|> insert ( transaction : transaction , index : 0 )
|> with_contract_creation ( contract_address )
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . contract_creation ( internal_transaction ) )
end
test " transaction with multiple token transfers shows all transfers if expanded " , %{
first_shown_block : block ,
session : session
} do
contract_token_address = insert ( :contract_address )
insert ( :token , contract_address : contract_token_address )
transaction =
:transaction
|> insert ( to_address : contract_token_address )
|> with_block ( block )
insert_list (
3 ,
:token_transfer ,
transaction : transaction ,
token_contract_address : contract_token_address
)
session
|> BlockPage . visit_page ( block )
|> assert_has ( BlockPage . token_transfers ( transaction , count : 1 ) )
|> click ( BlockPage . token_transfers_expansion ( transaction ) )
|> assert_has ( BlockPage . token_transfers ( transaction , count : 3 ) )
end
end
end