All checks set to exit_status: 0 initially to avoid blocking on pre-existing violations. Remove exit_status overrides as each check category is cleaned up incrementally.
61 lines
1.6 KiB
Elixir
61 lines
1.6 KiB
Elixir
defmodule ToweropsWeb.Components.CookieConsentTest do
|
|
use ExUnit.Case, async: true
|
|
|
|
import Phoenix.Component
|
|
import Phoenix.LiveViewTest
|
|
|
|
alias ToweropsWeb.Components.CookieConsent
|
|
|
|
describe "banner/1" do
|
|
test "renders consent banner when requires_consent is true" do
|
|
assigns = %{requires_consent: true}
|
|
|
|
html =
|
|
rendered_to_string(~H"""
|
|
<CookieConsent.banner requires_consent={@requires_consent} />
|
|
""")
|
|
|
|
assert html =~ ~s(id="cookie-consent-banner")
|
|
assert html =~ "We respect your privacy"
|
|
assert html =~ "essential cookies"
|
|
assert html =~ ~s(href="/privacy")
|
|
assert html =~ "Accept"
|
|
end
|
|
|
|
test "renders nothing when requires_consent is false" do
|
|
assigns = %{requires_consent: false}
|
|
|
|
html =
|
|
rendered_to_string(~H"""
|
|
<CookieConsent.banner requires_consent={@requires_consent} />
|
|
""")
|
|
|
|
assert html == ""
|
|
end
|
|
|
|
test "has proper accessibility attributes" do
|
|
assigns = %{requires_consent: true}
|
|
|
|
html =
|
|
rendered_to_string(~H"""
|
|
<CookieConsent.banner requires_consent={@requires_consent} />
|
|
""")
|
|
|
|
assert html =~ ~s(role="dialog")
|
|
assert html =~ ~s(aria-label="Cookie consent")
|
|
assert html =~ ~s(aria-live="polite")
|
|
end
|
|
|
|
test "has functioning accept button with data attribute" do
|
|
assigns = %{requires_consent: true}
|
|
|
|
html =
|
|
rendered_to_string(~H"""
|
|
<CookieConsent.banner requires_consent={@requires_consent} />
|
|
""")
|
|
|
|
assert html =~ ~s(data-cookie-consent="accept")
|
|
assert html =~ ~s(type="button")
|
|
end
|
|
end
|
|
end
|