From e5ffd637bb745a620af67bd3305580c1a637e71a Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 14 May 2025 09:57:37 +0200 Subject: [PATCH 1/4] FIX: ensure we can lookup identic ip adresses This has been broken in https://github.com/discourse/discourse/commit/b6aad28ccffc276153fe847621d282549c4aac78 We correctly access the users object and added a test to prevent future regressions. --- app/assets/javascripts/admin/addon/components/ip-lookup.gjs | 3 ++- spec/system/admin_user_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs index 1cb45f04fa941..b2fe12a38fa9d 100644 --- a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs +++ b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs @@ -72,7 +72,8 @@ export default class IpLookup extends Component { }); this.totalOthersWithSameIP = result.total; - const users = await AdminUser.findAll("active", data); + let users = await AdminUser.findAll("active", data)?.users; + this.otherAccounts = users; this.otherAccountsLoading = false; } diff --git a/spec/system/admin_user_spec.rb b/spec/system/admin_user_spec.rb index 9cac00a8bff7c..876539eb4c84d 100644 --- a/spec/system/admin_user_spec.rb +++ b/spec/system/admin_user_spec.rb @@ -39,6 +39,12 @@ before { admin_user_page.visit(user) } + it "can list accounts with identic IPs" do + find(".ip-lookup-trigger").click + + expect(page).to have_content("#{I18n.t("js.ip_lookup.other_accounts")}\n3") + end + it "displays the suspend and silence buttons" do expect(admin_user_page).to have_suspend_button expect(admin_user_page).to have_silence_button From fb1ac89422ef62e20a389915bda013c4cc0fe10b Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 14 May 2025 09:58:25 +0200 Subject: [PATCH 2/4] const --- app/assets/javascripts/admin/addon/components/ip-lookup.gjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs index b2fe12a38fa9d..ccd3f6a8b47bd 100644 --- a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs +++ b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs @@ -72,7 +72,7 @@ export default class IpLookup extends Component { }); this.totalOthersWithSameIP = result.total; - let users = await AdminUser.findAll("active", data)?.users; + const users = await AdminUser.findAll("active", data)?.users; this.otherAccounts = users; this.otherAccountsLoading = false; From 17dde9d91a20417de9c66e2fa44d152110212bb6 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 14 May 2025 10:08:13 +0200 Subject: [PATCH 3/4] Update spec/system/admin_user_spec.rb Co-authored-by: David Taylor --- spec/system/admin_user_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin_user_spec.rb b/spec/system/admin_user_spec.rb index 876539eb4c84d..2174aa580118c 100644 --- a/spec/system/admin_user_spec.rb +++ b/spec/system/admin_user_spec.rb @@ -39,7 +39,7 @@ before { admin_user_page.visit(user) } - it "can list accounts with identic IPs" do + it "can list accounts with identical IPs" do find(".ip-lookup-trigger").click expect(page).to have_content("#{I18n.t("js.ip_lookup.other_accounts")}\n3") From f24b68cf9b4f00ed0c422775347e6b4669ae3dac Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 14 May 2025 10:27:52 +0200 Subject: [PATCH 4/4] ensure we have displayed users --- app/assets/javascripts/admin/addon/components/ip-lookup.gjs | 5 ++--- spec/system/admin_user_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs index ccd3f6a8b47bd..d594651338319 100644 --- a/app/assets/javascripts/admin/addon/components/ip-lookup.gjs +++ b/app/assets/javascripts/admin/addon/components/ip-lookup.gjs @@ -71,10 +71,9 @@ export default class IpLookup extends Component { data, }); this.totalOthersWithSameIP = result.total; + let request = await AdminUser.findAll("active", data); - const users = await AdminUser.findAll("active", data)?.users; - - this.otherAccounts = users; + this.otherAccounts = request.users; this.otherAccountsLoading = false; } } catch (error) { diff --git a/spec/system/admin_user_spec.rb b/spec/system/admin_user_spec.rb index 876539eb4c84d..e659eebd72cce 100644 --- a/spec/system/admin_user_spec.rb +++ b/spec/system/admin_user_spec.rb @@ -43,6 +43,11 @@ find(".ip-lookup-trigger").click expect(page).to have_content("#{I18n.t("js.ip_lookup.other_accounts")}\n3") + + table = page.find(".other-accounts table") + expect(table).to have_content(similar_user.username) + expect(table).to have_content(another_mod.username) + expect(table).to have_content(another_admin.username) end it "displays the suspend and silence buttons" do