Consolidate transaction viewing tests

pull/199/head
Tim Mecklem 7 years ago
parent 2f3f2ad85b
commit 2e058cf94c
  1. 2
      apps/explorer_web/lib/explorer_web/templates/block_transaction/index.html.eex
  2. 2
      apps/explorer_web/lib/explorer_web/templates/chain/_transactions.html.eex
  3. 2
      apps/explorer_web/lib/explorer_web/templates/layout/_topnav.html.eex
  4. 3
      apps/explorer_web/lib/explorer_web/templates/transaction/index.html.eex
  5. 62
      apps/explorer_web/test/explorer_web/features/contributor_browsing_test.exs
  6. 13
      apps/explorer_web/test/explorer_web/features/pages/block_page.ex
  7. 21
      apps/explorer_web/test/explorer_web/features/pages/home_page.ex
  8. 8
      apps/explorer_web/test/explorer_web/features/pages/transaction_list_page.ex
  9. 27
      apps/explorer_web/test/explorer_web/features/viewing_transactions_test.ex

@ -1,7 +1,7 @@
<section class="container__section">
<div>
<h1><%= gettext("Block Details") %></h1>
<h2><%= @block.number %></h2>
<h2 data-test="block_detail_number"><%= @block.number %></h2>
</div>
<div class="panels container__subsection">
<div class="panels__container row">

@ -13,7 +13,7 @@
</thead>
<tbody>
<%= for transaction <- @chain.transactions do %>
<tr>
<tr data-test="chain_transaction">
<td>
<%= render ExplorerWeb.TransactionView, "_link.html", conn: @conn, transaction: transaction %>
</td>

@ -3,7 +3,7 @@
<div class="header__cell header__cell--search">
<%= form_for @conn, chain_path(@conn, :search, Gettext.get_locale), [class: "header__cell--search-form", method: :get, enforce_utf8: false], fn f -> %>
<i class="header__cell--search-glass fa fa-search"></i>
<%= search_input f, :q, class: 'header__cell--search-input', placeholder: gettext "Search by address, transaction hash, or block number" %>
<%= search_input f, :q, class: 'header__cell--search-input', placeholder: gettext("Search by address, transaction hash, or block number"), "data-test": "search_input" %>
<% end %>
</div>
</div>

@ -18,7 +18,8 @@
<%= link(
gettext("Pending"),
class: "nav-link",
to: pending_transaction_path(@conn, :index, @conn.assigns.locale)
to: pending_transaction_path(@conn, :index, @conn.assigns.locale),
"data-test": "pending_transactions_link"
) %>
</li>
</ul>

@ -4,54 +4,35 @@ defmodule ExplorerWeb.ContributorBrowsingTest do
import Wallaby.Query, only: [css: 1, css: 2, link: 1]
alias Explorer.Chain.{Credit, Debit}
alias ExplorerWeb.{AddressPage, BlockPage, HomePage, TransactionPage}
@logo css("[data-test='header_logo']")
test "browses the home page", %{session: session} do
session |> visit("/")
assert current_path(session) == "/en"
session
|> click(@logo)
|> assert_has(css("main", text: "Blocks"))
end
test "search for blocks", %{session: session} do
block = insert(:block, number: 42)
refute block.miner_hash == nil
session
|> visit("/")
|> fill_in(css(".header__cell--search-input"), with: to_string(block.number))
|> send_keys([:enter])
|> assert_has(css(".block__item", text: to_string(block.miner_hash)))
|> HomePage.visit_page()
|> HomePage.search(to_string(block.number))
|> assert_has(BlockPage.detail_number(block))
end
test "search for transactions", %{session: session} do
transaction = insert(:transaction, input: "0x736f636b73")
session
|> visit("/")
|> fill_in(
css(".header__cell--search-input"),
with: to_string(transaction.hash)
)
|> send_keys([:enter])
|> assert_has(css(".transaction__item", text: to_string(transaction.input)))
|> HomePage.visit_page()
|> HomePage.search(to_string(transaction.hash))
|> assert_has(TransactionPage.detail_hash(transaction))
end
test "search for address", %{session: session} do
address = insert(:address)
session
|> visit("/")
|> fill_in(
css(".header__cell--search-input"),
with: to_string(address.hash)
)
|> send_keys([:enter])
|> assert_has(css(".address__subheading", text: to_string(address.hash)))
|> HomePage.visit_page()
|> HomePage.search(to_string(address.hash))
|> assert_has(AddressPage.detail_hash(address))
end
test "views blocks", %{session: session} do
@ -164,29 +145,6 @@ defmodule ExplorerWeb.ContributorBrowsingTest do
}}
end
test "views transactions", %{session: session} do
session
|> visit("/en")
|> assert_has(css(".transactions__title", text: "Transactions"))
|> assert_has(css(".transactions__column--hash", count: 5))
|> assert_has(css(".transactions__column--value", count: 5))
|> assert_has(css(".transactions__column--age", count: 5))
end
test "can see pending transactions", %{pending: pending, session: session} do
session
|> visit("/transactions")
|> click(css(".transactions__tab-link", text: "Pending"))
|> click(css(".transactions__link", text: to_string(pending.hash)))
|> assert_has(css(".transaction__item-value--status", text: "Pending"))
end
test "don't see pending transactions by default", %{session: session} do
session
|> visit("/transactions")
|> refute_has(css(".transactions__column--block", text: "Pending"))
end
test "see's all addresses transactions by default", %{
lincoln: lincoln,
session: session,

@ -0,0 +1,13 @@
defmodule ExplorerWeb.BlockPage do
@moduledoc false
use Wallaby.DSL
import Wallaby.Query, only: [css: 2]
alias Explorer.Chain.Block
def detail_number(%Block{number: block_number}) do
css("[data-test='block_detail_number']", text: to_string(block_number))
end
end

@ -0,0 +1,21 @@
defmodule ExplorerWeb.HomePage do
@moduledoc false
use Wallaby.DSL
import Wallaby.Query, only: [css: 1, css: 2]
def search(session, text) do
session
|> fill_in(css("[data-test='search_input']"), with: text)
|> send_keys([:enter])
end
def visit_page(session) do
visit(session, "/")
end
def transactions(count: count) do
css("[data-test='chain_transaction']", count: count)
end
end

@ -14,4 +14,12 @@ defmodule ExplorerWeb.TransactionListPage do
def visit_page(session) do
visit(session, "/en/transactions")
end
def click_pending(session) do
click(session, css("[data-test='pending_transactions_link']"))
end
def transaction(%Transaction{hash: transaction_hash}) do
css("[data-test='transaction_hash'][data-transaction-hash='#{transaction_hash}']")
end
end

@ -1,8 +1,8 @@
defmodule ExplorerWeb.TransactionPageTest do
defmodule ExplorerWeb.ViewingTransactionsTest do
use ExplorerWeb.FeatureCase, async: true
alias Explorer.Chain.{Credit, Debit, Wei}
alias ExplorerWeb.{AddressPage, TransactionListPage, TransactionLogsPage, TransactionPage}
alias ExplorerWeb.{AddressPage, HomePage, TransactionListPage, TransactionLogsPage, TransactionPage}
setup do
block =
@ -66,6 +66,29 @@ defmodule ExplorerWeb.TransactionPageTest do
}}
end
describe "viewing transaction lists" do
test "transactions on the home page", %{session: session} do
session
|> HomePage.visit_page()
|> assert_has(HomePage.transactions(count: 5))
end
test "viewing the default transactions tab", %{session: session, transaction: transaction, pending: pending} do
session
|> TransactionListPage.visit_page()
|> assert_has(TransactionListPage.transaction(transaction))
|> refute_has(TransactionListPage.transaction(pending))
end
test "viewing the pending tab", %{pending: pending, session: session} do
session
|> TransactionListPage.visit_page()
|> TransactionListPage.click_pending()
|> assert_has(TransactionListPage.transaction(pending))
# |> click(css(".transactions__link", text: to_string(pending.hash)))
end
end
describe "viewing a transaction page" do
test "can navigate to transaction show from list page", %{session: session, transaction: transaction} do
session
Loading…
Cancel
Save