From b38f90db17052217847018051ab933efbbe53feb Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Thu, 31 Aug 2023 13:05:44 -0400 Subject: [PATCH] add tests rendering my_component --- lib/beacon/loader/error_module_loader.ex | 1 - test/beacon/loader/error_module_loader_test.exs | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/beacon/loader/error_module_loader.ex b/lib/beacon/loader/error_module_loader.ex index d506db25..9770d851 100644 --- a/lib/beacon/loader/error_module_loader.ex +++ b/lib/beacon/loader/error_module_loader.ex @@ -43,7 +43,6 @@ defmodule Beacon.Loader.ErrorModuleLoader do end :ok = Loader.reload_module!(error_module, ast) - {:ok, error_module, ast} end diff --git a/test/beacon/loader/error_module_loader_test.exs b/test/beacon/loader/error_module_loader_test.exs index 88768dc0..7cc97ef6 100644 --- a/test/beacon/loader/error_module_loader_test.exs +++ b/test/beacon/loader/error_module_loader_test.exs @@ -26,6 +26,7 @@ defmodule Beacon.Loader.ErrorModuleLoaderTest do end setup %{conn: conn} do + component_fixture(site: @site) :ok = Beacon.Loader.populate_layouts(@site) :ok = Beacon.Loader.populate_error_pages(@site) error_module = load_error_pages_module(@site) @@ -69,6 +70,22 @@ defmodule Beacon.Loader.ErrorModuleLoaderTest do assert error_module.layout(501, %{inner_content: error_page.template}) == {:safe, ["#custom_layout#", "error_501"]} end + test "user-defined component in layout" do + layout = published_layout_fixture(template: ~S|<%= my_component("sample_component", val: 1 )%><%= @inner_content %>|, site: @site) + error_page = error_page_fixture(layout: layout, template: "error", status: 502, site: @site) + error_module = load_error_pages_module(@site) + + assert error_module.layout(502, %{inner_content: error_page.template}) == {:safe, ["1", "error"]} + end + + test "user-defined component in page" do + layout = published_layout_fixture(template: ~S|<%= @inner_content %>|, site: @site) + error_page = error_page_fixture(layout: layout, template: ~S|<%= my_component("sample_component", val: 1) %>|, status: 503, site: @site) + error_module = load_error_pages_module(@site) + + assert error_module.layout(503, %{inner_content: error_page.template}) == {:safe, ["1", "error"]} + end + test "default error pages", %{conn: conn, error_module: error_module} do expected = ~S"""