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.
This commit is contained in:
Alan Guo Xiang Tan
2024-05-28 09:47:22 +08:00
committed by GitHub
parent b9984d9c64
commit 998b50fdf4
3 changed files with 11 additions and 1 deletions

View File

@@ -8,6 +8,9 @@ describe "User preferences | Security", type: :system do
let(:user_menu) { PageObjects::Components::UserMenu.new }
before do
@original_host = Capybara.server_host
SiteSetting.force_hostname = Capybara.server_host = "localhost"
user.activate
# testing the enforced 2FA flow requires a user that was created > 5 minutes ago
user.created_at = 6.minutes.ago
@@ -18,6 +21,8 @@ describe "User preferences | Security", type: :system do
DiscourseWebauthn.stubs(:origin).returns(current_host + ":" + Capybara.server_port.to_s)
end
after { SiteSetting.force_hostname = Capybara.server_host = @original_host }
shared_examples "security keys" do
it "adds a 2FA security key and logs in with it" do
options = ::Selenium::WebDriver::VirtualAuthenticatorOptions.new