diff --git a/test/beacon/loader/page_module_loader_test.exs b/test/beacon/loader/page_module_loader_test.exs index b724ae63b..d61344218 100644 --- a/test/beacon/loader/page_module_loader_test.exs +++ b/test/beacon/loader/page_module_loader_test.exs @@ -63,15 +63,15 @@ defmodule Beacon.Loader.PageModuleLoaderTest do %{"property" => "og:url", "content" => "http://example.com/{{ page.path }}"} ] ] - |> published_page_fixture() + |> page_fixture() |> Repo.preload(:event_handlers) - Beacon.Loader.load_page(page) - - {:ok, _module, ast} = PageModuleLoader.load_page!(page) + {:ok, module, _ast} = PageModuleLoader.load_page!(page) - assert has_fields?(ast, [{"content", "MY TEST PAGE"}, {"property", "og:description"}]) - assert has_fields?(ast, [{"content", "http://example.com/page/meta-tag"}, {"property", "og:url"}]) + assert Enum.sort(module.page_assigns().meta_tags) == [ + %{"content" => "MY TEST PAGE", "property" => "og:description"}, + %{"content" => "http://example.com/page/meta-tag", "property" => "og:url"} + ] end test "interpolates raw_schema snippets" do @@ -108,32 +108,22 @@ defmodule Beacon.Loader.PageModuleLoaderTest do } ] ] - |> published_page_fixture() + |> page_fixture() |> Repo.preload(:event_handlers) - Beacon.Loader.load_page(page) + {:ok, module, _ast} = PageModuleLoader.load_page!(page) - {:ok, _module, ast} = PageModuleLoader.load_page!(page) + [raw_schema] = module.page_assigns().raw_schema - assert has_fields?(ast, + assert Enum.sort(raw_schema) == [ "@context": "https://schema.org", "@type": "BlogPosting", - author: {:%{}, [], ["@type": "Person", name: "author_1"]}, + author: %{name: "author_1", "@type": "Person"}, headline: "hello world" - ) + ] end end - defp has_fields?(ast, match) do - {_new_ast, present} = - Macro.prewalk(ast, false, fn - {:%{}, _, fields} = node, acc -> {node, acc or match == Enum.sort(fields)} - node, acc -> {node, acc} - end) - - present - end - describe "render" do test "do not load template on boot stage" do page = page_fixture(site: "my_site", path: "1") |> Repo.preload([:event_handlers, :variants]) diff --git a/test/beacon/loader_test.exs b/test/beacon/loader_test.exs index f3d809704..8d1951f59 100644 --- a/test/beacon/loader_test.exs +++ b/test/beacon/loader_test.exs @@ -28,7 +28,7 @@ defmodule Beacon.LoaderTest do stylesheet_fixture() layout = - layout_fixture( + published_layout_fixture( template: """
layout_v1
<%= @inner_content %> @@ -44,7 +44,7 @@ defmodule Beacon.LoaderTest do ) page = - page_fixture( + published_page_fixture( layout_id: layout.id, path: "/loader_test", template: """ @@ -55,10 +55,7 @@ defmodule Beacon.LoaderTest do """ ) - Content.publish_layout(layout) - Content.publish_page(page) - - Beacon.reload_site(:my_site) + Beacon.Loader.load_page(page) [layout: layout, page: page, component: component] end diff --git a/test/beacon/tailwind_compiler_test.exs b/test/beacon/tailwind_compiler_test.exs index 129db315e..e5b4e174a 100644 --- a/test/beacon/tailwind_compiler_test.exs +++ b/test/beacon/tailwind_compiler_test.exs @@ -67,10 +67,6 @@ defmodule Beacon.TailwindCompilerTest do """ ) - Beacon.Loader.load_stylesheets(@site) - Beacon.Loader.load_components(@site) - Beacon.Loader.load_layouts(@site) - Beacon.Loader.load_pages(@site) Beacon.Loader.load_runtime_css(@site) :ok diff --git a/test/beacon_web/components/components_test.exs b/test/beacon_web/components/components_test.exs index 30ffaf704..91db5bd3b 100644 --- a/test/beacon_web/components/components_test.exs +++ b/test/beacon_web/components/components_test.exs @@ -73,13 +73,13 @@ defmodule BeaconWeb.ComponentsTest do defp create_page_with_component(template) do layout = published_layout_fixture() - published_page_fixture( - layout_id: layout.id, - path: "home", - template: template - ) - - Beacon.Loader.load_components(:my_site) - Beacon.Loader.load_pages(:my_site) + page = + published_page_fixture( + layout_id: layout.id, + path: "home", + template: template + ) + + Beacon.Loader.load_page(page) end end diff --git a/test/beacon_web/live/page_live_test.exs b/test/beacon_web/live/page_live_test.exs index c531c0026..44256d8d2 100644 --- a/test/beacon_web/live/page_live_test.exs +++ b/test/beacon_web/live/page_live_test.exs @@ -35,7 +35,7 @@ defmodule BeaconWeb.Live.PageLiveTest do ) page_home = - page_fixture( + published_page_fixture( layout_id: layout.id, path: "home", template: """ @@ -74,9 +74,7 @@ defmodule BeaconWeb.Live.PageLiveTest do """ }) - Content.publish_page(page_home) - - _page_without_meta_tags = + page_without_meta_tags = published_page_fixture( layout_id: layout.id, path: "without_meta_tags", @@ -87,7 +85,8 @@ defmodule BeaconWeb.Live.PageLiveTest do meta_tags: nil ) - Beacon.reload_site(:my_site) + Beacon.Loader.load_page(page_home) + Beacon.Loader.load_page(page_without_meta_tags) [layout: layout] end