@@ -255,6 +255,54 @@ describe('Overview component', () => {
255255 }
256256 } )
257257
258+ it ( 'sorts nodes by URI when selected' , async ( ) => {
259+ render (
260+ < MockedProvider mocks = { mocks } addTypename = { false } >
261+ < Overview />
262+ </ MockedProvider >
263+ )
264+
265+ await screen . findByText ( 'http://192.168.1.10:4444' )
266+
267+ const user = userEvent . setup ( )
268+ const selectElement = screen . getByRole ( 'combobox' )
269+ await user . click ( selectElement )
270+ await user . click ( screen . getByText ( 'URI' ) )
271+
272+ // After sorting by URI, node1 should appear before node2
273+ const nodeUris = screen . getAllByText ( / h t t p : \/ \/ 1 9 2 \. 1 6 8 \. 1 \. \d + : 4 4 4 4 / )
274+ expect ( nodeUris [ 0 ] ) . toHaveTextContent ( 'http://192.168.1.10:4444' )
275+ expect ( nodeUris [ 1 ] ) . toHaveTextContent ( 'http://192.168.1.11:4444' )
276+ } )
277+
278+ it ( 'sorts nodes by URI in descending order when selected' , async ( ) => {
279+ render (
280+ < MockedProvider mocks = { mocks } addTypename = { false } >
281+ < Overview />
282+ </ MockedProvider >
283+ )
284+
285+ await screen . findByText ( 'http://192.168.1.10:4444' )
286+
287+ const user = userEvent . setup ( )
288+ const selectElement = screen . getByRole ( 'combobox' )
289+ await user . click ( selectElement )
290+ await user . click ( screen . getByText ( 'URI' ) )
291+
292+ const descendingLabel = screen . getByText ( 'Descending' )
293+ const checkbox = descendingLabel . closest ( 'label' ) ?. querySelector ( 'input[type="checkbox"]' )
294+ expect ( checkbox ) . not . toBeNull ( )
295+ if ( checkbox ) {
296+ await user . click ( checkbox )
297+ expect ( checkbox ) . toBeChecked ( )
298+ }
299+
300+ // After sorting by URI descending, node2 should appear before node1
301+ const nodeUris = screen . getAllByText ( / h t t p : \/ \/ 1 9 2 \. 1 6 8 \. 1 \. \d + : 4 4 4 4 / )
302+ expect ( nodeUris [ 0 ] ) . toHaveTextContent ( 'http://192.168.1.11:4444' )
303+ expect ( nodeUris [ 1 ] ) . toHaveTextContent ( 'http://192.168.1.10:4444' )
304+ } )
305+
258306 it ( 'renders live view icon for node with VNC session' , async ( ) => {
259307 render (
260308 < MockedProvider mocks = { mocks } addTypename = { false } >
0 commit comments