@@ -21,6 +21,7 @@ defmodule NervesHubWeb.Live.Devices.IndexTest do
2121 change = render_change ( view , "update-filters" , % { "device_id" => device . identifier } )
2222 assert change =~ device . identifier
2323 refute change =~ device2 . identifier
24+ assert change =~ "1 devices found"
2425 end
2526
2627 test "filters devices by wrong identifier" , % { conn: conn , fixture: fixture } do
@@ -35,6 +36,7 @@ defmodule NervesHubWeb.Live.Devices.IndexTest do
3536 change = render_change ( view , "update-filters" , % { "device_id" => "foo" } )
3637 refute change =~ device . identifier
3738 refute change =~ device2 . identifier
39+ assert change =~ "0 devices found"
3840 end
3941
4042 test "filters devices by prefix identifier" , % { conn: conn , fixture: fixture } do
@@ -128,6 +130,39 @@ defmodule NervesHubWeb.Live.Devices.IndexTest do
128130 assert change =~ device2 . identifier
129131 refute change =~ device3 . identifier
130132 end
133+
134+ test "select device" , % { conn: conn , fixture: fixture } do
135+ % { device: _device , firmware: firmware , org: org , product: product } = fixture
136+
137+ device2 = Fixtures . device_fixture ( org , product , firmware , % { tags: nil } )
138+ _device3 = Fixtures . device_fixture ( org , product , firmware , % { tags: [ "foo" ] } )
139+
140+ { :ok , view , html } = live ( conn , device_index_path ( fixture ) )
141+ assert html =~ "3 devices found"
142+ refute html =~ "(1 selected)"
143+
144+ change = render_change ( view , "select" , % { "id" => device2 . id } )
145+ assert change =~ "3 devices found"
146+ assert change =~ "(1 selected)"
147+ end
148+
149+ test "select/deselect all devices" , % { conn: conn , fixture: fixture } do
150+ % { device: _device , firmware: firmware , org: org , product: product } = fixture
151+
152+ _device2 = Fixtures . device_fixture ( org , product , firmware , % { tags: nil } )
153+ _device3 = Fixtures . device_fixture ( org , product , firmware , % { tags: [ "foo" ] } )
154+
155+ { :ok , view , html } = live ( conn , device_index_path ( fixture ) )
156+ assert html =~ "3 devices found"
157+
158+ change = render_change ( view , "select-all" , % { } )
159+ assert change =~ "3 devices found"
160+ assert change =~ "(3 selected)"
161+
162+ change = render_change ( view , "select-all" , % { } )
163+ assert change =~ "3 devices found"
164+ refute change =~ "selected)"
165+ end
131166 end
132167
133168 describe "bulk actions" do
0 commit comments