Skip to content

Commit 4c85275

Browse files
authored
toil(front): update alpine image to 3.22.2 (#692)
## 📝 Description - Bumped the CI image to Alpine 3.20+, updated wallaby to comply with the new ChromeDriver version - Hardened our Wallaby helpers to handle DOM refreshes/retries, then applied them across the suite (flash assertions, modal submits, Okta setup, artifacts policies, etc.) so the worst flakes are gone - Stabilized the stubborn cases (self‑hosted agents page, artifacts retention editor, Okta integration flows) by waiting on the right UI hooks instead of the old modal DOM ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent ae30703 commit 4c85275

40 files changed

+486
-317
lines changed

.semaphore/semaphore.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ global_job_config:
3737
- 'if [ -f out/dependency-scan-trivy.json ]; then CHECK_TYPE=deps make check.generate-report; fi'
3838
- 'if [ -f out/security-export.json ]; then artifact push workflow out/security-export.json -d scans/$SEMAPHORE_JOB_ID.json; fi'
3939
- 'if [ -f out/security-summary.md ]; then artifact push job out/security-summary.md -d .semaphore/REPORT.md; fi'
40+
- 'if [ -d out/screenshots ] && [ "$(ls -A out/screenshots)" ]; then artifact push workflow out/screenshots -d screenshots; fi'
41+
4042

4143
after_pipeline:
4244
task:

front/AGENTS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@
2424
## Testing Guidelines
2525
- Keep unit tests close to their modules and name `describe` blocks after the function under test.
2626
- Wallaby browser specs need the Docker stack running; execute with `mix test test/browser`.
27+
- Prefer the helpers in `Support.Browser`/`Support.Browser.Assertions` (`assert_stable/2`, `assert_flash_notice/2`, etc.) instead of calling `assert_text/2` or `assert_has/2` directly—these wrappers handle stale DOM retries and should be the default in new tests.
28+
- When a flow depends on flashes or full-page redirects, assert against deterministic selectors (e.g., `#changes-notification p[data-test=...]`) rather than generic text nodes, and wait for the new page before chaining more actions.
29+
- Seed every browser test with the features and permissions it needs (usually via `Support.Stubs.Feature.enable_feature/3` and `Support.Stubs.PermissionPatrol.allow_everything/2`) so the UI renders the buttons you intend to click.
30+
- Keep destructive test fixtures scoped: create orgs/projects/users per test module using the stubs in `test/support/stubs`, and add explicit waits if a change propagates asynchronously (e.g., retention policies or self-hosted agents).
2731
- Generate coverage with `mix coveralls.html` and `npm run coverage`.
2832
- Update fixtures in `test/fixture` when workflow, API, or UI contracts change.
2933

34+
## Browser Testing Notes
35+
- Use the `browser_test` macro from `FrontWeb.WallabyCase` for every Wallaby spec. It handles screenshot capture, session cleanup, and tags so failures are easier to debug.
36+
- Chrome/Chromedriver now refuse to click invisible elements; always wait until the target button/link is visible (`assert_stable/2`, `assert_stable_text/2`) before clicking, and prefer selectors that match the final rendered node (not a parent wrapper).
37+
- For modals, redirects, and flash messages, re-sync the page via `Support.Browser.assert_flash_notice/2` or another deterministic element to avoid stale references after navigation.
38+
3039
## Commit & Pull Request Guidelines
3140
- Commits follow `type(scope): message (#issue)` (e.g., `fix(front): adjust mermaid rendering (#621)`).
3241
- Each commit should bundle code, schema, and tests for a single concern.

front/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG ELIXIR_VERSION=1.14.5
22
ARG OTP_VERSION=25.3.2.21
3-
ARG ALPINE_VERSION=3.19.7
3+
ARG ALPINE_VERSION=3.22.2
44
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-alpine-${ALPINE_VERSION}"
55
ARG RUNNER_IMAGE="alpine:${ALPINE_VERSION}"
66

front/config/test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ config :front,
1919
docs_domain: "docs.semaphoretest.test",
2020
start_reactor: true
2121

22-
config :wallaby, screenshot_dir: System.get_env("WALLABY_SCREENSHOTS") || "./out"
22+
config :wallaby, screenshot_dir: System.get_env("WALLABY_SCREENSHOTS") || "./out/screenshots"
2323
config :wallaby, screenshot_on_failure: true
24-
config :wallaby, driver: Wallaby.Experimental.Chrome
24+
config :wallaby, driver: Wallaby.Chrome
2525
config :wallaby, max_wait_time: 10_000
2626

2727
config :joken, current_time_adapter: Support.TimeMock

front/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Front.Mixfile do
5151
{:tentacat, github: "renderedtext/tentacat"},
5252
{:httpoison, ">= 0.0.0"},
5353
{:uuid, "~> 1.1"},
54-
{:wallaby, "~> 0.23.0", runtime: false, only: [:dev, :test]},
54+
{:wallaby, "~> 0.30", runtime: false, only: [:dev, :test]},
5555
{:fun_registry, github: "renderedtext/fun-registry", only: [:dev, :test]},
5656
{:grpc_mock, github: "renderedtext/grpc-mock", only: [:dev, :test]},
5757
{:yaml_elixir, "~> 2.4"},

front/mix.lock

Lines changed: 9 additions & 7 deletions
Large diffs are not rendered by default.

front/test/browser/account_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ defmodule Front.Browser.AccountTest do
1919
end
2020

2121
describe "Okta welcome page" do
22-
test "it welcomes the customer to semaphore", %{page_url: page_url, session: session} do
22+
browser_test "it welcomes the customer to semaphore", %{page_url: page_url, session: session} do
2323
page = visit(session, page_url)
2424

2525
assert_text(page, "Welcome")
2626
end
2727

28-
test "it asks the customer to connect to a git provider account", %{
28+
browser_test "it asks the customer to connect to a git provider account", %{
2929
page_url: page_url,
3030
session: session
3131
} do

front/test/browser/activity_monitor_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ defmodule Front.Browser.ActivityMonitorTest do
1717
{:ok, %{page: page}}
1818
end
1919

20-
test "active pipelines are displayed on the activity monitor page", %{page: page} do
20+
browser_test "active pipelines are displayed on the activity monitor page", %{page: page} do
2121
FrontWeb.Plugs.Development.ActivityMonitor.running_pipelines()
2222
|> Enum.each(fn p ->
2323
assert_text(page, p.commit_message)
2424
end)
2525
end
2626

27-
test "queuing pipelines are displayed on the activity monitor page", %{page: page} do
27+
browser_test "queuing pipelines are displayed on the activity monitor page", %{page: page} do
2828
assert_text(page, "Lobby")
2929
assert_text(page, "(1)")
3030
end
3131

32-
test "usage gauge for machines are presented on the activity monitor", %{page: page} do
32+
browser_test "usage gauge for machines are presented on the activity monitor", %{page: page} do
3333
assert_text(page, "e1-standard-2")
3434
assert_text(page, "4/8")
3535
end

front/test/browser/audit_logs_test.exs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Front.Browser.AuditLogsTest do
55

66
import Wallaby.Query, only: [link: 1]
77

8-
test "viewing audit logs that have project details", %{session: session} do
8+
browser_test "viewing audit logs that have project details", %{session: session} do
99
user = Stubs.User.create_default()
1010
org = Stubs.Organization.create_default()
1111
Support.Stubs.Feature.enable_feature(org.id, :audit_logs)
@@ -83,7 +83,7 @@ defmodule Front.Browser.AuditLogsTest do
8383
}}
8484
end
8585

86-
test "project link is displayed", %{session: session, project: project} do
86+
browser_test "project link is displayed", %{session: session, project: project} do
8787
page = open(session)
8888

8989
assert_text(page, "Project:")
@@ -94,7 +94,7 @@ defmodule Front.Browser.AuditLogsTest do
9494
assert Wallaby.Browser.current_path(page) == "/projects/#{project.name}"
9595
end
9696

97-
test "branch link is displayed", %{session: session, branch: branch} do
97+
browser_test "branch link is displayed", %{session: session, branch: branch} do
9898
page = open(session)
9999

100100
assert_text(page, "Branch:")
@@ -105,7 +105,7 @@ defmodule Front.Browser.AuditLogsTest do
105105
assert Wallaby.Browser.current_path(page) == "/branches/#{branch.id}"
106106
end
107107

108-
test "workflow link is displayed", %{session: session, workflow: workflow, hook: hook} do
108+
browser_test "workflow link is displayed", %{session: session, workflow: workflow, hook: hook} do
109109
page = open(session)
110110

111111
assert_text(page, "Workflow:")
@@ -116,7 +116,11 @@ defmodule Front.Browser.AuditLogsTest do
116116
assert Wallaby.Browser.current_path(page) == "/workflows/#{workflow.id}"
117117
end
118118

119-
test "pipeline link is displayed", %{session: session, workflow: workflow, pipeline: pipeline} do
119+
browser_test "pipeline link is displayed", %{
120+
session: session,
121+
workflow: workflow,
122+
pipeline: pipeline
123+
} do
120124
page = open(session)
121125

122126
assert_text(page, "Pipeline:")
@@ -127,13 +131,13 @@ defmodule Front.Browser.AuditLogsTest do
127131
assert Wallaby.Browser.current_path(page) == "/workflows/#{workflow.id}"
128132
end
129133

130-
test "event description is visible", %{session: session} do
134+
browser_test "event description is visible", %{session: session} do
131135
page = open(session)
132136

133137
assert_text(page, "Triggered a promotion to Production")
134138
end
135139

136-
test "agent name and IP address is visible", %{session: session} do
140+
browser_test "agent name and IP address is visible", %{session: session} do
137141
page = open(session)
138142

139143
assert_text(page, "s1-local-testing")

front/test/browser/organization_settings/contacts_test.exs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,24 @@ defmodule Front.Browser.OrganizationSettings.ContactsTest do
2121
end
2222

2323
describe "form" do
24-
test "when org does not have any contacts, it is empty", %{page: page} do
24+
browser_test "when org does not have any contacts, it is empty", %{page: page} do
2525
page
2626
|> click(@contacts_tab)
2727
|> assert_contact_forms_are_shown()
2828
end
2929

30-
test "when org has only one contact set, display it's information", %{page: page, org: org} do
30+
browser_test "when org has only one contact set, display it's information", %{
31+
page: page,
32+
org: org
33+
} do
3134
insert_contact(org.id, "CONTACT_TYPE_MAIN", "Joe")
3235

3336
page
3437
|> click(@contacts_tab)
3538
|> assert_contact_name_is_present("Joe")
3639
end
3740

38-
test "fill out financial contact info", %{page: page} do
41+
browser_test "fill out financial contact info", %{page: page} do
3942
page
4043
|> click(@contacts_tab)
4144
|> submit_form()

0 commit comments

Comments
 (0)