Skip to content

Commit

Permalink
Omit networks without an essid
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Apr 28, 2021
1 parent 1c2af43 commit d1a57f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/y2network/dialogs/wireless_networks.rb
Expand Up @@ -121,6 +121,7 @@ def find_networks(cache = true)
_("Scanning for wireless networks..."), headline: _("Scanning network")
) do
found_networks = Y2Network::WirelessNetwork.all(@builder.interface.name, cache: cache)
found_networks.delete_if { |n| n.essid.to_s.empty? }
log.info("Found networks: #{found_networks.map(&:essid)}")
end

Expand Down
20 changes: 17 additions & 3 deletions test/y2network/dialogs/wireless_networks_test.rb
Expand Up @@ -34,6 +34,14 @@
Y2Network::Widgets::WirelessNetworks.new(builder)
end

let(:scanned_networks) do
[hidden, selected]
end

let(:hidden) do
instance_double(Y2Network::WirelessNetwork, essid: nil)
end

let(:selected) do
instance_double(Y2Network::WirelessNetwork, essid: "TESTING")
end
Expand All @@ -46,7 +54,7 @@
allow(Y2Network::Widgets::WirelessNetworks).to receive(:new)
.and_return(networks_table)
allow(Y2Network::WirelessNetwork).to receive(:all).with("wlo1", cache: true)
.and_return([selected])
.and_return(scanned_networks)
allow(networks_table).to receive(:selected).and_return(selected)
allow(networks_table).to receive(:update)
allow(Yast2::Feedback).to receive(:show) { |&block| block.call }
Expand All @@ -55,13 +63,18 @@
end

describe "#run" do
let(:event) { { "ID" => :ok, "EventReason" => "Activated" } }

before do
allow(Yast::UI).to receive(:WaitForEvent).and_return(event)
end

context "if the user clicks the 'Select' button" do
let(:event) { { "ID" => :ok, "EventReason" => "Activated" } }
it "does not show networks without and essid in the table selection" do
expect(networks_table).to receive(:update).with([selected])
subject.run
end

context "if the user clicks the 'Select' button" do
it "returns the selected network" do
expect(subject.run).to eq(selected)
end
Expand All @@ -74,5 +87,6 @@
expect(subject.run).to eq(nil)
end
end

end
end

0 comments on commit d1a57f9

Please sign in to comment.