Skip to content

Commit 00ce165

Browse files
committed
Fix review comments
1 parent 92b4ebc commit 00ce165

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

javascript/grid-ui/src/screens/Overview/Overview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function Overview (): JSX.Element {
6666

6767
const sortProperties = {
6868
'platformName': (a, b) => compareSlotStereotypes(a, b, 'platformName'),
69-
'status': (a, b) => a.status.localeCompare(b.status),
70-
'uri': (a, b) => a.uri.localeCompare(b.uri),
69+
'status': (a, b) => (a.status ?? '').localeCompare(b.status ?? ''),
70+
'uri': (a, b) => (a.uri ?? '').localeCompare(b.uri ?? ''),
7171
'browserName': (a, b) => compareSlotStereotypes(a, b, 'browserName'),
7272
'browserVersion': (a, b) => compareSlotStereotypes(a, b, 'browserVersion'),
7373
'slotCount': (a, b) => {

javascript/grid-ui/src/tests/components/Overview.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,34 @@ describe('Overview component', () => {
275275
expect(nodeUris[1]).toHaveTextContent('http://192.168.1.11:4444')
276276
})
277277

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(/http:\/\/192\.168\.1\.\d+:4444/)
302+
expect(nodeUris[0]).toHaveTextContent('http://192.168.1.11:4444')
303+
expect(nodeUris[1]).toHaveTextContent('http://192.168.1.10:4444')
304+
})
305+
278306
it('renders live view icon for node with VNC session', async () => {
279307
render(
280308
<MockedProvider mocks={mocks} addTypename={false}>

0 commit comments

Comments
 (0)