From 48f5f04a110a8c99ea915310b67b897411c6123b Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Tue, 1 May 2018 13:03:18 -0400 Subject: [PATCH 1/4] Add configurable social media links Co-authored-by: tmecklem --- apps/explorer_web/config/config.exs | 11 +++++++--- .../lib/explorer_web/social_media.ex | 9 ++++++++ .../templates/layout/app.html.eex | 22 ++++++------------- .../lib/explorer_web/views/layout_view.ex | 6 +++++ .../features/social_media_links_test.exs | 21 ++++++++++++++++++ 5 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 apps/explorer_web/lib/explorer_web/social_media.ex create mode 100644 apps/explorer_web/test/explorer_web/features/social_media_links_test.exs diff --git a/apps/explorer_web/config/config.exs b/apps/explorer_web/config/config.exs index f774845edc..7099b19fc9 100644 --- a/apps/explorer_web/config/config.exs +++ b/apps/explorer_web/config/config.exs @@ -10,15 +10,20 @@ config :explorer_web, namespace: ExplorerWeb, ecto_repos: [Explorer.Repo] -# Configures gettext -config :explorer_web, ExplorerWeb.Gettext, locales: ~w(en), default_locale: "en" - # Configures the endpoint config :explorer_web, ExplorerWeb.Endpoint, url: [host: "localhost"], render_errors: [view: ExplorerWeb.ErrorView, accepts: ~w(html json)], pubsub: [name: ExplorerWeb.PubSub, adapter: Phoenix.PubSub.PG2] +# Configures gettext +config :explorer_web, ExplorerWeb.Gettext, locales: ~w(en), default_locale: "en" + +config :explorer_web, ExplorerWeb.SocialMedia, + facebook: "https://www.facebook.com/PoaNetwork", + instagram: "https://www.instagram.com/PoaNetwork", + twitter: "https://www.twitter.com/PoaNetwork" + config :ex_cldr, default_locale: "en", locales: ["en"], diff --git a/apps/explorer_web/lib/explorer_web/social_media.ex b/apps/explorer_web/lib/explorer_web/social_media.ex new file mode 100644 index 0000000000..49473bc799 --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/social_media.ex @@ -0,0 +1,9 @@ +defmodule ExplorerWeb.SocialMedia do + @moduledoc """ + This module provides social media links + """ + + def links do + Application.get_env(:explorer_web, __MODULE__, []) + end +end diff --git a/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex b/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex index 137973503a..14eaea93a7 100644 --- a/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex @@ -59,21 +59,13 @@ <% end %> diff --git a/apps/explorer_web/lib/explorer_web/views/layout_view.ex b/apps/explorer_web/lib/explorer_web/views/layout_view.ex index cde326f64f..6f8dc941fa 100644 --- a/apps/explorer_web/lib/explorer_web/views/layout_view.ex +++ b/apps/explorer_web/lib/explorer_web/views/layout_view.ex @@ -1,3 +1,9 @@ defmodule ExplorerWeb.LayoutView do use ExplorerWeb, :view + + alias ExplorerWeb.SocialMedia + + def configured_social_media_services do + SocialMedia.links() + end end diff --git a/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs b/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs new file mode 100644 index 0000000000..15c28ac758 --- /dev/null +++ b/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs @@ -0,0 +1,21 @@ +defmodule ExplorerWeb.SocialMediaLinksTest do + use ExplorerWeb.FeatureCase, async: true + + import Wallaby.Query + + test "it shows twitter when twitter is configured", %{session: session} do + Application.put_env(:explorer_web, ExplorerWeb.SocialMedia, twitter: "https://twitter.com/twitter") + + session + |> visit("/") + |> assert_has(css("[data-test='twitter_link']")) + end + + test "it hides twitter when twitter is not configured", %{session: session} do + Application.put_env(:explorer_web, ExplorerWeb.SocialMedia, facebook: "https://facebook.com/") + + session + |> visit("/") + |> refute_has(css("[data-test='twitter_link']")) + end +end From b5b152cc9fb464c66d5845e7fc4750f93ad96d86 Mon Sep 17 00:00:00 2001 From: jimmay5469 Date: Tue, 1 May 2018 16:49:37 -0400 Subject: [PATCH 2/4] Use larger browser window for testing Co-authored-by: tmecklem --- .../test/explorer_web/features/social_media_links_test.exs | 2 +- apps/explorer_web/test/support/feature_case.ex | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs b/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs index 15c28ac758..385c0f9f1e 100644 --- a/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs +++ b/apps/explorer_web/test/explorer_web/features/social_media_links_test.exs @@ -1,5 +1,5 @@ defmodule ExplorerWeb.SocialMediaLinksTest do - use ExplorerWeb.FeatureCase, async: true + use ExplorerWeb.FeatureCase import Wallaby.Query diff --git a/apps/explorer_web/test/support/feature_case.ex b/apps/explorer_web/test/support/feature_case.ex index 8a975dfec8..40d177c69d 100644 --- a/apps/explorer_web/test/support/feature_case.ex +++ b/apps/explorer_web/test/support/feature_case.ex @@ -24,6 +24,7 @@ defmodule ExplorerWeb.FeatureCase do 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) {:ok, session: session} end end From 2aab3759282a210d78541184e3dd1d1f57496b81 Mon Sep 17 00:00:00 2001 From: jimmay5469 Date: Wed, 2 May 2018 09:43:53 -0400 Subject: [PATCH 3/4] Fix tests that were accounting for the old smaller window --- .../lib/explorer_web/templates/layout/app.html.eex | 2 +- .../test/explorer_web/features/contributor_browsing_test.exs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex b/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex index 14eaea93a7..4847441bad 100644 --- a/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/layout/app.html.eex @@ -43,7 +43,7 @@