From 5fb1347bf469231d3faf9ed3b0cd0b8ef2c328af Mon Sep 17 00:00:00 2001 From: Amanda Sposito Date: Wed, 2 Jan 2019 11:43:37 -0200 Subject: [PATCH] Fix 'DBConnection.OwnershipError' in feature tests. * Add sandbox config to shared mode when test is async false. --- .../test/block_scout_web/features/viewing_blocks_test.exs | 2 +- .../block_scout_web/features/viewing_transactions_test.exs | 2 +- apps/block_scout_web/test/support/feature_case.ex | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_blocks_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_blocks_test.exs index 6838136ec5..eb5e24e8c4 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_blocks_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_blocks_test.exs @@ -1,5 +1,5 @@ defmodule BlockScoutWeb.ViewingBlocksTest do - use BlockScoutWeb.FeatureCase, async: true + use BlockScoutWeb.FeatureCase, async: false alias BlockScoutWeb.{BlockListPage, BlockPage} alias Explorer.Chain.Block diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_transactions_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_transactions_test.exs index 1fd14622cb..b72431fb41 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_transactions_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_transactions_test.exs @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.ViewingTransactionsTest do @moduledoc false - use BlockScoutWeb.FeatureCase, async: true + use BlockScoutWeb.FeatureCase, async: false alias BlockScoutWeb.{AddressPage, TransactionListPage, TransactionLogsPage, TransactionPage} alias Explorer.Chain.Wei diff --git a/apps/block_scout_web/test/support/feature_case.ex b/apps/block_scout_web/test/support/feature_case.ex index 14f02c13d8..cf9d64cdc5 100644 --- a/apps/block_scout_web/test/support/feature_case.ex +++ b/apps/block_scout_web/test/support/feature_case.ex @@ -20,9 +20,13 @@ defmodule BlockScoutWeb.FeatureCase do end end - setup do + setup tags do :ok = Ecto.Adapters.SQL.Sandbox.checkout(Explorer.Repo) + unless tags[:async] do + Ecto.Adapters.SQL.Sandbox.mode(Explorer.Repo, {:shared, self()}) + end + metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for(Explorer.Repo, self()) {:ok, session} = Wallaby.start_session(metadata: metadata) session = Wallaby.Browser.resize_window(session, 1200, 800)