Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at https://git.elektrine.com/elektrine/tarakan.
This commit is contained in:
commit
af6077b9c3
455 changed files with 78366 additions and 0 deletions
22
test/tarakan_web/theme_boot_test.exs
Normal file
22
test/tarakan_web/theme_boot_test.exs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
defmodule TarakanWeb.ThemeBootTest do
|
||||
use TarakanWeb.ConnCase, async: true
|
||||
|
||||
test "the theme script is blocking and precedes the deferred bundle", %{conn: conn} do
|
||||
html = conn |> get(~p"/") |> html_response(200)
|
||||
|
||||
theme_at = :binary.match(html, "/assets/js/theme") |> elem(0)
|
||||
app_at = :binary.match(html, "/assets/js/app") |> elem(0)
|
||||
|
||||
assert theme_at < app_at, "theme.js must load before app.js"
|
||||
|
||||
# The whole point: it must not be deferred, or it runs after first paint
|
||||
# and the toggle flashes the wrong option again.
|
||||
[theme_tag] = Regex.run(~r|<script[^>]*/assets/js/theme[^>]*>|, html)
|
||||
refute theme_tag =~ "defer"
|
||||
refute theme_tag =~ "type=\"module\""
|
||||
|
||||
# And the bundle that needs to stay deferred still is.
|
||||
[app_tag] = Regex.run(~r|<script[^>]*/assets/js/app[^>]*>|, html)
|
||||
assert app_tag =~ "defer"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue