Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/javascript/controllers/bank_search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default class extends Controller {
const query = this.inputTarget.value.toLocaleLowerCase().trim();
let visibleCount = 0;

this.itemTargets.forEach(item => {
const name = item.dataset.bankName?.toLocaleLowerCase() ?? "";
const match = name.includes(query);
this.itemTargets.forEach((item) => {
const haystack = (item.dataset.bankSearch ?? "").toLocaleLowerCase();
const match = haystack.includes(query);
item.style.display = match ? "" : "none";
if (match) visibleCount++;
});
Expand Down
2 changes: 1 addition & 1 deletion app/views/enable_banking_items/select_bank.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<div class="space-y-2 max-h-80 overflow-y-auto">
<% @aspsps.each do |aspsp| %>
<div data-bank-search-target="item" data-bank-name="<%= aspsp[:name].to_s.downcase(:fold) %>">
<div data-bank-search-target="item" data-bank-search="<%= [ aspsp[:name], aspsp[:bic] ].compact_blank.join(" ").downcase(:fold) %>">
<%= button_to authorize_enable_banking_item_path(@enable_banking_item),
method: :post,
params: { aspsp_name: aspsp[:name], new_connection: @new_connection },
Expand Down
42 changes: 42 additions & 0 deletions test/controllers/enable_banking_items_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

require "test_helper"
require "openssl"

class EnableBankingItemsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in users(:family_admin)
@family = families(:dylan_family)
@item = @family.enable_banking_items.create!(
name: "Test Connection",
country_code: "DE",
application_id: "test_app_id",
client_certificate: OpenSSL::PKey::RSA.new(2048).to_pem
)
end

test "select_bank exposes ASPSP BIC in the searchable data attribute" do
Provider::EnableBanking.any_instance.stubs(:get_aspsps).returns(
aspsps: [
{
name: "ING-DiBa AG",
country: "DE",
bic: "INGDDEFF",
beta: false,
psu_types: [ "personal" ],
auth_methods: [ { approach: "REDIRECT" } ]
}
]
)

get select_bank_enable_banking_item_url(@item)

assert_response :success
haystack = @response.body[/data-bank-search="([^"]*)"/, 1]
assert haystack, "Expected list items to render a data-bank-search attribute the client filter reads from"
assert_includes haystack, "ingddeff",
"Expected the searchable data attribute to include the BIC so users can find banks by BIC code"
assert_includes haystack, "ing-diba ag",
"Expected the searchable data attribute to still include the bank name (existing name-search behavior)"
end
end