Commit Graph

31 Commits

Author SHA1 Message Date
ed1e0e30f2 DEV: Remove full_page_login setting (#32189)
We are making this the only option for our login/signup
pages on April 29th, 2025, per

https://meta.discourse.org/t/introducing-our-new-fullscreen-signup-and-login-pages/340401.

This commit removes the `full_page_login` setting and any logic
around it, as well as deleting the old login and signup modals,
and removing leftover problem checks and settings from the database.
2025-04-29 10:40:40 +02:00
b6281d0c52 DEV: Introduce with_security_key system test helper (#32459)
Instead of having each test go incur the overhead of having to go
through the actual user flow to register a security key, we can generate
the WebAuthn credentials on the server side and adds it to the virtual
authenticator.
2025-04-25 15:40:07 +08:00
0724b03fb8 DEV: Bump Capybara.default_max_wait_time to 20 on CI (#32143)
There are flaky system tests that have been exhausting the 10 seconds
default max wait time which we have set previously on CI. However, I
have yet to be able to figure out why and lack the tools to be able to
figure out why. The hope here is that the upcoming playwright driver
will provide us with better tooling to debug such problems.

I've attempted to use `Capybara::Session#using_wait_time` by there is
some race condition going on where the session's default max wait time
is sometimes not set properly. I can't figure out why and have spent too
much time trying to figure out why. Instead, I will just bump up the
`default_max_wait_time` to `20`. This may the build take longer when
there are test failures but it is a trade-off we will make right now.
2025-04-04 12:50:28 +08:00
0cb08a3d2f DEV: Double timeout in spec/email_change_spec.rb (#32131)
Checking of the database state is still flaky on CI. Double the timeout
to give the server more time to process as a workaround.

Example of test flake:
https://github.com/discourse/discourse/actions/runs/14216968060/job/39835831706
2025-04-02 20:10:57 +08:00
0f3d61b463 DEV: Use Capybara::Session#using_wait_time instead (#32116)
When `Capybara.threadsafe` has been set to `true` as in our case, we
have to use `Capybara::Session#using_wait_time` instead of
`Capybara.using_wait_time`. The latter sets `default_max_wait_time` on
`Capybara.default_max_wait_time` while the former sets
`default_max_wait_time` on the session.
2025-04-02 09:11:26 +08:00
7f25e13222 DEV: Double default capybara max wait time for certain tests take 3 (#32096)
This is a follow up to 59edec46a3de105e720bd2c716ae34d636794044

Test is flaky and seems to require more time to complete on CI so we
double the max wait time for now to see if it reduces the test's
flakiness.
2025-04-01 11:35:28 +08:00
59edec46a3 DEV: Double default capybara wait time for certain flaky tests take 2 (#32058)
The `using_wait_time` DSL did not work when used in the `around` context
as the Capybara's session has not been initialized.

Follow-up to afde7cc1727a751e4d87be2ceee17f2d82edf89c
2025-03-28 16:09:15 +08:00
afde7cc172 DEV: Double default capybara wait time for certain flaky tests (#32057)
I'm not sure what is causing the tests to be flaky so I need more
information to determine where the problem is. For now, I'm doubling the
wait time to rule out any server side problem.
2025-03-28 13:49:42 +08:00
9d786ad870 DEV: Dump all threads for some flaky system tests (#32050)
This is to provide diagnostic information for some flaky system tests
which we are currently investigating. The previous attempt in
6f92f42eb83fea61b2712aaaefcc124e4939365d only dumped threads that
contains the `puma` gem in the backtrace but that is not enough. Since I
am now printing all thread backtraces, I added the
`dump_threads_on_failure` metadata
which will be used to determine if all the thread backtraces should be
printed out in the spec's failure output.
2025-03-28 09:54:05 +08:00
ac26a52c6d DEV: Improve PageObjects::Pages::UserPreferencesSecurity#visit_second_factor (#32017)
This commit improves said method to ensure that user is redirected to
the right page before returning.

### Reviewer notes

Example of test flakiness:
https://github.com/discourse/discourse/actions/runs/14081653020/job/39435797236

```
Failure/Error: raise capybara_timeout_error

CapybaraTimeoutExtension::CapybaraTimedOut:
  This spec passed, but capybara waited for the full wait duration (10s) at least once. This will slow down the test suite. Beware of negating the result of selenium's RSpec matchers.

[Screenshot Image]: /__w/discourse/discourse/tmp/capybara/failures_r_spec_example_groups_user_resetting_password_when_desktop_when_user_has_multi_factor_authentication_configured_when_user_has_security_key_and_backup_codes_configured_should_allow_a_user_to_reset_pass_261.png

~~~~~~~ JS LOGS ~~~~~~~
~~~~~ END JS LOGS ~~~~~

Shared Example Group: "forgot password scenarios" called from ./spec/system/forgot_password_spec.rb:213

./spec/rails_helper.rb:426:in `block (3 levels) in <top (required)>'
./spec/rails_helper.rb:619:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/benchmark-0.4.0/lib/benchmark.rb:304:in `measure'
./spec/rails_helper.rb:619:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:580:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:185:in `block in timeout'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:192:in `timeout'
./spec/rails_helper.rb:570:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:527:in `block (2 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/webmock-3.25.1/lib/webmock/rspec.rb:39:in `block (2 levels) in <top (required)>'
```
2025-03-26 22:11:03 +08:00
6aaddcf381 FEATURE: enable full page login by default (#31771)
This switches the signup/login UI to the full page experience by
default. This has been in use by many sites for multiple months and we
have ironed out many fixes in the meantime.

The `full_page_login` setting is also marked for removal in about
1.5mths, by the end of April 2025.
2025-03-25 13:43:51 -04:00
3cf9f81552 DEV: Unksip flaky changing email system tests (#31991)
This commit unskips 3 flaky system tests and gives up on asserting that
redirecting is done correctly. This is because we have invested
considerable effort into this and cannot figure it out. The redirect is
tested by the client side anyway so there is still some test coverage.
2025-03-25 09:09:50 -04:00
ab3e85f8f1 DEV: Skip two flaky tests (#31989) 2025-03-25 15:34:21 +08:00
3df592a43e DEV: Remove assertion causing test to flake. (#31946)
This commit removes an assertion for the redirect after 2FA
authentication is success message because the message is flashed briefly
before a route transition happens. A proper fix would require us to
redesign when/how the flash message which we can address in the future.
2025-03-21 11:38:03 +08:00
871356f547 UX: Improve UX of 2FA token submission page (#31918)
This commit updates the 2FA token submission page to disable the submit
button when the 2FA token is not valid and to also set the submit button
to be in the loading state after the submit button has been clicked.

The UX issues were discovered while I was investigating a flaky test
which has been unskipped in this commit as well. I am not sure if  this
will completely resolve the flakiness but we have to unskip it to know
if it continues to be flaky.
2025-03-21 08:49:12 +08:00
80118c8891 DEV: Attempt to fix flaky system tests around email confirmation (#31904)
Both tests being unskipped here failed previosly with the following
error:

```
Failure/Error: expect(page).to have_current_path("/u/#{user.username}/preferences/account")
  expected "/u/confirm-new-email/f42a416fcbca40d66788d65a8837ad49" to equal "/u/bruce306/preferences/account"

./spec/system/email_change_spec.rb:49:in `block (2 levels) in <main>'
```

The error indicates that the transition was not successful and I
suspect that it may be due to the use of the `/my` route prefix which
is just a nice to have and not necessary.
2025-03-19 18:44:05 +08:00
a7f8233452 DEV: Skip flakey email change spec (#31831) 2025-03-14 10:53:28 -04:00
f3f2ae1ae7 FIX: Double wait timeout for mail deliver in email_change_spec.rb (#31818)
The tests have been flaky on CI so just double the timeouts for now.
We will investigate further if it continues to flake with the doubled
timeout.
2025-03-14 11:40:50 +08:00
5aa1e58492 DEV: Wrong test was skipped in e9244ebc6819d517c6001a92413c1814ce52656c (#31817) 2025-03-14 11:40:33 +08:00
e9244ebc68 DEV: Skip two high frequency flaky test (#31816) 2025-03-14 10:01:31 +08:00
e6034af1ba DEV: more resilient email change spec (#31754)
This might not reduce the failures to zero but some screenshots of the
failures clearly show we were still on the success message page.

Same fix than: https://github.com/discourse/discourse/pull/31750
2025-03-11 18:48:11 +01:00
31b621bfda DEV: more resilient email change spec (#31750)
This might not reduce the failures to zero but some screenshots of the
failures clearly show we were still on the success message page.
2025-03-11 17:44:03 +01:00
c1c7ea8959 DEV: Change hide_email_address_taken default to true (#30293)
We're changing the default of hide_email_address_taken to true. This is a trade-off we want to make, as it prevents account enumeration with minimal impact on legitimate users. If you forget you have an account and try to sign up again with the same e-mail you'll receive an e-mail letting you know.
2024-12-17 10:46:04 +08:00
952f69ce60 FIX: User can't reset password with backup codes when only security key is enabled (#27368)
This commit fixes a problem where the user will not be able to reset
their password when they only have security keys and backup codes
configured.

This commit also makes the following changes/fixes:

1. Splits password reset system tests to
   `spec/system/forgot_password_spec.rb` instead of missing the system
   tests in `spec/system/login_spec.rb` which is mainly used to test
   the login flow.

2. Fixes a UX issue where the `Use backup codes` or `Use authenticator
   app` text is shown on the reset password form when the user does
   not have either backup codes or an authenticator app configured.
2024-06-06 14:30:42 +08:00
4d8eca91ef Revert "DEV: Use 127.0.0.1 instead of localhost as Capybara's server host (#27215)" (#27218)
This reverts commit 998b50fdf4b83383c9b8cbebdf606477f2a799a2.

Ended up making system tests even more unstable
2024-05-28 11:32:22 +08:00
998b50fdf4 DEV: Use 127.0.0.1 instead of localhost as Capybara's server host (#27215)
We are seeing a weird resolution error on Github actions with the
following backtrace:

```
Failure/Error:
  visit File.join(
          GlobalSetting.relative_url_root || "",
          "/session/#{user.encoded_username}/become.json?redirect=false",
        )

Socket::ResolutionError:
  getaddrinfo: Temporary failure in name resolution

```

Switch to use `127.0.0.1` instead of forcing a name resolution.
2024-05-28 09:47:22 +08:00
31e44cfa82 DEV: Fix flaky "Changing email" system tests (#25805)
Why this change?

`current_url` does not rely on Capybara waiters so opt to use
`have_current_path` matcher instead. Also assert for email against
element displayed on the page instead of querying the database for it
which isn't really what system tests are meant for.
2024-02-22 10:46:37 +08:00
974b3a2a6f DEV: Do not require session confirmation for new users (#24799)
When making sensitive changes to an account (adding 2FA or passkeys), we
require users to confirm their password. This is to prevent an attacker
from adding 2FA to an account they have access to.

However, on newly created accounts, we should not require this, it's an
extra step and it doesn't provide extra security (since the account was
just created). This commit makes it so that we don't require session
confirmation for accounts created less than 5 minutes ago.
2024-02-15 12:29:16 -05:00
9bd6523581 DEV: Update email_change_spec to increase wait time in CI (#25522)
CI runs on slower machines, so we need to use longer wait times. `Capybara.default_max_wait_time` is automatically reconfigured based on the environment.
2024-02-01 14:11:37 +00:00
02953ec5fa DEV: Clean up authenticator in email_change_spec (#25521) 2024-02-01 14:11:18 +00:00
283fe48243 DEV: Update confirm-email flows to use central 2fa and ember rendering (#25404)
These routes were previously rendered using Rails, and had a fairly fragile 2fa implementation in vanilla-js. This commit refactors the routes to be handled in the Ember app, removes the custom vanilla-js bundles, and leans on our centralized 2fa implementation. It also introduces a set of system specs for the behavior.
2024-01-30 10:32:42 +00:00