E531 test(portal): rewrite all .old tests by jamilbk · Pull Request #12496 · firezone/firezone · GitHub
[go: up one dir, main page]

Skip to content

test(portal): rewrite all .old tests#12496

Open
jamilbk wants to merge 1 commit intomainfrom
chore/unit-tests
Open

test(portal): rewrite all .old tests#12496
jamilbk wants to merge 1 commit intomainfrom
chore/unit-tests

Conversation

@jamilbk
Copy link
Member
@jamilbk jamilbk commented Mar 8, 2026

Restores/rewrites all of the .old tests from before the major IdP refactor.

Some application code was changed in order to fix failing assertions (read: bugs).


Fixes #11056

@vercel
Copy link
vercel bot commented Mar 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
firezone Ready Ready Preview, Comment Mar 11, 2026 5:38pm

Request Review

@jamilbk
Copy link
Member Author
jamilbk commented Mar 8, 2026

Draft because stacked on #12431

Base automatically changed from credo-nesting to main March 10, 2026 16:05
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores and rewrites legacy .old test coverage across the Portal Web/API domains after the IdP refactor, updating fixtures and flows to match the current authentication and domain model. It also includes a few targeted application-code adjustments to align behavior with the rewritten tests and fix surfaced issues.

Changes:

  • Replaced many legacy .old tests with updated .exs equivalents using the new *Fixtures modules and updated sign-in/provider flows.
  • Updated Portal Web LiveViews to handle internet resource/site absence safely and to compute gateway online counts without per-render presence lookups.
  • Hardened keyset pagination by validating cursor values during paginator initialization.

Reviewed changes

Copilot reviewed 88 out of 88 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
elixir/test/portal_web/live/sites/new_token_test.old Removed legacy .old test file.
elixir/test/portal_web/live/sites/new_token_test.exs Added rewritten tests for new-token page rendering and connection status element.
elixir/test/portal_web/live/sites/new_test.exs Updated site creation tests to new fixtures/actor auth and updated form selectors/fields.
elixir/test/portal_web/live/sites/index_test.exs Updated fixtures and added setup requirements (internet resource) + presence-driven table update assertions.
elixir/test/portal_web/live/sites/gateways/index_test.old Removed legacy .old test file.
elixir/test/portal_web/live/sites/edit_test.exs Updated site edit tests to new fixtures/actor auth and form selectors.
elixir/test/portal_web/live/sign_in_test.old Removed legacy .old test file.
elixir/test/portal_web/live/sign_in_test.exs Added rewritten sign-in page tests using new auth provider fixtures.
elixir/test/portal_web/live/sign_in/email_test.old Removed legacy .old test file.
elixir/test/portal_web/live/sign_in/email_test.exs Added rewritten email OTP LiveView tests (cookie/OTP flow).
elixir/test/portal_web/live/sidebar_test.old Removed legacy .old test file.
elixir/test/portal_web/live/sidebar_test.exs Added rewritten sidebar active-state and dropdown visibility tests using actor auth.
elixir/test/portal_web/live/settings/billing_test.old Removed legacy .old test file.
elixir/test/portal_web/live/settings/account_test.exs Updated account settings LiveView tests to new fixtures/actor auth; removed some legacy scenarios.
elixir/test/portal_web/live/settings/account/notifications_edit_test.exs Updated notifications edit tests to new fixtures/actor auth and form selector.
elixir/test/portal_web/live/resources/index_test.old Removed legacy .old test file.
elixir/test/portal_web/live/resources/index_test.exs Added rewritten resources index LiveView tests (policies count, internet section, WAL hook reload).
elixir/test/portal_web/live/groups/show_test.old Removed legacy .old test file.
elixir/test/portal_web/live/groups/new_test.old Removed legacy .old test file.
elixir/test/portal_web/live/groups/index_test.old Removed legacy .old test file.
elixir/test/portal_web/live/groups/edit_test.old Removed legacy .old test file.
elixir/test/portal_web/live/groups/edit_actors_test.old Removed legacy .old test file.
elixir/test/portal_web/live/clients/index_test.old Removed legacy .old test file.
elixir/test/portal_web/live/clients/edit_test.exs Updated client edit tests to new fixtures/actor auth and form selector.
elixir/test/portal_web/live/actors/users/new_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/users/new_identity_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/service_accounts/new_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/service_accounts/new_identity_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/new_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/index_test.old Removed legacy .old test file.
elixir/test/portal_web/live/actors/groups_test.old Removed legacy .old test file.
elixir/test/portal_web/controllers/sign_in_controller_test.old Removed legacy .old controller test file.
elixir/test/portal_web/controllers/sign_in_controller_test.exs Added rewritten client redirect cookie tests using PortalWeb.Cookie.ClientAuth.
elixir/test/portal_web/controllers/home_controller_test.exs Updated “recent accounts” cookie test to use PortalWeb.Cookie.RecentAccounts; updated error message assertion.
elixir/test/portal_web/banner_test.old Removed legacy .old test file.
elixir/test/portal_web/banner_test.exs Added rewritten banner rendering tests using new fixtures/actor auth.
elixir/test/portal_web/authentication_test.exs Added tests for PortalWeb.Authentication.take_sign_in_params/1 behavior.
elixir/test/portal_web/acceptance/auth_test.old Removed legacy .old acceptance test file.
elixir/test/portal_web/acceptance/auth_test.exs Added rewritten acceptance auth tests for provider options and sign-out flows.
elixir/test/portal_web/acceptance/auth/userpass_test.old Removed legacy .old acceptance test file.
elixir/test/portal_web/acceptance/auth/userpass_test.exs Added rewritten userpass acceptance flows aligned with new auth model/fields.
elixir/test/portal_web/acceptance/auth/openid_connect_test.old Removed legacy .old acceptance test file.
elixir/test/portal_web/acceptance/auth/openid_connect_test.exs Added rewritten OIDC acceptance tests using new identity fixture fields.
elixir/test/portal_web/acceptance/auth/email_test.old Removed legacy .old acceptance test file.
elixir/test/portal_web/acceptance/auth/email_test.exs Added rewritten email sign-in acceptance test for enumeration-safe UX.
elixir/test/portal_api/rate_limit.old Removed legacy .old API rate limit test file.
elixir/test/portal_api/client/views/interface_test.exs Updated interface view test to new client IP address field structure and DataCase usage.
elixir/test/portal/workers/outdated_gateways_test.old Removed legacy .old worker test file.
elixir/test/portal/workers/delete_expired_one_time_passcodes_test.exs Updated to call Portal.Authentication.create_one_time_passcode/2 and renamed alias accordingly.
elixir/test/portal/repo/filter_test.exs Refactored query setup helper and adjusted invalid-type test cases.
elixir/test/portal/notifications/jobs/outdated_gateways_test.old Removed legacy .old notifications job test file.
elixir/test/portal/mailer/sync_error_email_test.old Removed legacy .old mailer test file.
elixir/test/portal/mailer/sync_error_email_test.exs Added rewritten directory sync error email tests using directory fixtures.
elixir/test/portal/mailer/notifications_test.exs Updated fixtures and adjusted expected outdated-clients URL format.
elixir/test/portal/mailer/auth_email_test.old Removed legacy .old mailer test file.
elixir/test/portal/mailer/account_delete_email_test.exs Updated to use SubjectFixtures instead of identity-based subject construction.
elixir/test/portal/crypto_test.old Removed legacy .old test file.
elixir/test/portal/config_test.exs Updated to new account fixture and updated expected validator error message formatting.
elixir/test/portal/config/validator_test.exs Updated expected error messages for IP/CIDR validation failures.
elixir/test/portal/changes/hooks/tokens_test.old Removed legacy .old hooks test file.
elixir/test/portal/changes/hooks/tokens_test.exs Added rewritten hook tests targeting Portal.Changes.Hooks.ClientTokens.
elixir/test/portal/changes/hooks/resources_test.exs Updated to new fixtures and PubSub subscription namespace; adjusted assertions.
elixir/test/portal/changes/hooks/policies_test.exs Updated to new fixtures and PubSub subscription namespace; clarified breaking-update test naming.
elixir/test/portal/changes/hooks/memberships_test.exs Updated PubSub subscription namespace and fixture imports; removed unused setup block.
elixir/test/portal/changes/hooks/gateways_test.exs Updated to new fixtures and PubSub subscription namespace.
elixir/test/portal/changes/hooks/clients_test.exs Updated to new fixtures and PubSub subscription namespace; updated policy authorization fixture usage.
elixir/test/portal/billing/stripe/api_client_test.old Removed legacy .old Stripe client test file.
elixir/test/portal/billing/stripe/api_client_test.exs Added rewritten Stripe API client tests using Req.Test stubs and Stripe mocks.
elixir/test/portal/billing/jobs/check_account_limits_test.old Removed legacy .old billing job test file.
elixir/lib/portal_web/live/sites/new.ex Simplified new-site changeset building to use cast/3 + Portal.Site.changeset/1.
elixir/lib/portal_web/live/sites/index.ex Avoided nil crash when no internet resource; precomputed per-site gateway online counts for rendering.
elixir/lib/portal_web/live/clients/edit.ex Refactored client edit changeset flow (casts/required fields; applies Portal.Client.changeset/1 on change).
elixir/lib/portal_web/authentication.ex Added nil-safe clause for take_sign_in_params/1.
elixir/lib/portal/repo/paginator.ex Added cursor value validation during paginator init to reject invalid cursor values early.
elixir/lib/portal/presence.ex Reordered gateway presence tracking (Site before Account) to align reload behavior with current subscribers.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly a change to make the presence tests less flaky.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor refactoring in this module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents an invalid cursor from raising ArgumentError

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor cleanup

socket
|> assign(internet_resource: internet_resource)
|> assign(internet_site: internet_resource.site)
|> assign(internet_site: internet_resource && internet_resource.site)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents the user from seeing a 500 if for some reason there is no internet resource for this account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-implement broken portal tests

2 participants

0