Appease dialyzer

pull/870/head
Stamates 6 years ago committed by Ryan Arthur
parent 1d37033518
commit b15b8cb23a
  1. 11
      apps/block_scout_web/test/block_scout_web/features/pages/block_page.ex
  2. 93
      apps/block_scout_web/test/block_scout_web/features/viewing_blocks_test.exs

@ -1,10 +1,8 @@
defmodule BlockScoutWeb.BlockPage do defmodule BlockScoutWeb.BlockPage do
@moduledoc false @moduledoc false
use Phoenix.ConnTest
use Wallaby.DSL use Wallaby.DSL
import BlockScoutWeb.Router.Helpers
import Wallaby.Query, only: [css: 1, css: 2] import Wallaby.Query, only: [css: 1, css: 2]
alias Explorer.Chain.{Block, InternalTransaction, Transaction} alias Explorer.Chain.{Block, InternalTransaction, Transaction}
@ -41,8 +39,11 @@ defmodule BlockScoutWeb.BlockPage do
css("[data-test='uncle_link'][data-uncle-hash='#{hash}']") css("[data-test='uncle_link'][data-uncle-hash='#{hash}']")
end end
def visit_page(session, %Block{} = block) do def visit_page(session, %Block{number: block_number, consensus: true}) do
path = block_path(build_conn(), :show, block) visit(session, "/blocks/#{block_number}")
visit(session, path) end
def visit_page(session, %Block{hash: hash}) do
visit(session, "/blocks/#{hash}")
end end
end end

@ -20,12 +20,6 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
{:ok, first_shown_block: newest_block, last_shown_block: oldest_block} {:ok, first_shown_block: newest_block, last_shown_block: oldest_block}
end end
test "viewing the blocks index page", %{first_shown_block: block, session: session} do
session
|> BlockListPage.visit_page()
|> assert_has(BlockListPage.block(block))
end
describe "block details page" do describe "block details page" do
test "show block detail page", %{session: session} do test "show block detail page", %{session: session} do
block = insert(:block, number: 42) block = insert(:block, number: 42)
@ -36,35 +30,6 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
|> assert_has(BlockPage.page_type("Block Details")) |> assert_has(BlockPage.page_type("Block Details"))
end end
test "inserts place holder blocks if out of order block received", %{session: session} do
BlockListPage.visit_page(session)
block = insert(:block, number: 315)
Notifier.handle_event({:chain_event, :blocks, :realtime, [block]})
session
|> assert_has(BlockListPage.block(block))
|> assert_has(BlockListPage.place_holder_blocks(3))
end
test "replaces place holder block if skipped block received", %{session: session} do
BlockListPage.visit_page(session)
block = insert(:block, number: 315)
Notifier.handle_event({:chain_event, :blocks, :realtime, [block]})
session
|> assert_has(BlockListPage.block(block))
|> assert_has(BlockListPage.place_holder_blocks(3))
skipped_block = insert(:block, number: 314)
Notifier.handle_event({:chain_event, :blocks, :realtime, [skipped_block]})
session
|> assert_has(BlockListPage.block(skipped_block))
|> assert_has(BlockListPage.place_holder_blocks(2))
end
test "block detail page has transactions", %{session: session} do test "block detail page has transactions", %{session: session} do
block = insert(:block, number: 42) block = insert(:block, number: 42)
@ -127,6 +92,15 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
|> assert_has(BlockPage.token_transfers(transaction, count: 3)) |> assert_has(BlockPage.token_transfers(transaction, count: 3))
end end
test "show reorg detail page", %{session: session} do
reorg = insert(:block, consensus: false)
session
|> BlockPage.visit_page(reorg)
|> assert_has(BlockPage.detail_number(reorg))
|> assert_has(BlockPage.page_type("Reorg Details"))
end
test "show uncle detail page", %{session: session} do test "show uncle detail page", %{session: session} do
uncle = insert(:block, consensus: false) uncle = insert(:block, consensus: false)
insert(:block_second_degree_relation, uncle_hash: uncle.hash) insert(:block_second_degree_relation, uncle_hash: uncle.hash)
@ -150,14 +124,40 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
end end
end end
describe "viewing reorg blocks list" do describe "viewing blocks list" do
test "lists uncle blocks", %{session: session} do test "viewing the blocks index page", %{first_shown_block: block, session: session} do
[reorg | _] = insert_list(10, :block, consensus: false) session
|> BlockListPage.visit_page()
|> assert_has(BlockListPage.block(block))
end
test "inserts place holder blocks if out of order block received", %{session: session} do
BlockListPage.visit_page(session)
block = insert(:block, number: 315)
Notifier.handle_event({:chain_event, :blocks, :realtime, [block]})
session session
|> BlockListPage.visit_reorgs_page() |> assert_has(BlockListPage.block(block))
|> assert_has(BlockListPage.block(reorg)) |> assert_has(BlockListPage.place_holder_blocks(3))
|> assert_has(BlockListPage.blocks(10)) end
test "replaces place holder block if skipped block received", %{session: session} do
BlockListPage.visit_page(session)
block = insert(:block, number: 315)
Notifier.handle_event({:chain_event, :blocks, :realtime, [block]})
session
|> assert_has(BlockListPage.block(block))
|> assert_has(BlockListPage.place_holder_blocks(3))
skipped_block = insert(:block, number: 314)
Notifier.handle_event({:chain_event, :blocks, :realtime, [skipped_block]})
session
|> assert_has(BlockListPage.block(skipped_block))
|> assert_has(BlockListPage.place_holder_blocks(2))
end end
end end
@ -185,4 +185,15 @@ defmodule BlockScoutWeb.ViewingBlocksTest do
|> assert_has(BlockListPage.blocks(10)) |> assert_has(BlockListPage.blocks(10))
end end
end end
describe "viewing reorg blocks list" do
test "lists uncle blocks", %{session: session} do
[reorg | _] = insert_list(10, :block, consensus: false)
session
|> BlockListPage.visit_reorgs_page()
|> assert_has(BlockListPage.block(reorg))
|> assert_has(BlockListPage.blocks(10))
end
end
end end

Loading…
Cancel
Save