Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .github/workflows/accessibility_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: html_files
path: test/axe_html/
path: test/excessibility/html_snapshots

axe-test:
needs: mix-test
Expand All @@ -46,18 +46,11 @@ jobs:
uses: actions/checkout@v3
- name: Setup App
uses: ./.github/workflows/setup
- name: Generate css and js for pa11y
shell: bash
run: |
mix assets.deploy
cp -r priv/static/assets/js/ test/axe_html/assets
cp -r priv/static/assets/css/ test/axe_html/assets
- name: Download html files from mix test
uses: actions/download-artifact@v3
with:
name: html_files
path: test/axe_html/
path: test/excessibility/html_snapshots
- name: Pa11y Tests
shell: bash
run: ./run_pa11y.sh
run: mix excessibility

6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ npm-debug.log
*.secret.exs

# Axe test html fiels
/test/axe_html/*.html
/test/axe_html/assets/**/*.css*
/test/axe_html/assets/**/*.js*
/test/excessibility/*.html
/test/excessibility/assets/**/*.css*
/test/excessibility/assets/**/*.js*
4 changes: 2 additions & 2 deletions assets/js/launch-cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class LaunchCartElement extends LitElement {
<div part="modal-header">
<button @click=${this.closeThanks} part="close-modal" aria-label="Close Modal">✕</button>
</div>
<div part="modal-body">
<div style="color:white!important"part="modal-body">
<p part="cart-thank-you">Thanks for purchasing!</p>
</div>
</dialog>
Expand Down Expand Up @@ -215,4 +215,4 @@ declare global {
interface HTMLElementEventMap {
'checkout_redirect': CustomEvent<{ checkout_url: string }>;
}
}
}
10 changes: 8 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ defmodule LaunchCart.MixProject do
{:dart_sass, "~> 0.5", runtime: Mix.env() == :dev},
{:ecto_sql, "~> 3.6"},
{:esbuild, "~> 0.4", runtime: Mix.env() == :dev},
{:excessibility, "~> 0.1.0",
only: [:dev, :test], git: "https://github.com/launchscout/excessibility.git"},
{:ex_machina, "~> 2.7.0"},
{:faker, ">= 0.0.0"},
{:floki, ">= 0.30.0", only: :test},
{:floki, ">= 0.30.0", only: [:dev, :test]},
{:gettext, "~> 0.18"},
{:jason, "~> 1.2"},
{:live_state, "~> 0.6.0"},
Expand All @@ -59,7 +61,11 @@ defmodule LaunchCart.MixProject do
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:wallaby, "~> 0.30.2",
git: "https://github.com/launchscout/wallaby.git", branch: "shadow-dom", runtime: false, only: :test}
git: "https://github.com/launchscout/wallaby.git",
branch: "shadow-dom",
override: true,
runtime: false,
only: :test}
]
end

Expand Down
57 changes: 29 additions & 28 deletions mix.lock

Large diffs are not rendered by default.

Binary file modified priv/static/robots.txt.gz
Binary file not shown.
22 changes: 0 additions & 22 deletions run_pa11y.sh

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
defmodule LaunchCartWeb.StripeAccountControllerTest do
use LaunchCartWeb.ConnCase

alias LaunchCartWeb.PallyTest
alias LaunchCart.Repo
alias LaunchCart.StripeAccounts.StripeAccount

Expand All @@ -17,7 +16,7 @@ defmodule LaunchCartWeb.StripeAccountControllerTest do
test "lists all stripe_accounts", %{conn: conn} do
conn = get(conn, Routes.stripe_account_path(conn, :index))
assert html_response(conn, 200) =~ "Connected Stripe Accounts"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule LaunchCartWeb.UserConfirmationControllerTest do
conn = get(conn, Routes.user_confirmation_path(conn, :new))
response = html_response(conn, 200)
assert response =~ "<h1>Resend Confirmation Instructions</h1>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end
end

Expand Down Expand Up @@ -64,7 +64,7 @@ defmodule LaunchCartWeb.UserConfirmationControllerTest do
response = html_response(conn, 200)
assert response =~ "<h1>Confirm account</h1>"

PallyTest.here(conn)
Excessibility.html_snapshot(conn)

form_action = Routes.user_confirmation_path(conn, :update, "some-token")
assert response =~ "action=\"#{form_action}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule LaunchCartWeb.UserRegistrationControllerTest do
assert response =~ "Help us test Launch Elements!"
assert response =~ "Log in</a>"
assert response =~ "Register</a>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "redirects if already logged in", %{conn: conn} do
Expand All @@ -33,7 +33,7 @@ defmodule LaunchCartWeb.UserRegistrationControllerTest do

response = html_response(conn, 200)
assert response =~ "Thanks"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule LaunchCartWeb.UserResetPasswordControllerTest do
conn = get(conn, Routes.user_reset_password_path(conn, :new))
response = html_response(conn, 200)
assert response =~ "<h1>Forgot your password?</h1>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end
end

Expand Down Expand Up @@ -57,7 +57,7 @@ defmodule LaunchCartWeb.UserResetPasswordControllerTest do
test "renders reset password", %{conn: conn, token: token} do
conn = get(conn, Routes.user_reset_password_path(conn, :edit, token))
assert html_response(conn, 200) =~ "<h1>Reset password</h1>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "does not render reset password with invalid token", %{conn: conn} do
Expand Down Expand Up @@ -105,7 +105,7 @@ defmodule LaunchCartWeb.UserResetPasswordControllerTest do
assert response =~ "<h1>Reset password</h1>"
assert response =~ "should be at least 12 character(s)"
assert response =~ "does not match password"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "does not reset password with invalid token", %{conn: conn} do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule LaunchCartWeb.UserSessionControllerTest do
assert response =~ "<h1>Log in</h1>"
assert response =~ "Register</a>"
assert response =~ "Forgot your password?</a>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "redirects if already logged in", %{conn: conn, user: user} do
Expand All @@ -40,7 +40,7 @@ defmodule LaunchCartWeb.UserSessionControllerTest do
assert response =~ user.email
assert response =~ "settings</i>"
assert response =~ "Log out</a>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "logs the user in with remember me", %{conn: conn, user: user} do
Expand Down Expand Up @@ -80,7 +80,7 @@ defmodule LaunchCartWeb.UserSessionControllerTest do
response = html_response(conn, 200)
assert response =~ "<h1>Log in</h1>"
assert response =~ "Invalid email or password"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule LaunchCartWeb.UserSettingsControllerTest do
conn = get(conn, Routes.user_settings_path(conn, :edit))
response = html_response(conn, 200)
assert response =~ "<h1>Settings</h1>"
PallyTest.here(conn)
Excessibility.html_snapshot(conn)
end

test "redirects if user is not logged in" do
Expand Down Expand Up @@ -59,7 +59,7 @@ defmodule LaunchCartWeb.UserSettingsControllerTest do

assert get_session(old_password_conn, :user_token) == get_session(conn, :user_token)

PallyTest.here(old_password_conn)
Excessibility.html_snapshot(old_password_conn)
end
end

Expand Down
42 changes: 26 additions & 16 deletions test/launch_cart_web/features/stripe_cart_test.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
defmodule LaunchCartWeb.Features.LaunchCartTest do
alias LaunchCartWeb.PallyTest
alias LaunchCart.Test.FakeLaunch
use ExUnit.Case, async: false
use Wallaby.Feature
use LaunchCartWeb.PallyTest
use Excessibility

import Wallaby.Query
import LaunchCart.Factory
Expand All @@ -18,22 +17,33 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
end

feature "add item", %{session: session, store: store} do
session =
session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")

Excessibility.html_snapshot(session)

session
|> visit("/fake_stores/#{store.id}")
|> assert_text("My Store")
|> click(css("button#add-price_123"))
|> find(css("launch-cart"))
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("dialog"))
|> assert_has(css("table", text: "Nifty onesie"))

PallyTest.here(session)
|> find(css("launch-cart"), fn shadow ->
shadow
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))
|> click(css(".cart-count"))
|> assert_has(css("dialog"))
|> assert_has(css("table", text: "Nifty onesie"))
end)
|> Excessibility.html_snapshot()

assert Repo.get_by(Cart, store_id: store.id)
end

defp expand_shadow_element(element) do
element
|> Browser.execute_script('return arguments[0].shadowRoot')
end

feature "alter quantity", %{session: session, store: store} do
session
|> visit("/fake_stores/#{store.id}")
Expand All @@ -50,7 +60,7 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
|> click(css("button[part='cart-decrease-qty-button']"))
|> assert_has(css("td[part='cart-summary-qty']", text: "1"))

PallyTest.here(session)
Excessibility.html_snapshot(session)
end

feature "add item and reload", %{session: session, store: store} do
Expand All @@ -68,7 +78,7 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
|> shadow_root()
|> assert_has(css(".cart-count", text: "1"))

PallyTest.here(session)
Excessibility.html_snapshot(session)
end

feature "after checkout", %{session: session, store: store} do
Expand All @@ -87,7 +97,7 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
|> shadow_root()
|> assert_has(css("dialog"))

PallyTest.here(session)
Excessibility.html_snapshot(session)
end

feature "remove item from cart", %{session: session, store: store} do
Expand All @@ -103,7 +113,7 @@ defmodule LaunchCartWeb.Features.LaunchCartTest do
|> click(css("button#remove-item"))
|> assert_has(css("td", text: "Nifty onesie", count: 0))

PallyTest.here(session)
Excessibility.html_snapshot(session)

cart = Repo.get_by(Cart, store_id: store.id) |> Repo.preload(:items)
assert Enum.count(cart.items) == 0
Expand Down
3 changes: 1 addition & 2 deletions test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ defmodule LaunchCartWeb.ConnCase do
using do
quote do
# Use Axe Test module
use LaunchCartWeb.PallyTest
use Excessibility

# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
import LaunchCartWeb.ConnCase

alias LaunchCartWeb.Router.Helpers, as: Routes
alias LaunchCartWeb.PallyTest

# The default endpoint for testing
@endpoint LaunchCartWeb.Endpoint
Expand Down
49 changes: 0 additions & 49 deletions test/support/pally_test.ex

This file was deleted.