diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9cc6f38..bc082ff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,8 +77,18 @@ jobs: - name: Run tests run: mix test -# - name: Run smoke tests -# run: elixir ./bin/smoke_test.exs + - name: Set up Chromedriver + uses: nanasess/setup-chromedriver@v2 + - run: | + export DISPLAY=:99 + chromedriver --url-base=/wd/hub & + sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional + + - name: Set up demo project + run: cd demo && mix deps.get + + - name: Run smoke tests + run: elixir ./bin/smoke_test.exs - name: Check for compilation warnings run: mix compile --force --no-warnings diff --git a/bin/smoke_test.exs b/bin/smoke_test.exs new file mode 100755 index 0000000..d5724cb --- /dev/null +++ b/bin/smoke_test.exs @@ -0,0 +1,39 @@ +# assumes Chromedriver is running + +IO.puts("Running smoke tests") +IO.puts("\n\n") + +check_output = fn (output, pattern) -> + if not (output =~ pattern) do + IO.puts("Expected test output to match pattern:") + IO.puts(pattern) + exit 1 + end +end + +demo_project_path = "./demo" +demo_test_files = + [ + "test/demo_web/integration/pages_wallaby_test.exs", + "test/demo_web/integration/pages_hound_test.exs" + ] + +Enum.each(demo_test_files, fn demo_test_file -> + IO.puts("checking #{demo_test_file}") + + {output, 2} = System.cmd("mix", ["test", demo_test_file], cd: demo_project_path) + + check_output.(output, ~r/3 (features|tests), 2 failures/) + check_output.(output, "invalid page with accessibility errors") + check_output.(output, "critical") + check_output.(output, "Images must have alternate text") + check_output.(output, "There is 1 node with this violation:") + check_output.(output, "dynamic invalid page with accessibility errors that only happen after interaction") + check_output.(output, "serious") + check_output.(output, "Elements must meet minimum color contrast ratio thresholds") + check_output.(output, "There are 13 nodes with this violation:") + check_output.(output, "1.