-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
door-summary, tests, clean up unused opmode
Signed-off-by: Aaron Chong <[email protected]>
- Loading branch information
1 parent
2329251
commit 26d7bcf
Showing
13 changed files
with
87 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
packages/rmf-dashboard-framework/src/components/doors/door-card.stories.tsx
This file was deleted.
Oops, something went wrong.
73 changes: 0 additions & 73 deletions
73
packages/rmf-dashboard-framework/src/components/doors/door-card.tsx
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
packages/rmf-dashboard-framework/src/components/doors/door-controls.tsx
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
packages/rmf-dashboard-framework/src/components/doors/door-summary.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { DoorState } from 'api-client'; | ||
import React, { act } from 'react'; | ||
import { Door as RmfDoor } from 'rmf-models/ros/rmf_building_map_msgs/msg'; | ||
import { DoorMode as RmfDoorMode } from 'rmf-models/ros/rmf_door_msgs/msg'; | ||
import { describe, expect, it, vi } from 'vitest'; | ||
|
||
import { RmfApiProvider } from '../../hooks'; | ||
import { MockRmfApi, render, TestProviders } from '../../utils/test-utils.test'; | ||
import { DoorSummary } from './door-summary'; | ||
import { makeDoor } from './test-utils.test'; | ||
|
||
describe('DoorSummary', () => { | ||
const mockDoor: RmfDoor = makeDoor({ name: 'test_door' }); | ||
|
||
const rmfApi = new MockRmfApi(); | ||
const Base = (props: React.PropsWithChildren<{}>) => { | ||
return ( | ||
<TestProviders> | ||
<RmfApiProvider value={rmfApi}>{props.children}</RmfApiProvider> | ||
</TestProviders> | ||
); | ||
}; | ||
|
||
it('renders door summary correctly', async () => { | ||
const onCloseMock = vi.fn(); | ||
const root = render( | ||
<Base> | ||
<DoorSummary onClose={onCloseMock} door={mockDoor} doorLevelName="L1" /> | ||
</Base>, | ||
); | ||
|
||
// Create the subject for the door | ||
const doorStateObs = rmfApi.getDoorStateObs('test_door'); | ||
let emittedDoorState: DoorState | undefined; | ||
doorStateObs.subscribe((doorState) => { | ||
emittedDoorState = doorState; | ||
}); | ||
|
||
const mockDoorState: DoorState = { | ||
door_time: { sec: 0, nanosec: 0 }, | ||
door_name: 'test_door', | ||
current_mode: { value: RmfDoorMode.MODE_OPEN }, | ||
}; | ||
act(() => { | ||
rmfApi.doorStateObsStore['test_door'].next(mockDoorState); | ||
}); | ||
|
||
expect(emittedDoorState).toEqual(mockDoorState); | ||
expect(emittedDoorState?.current_mode.value).toEqual(RmfDoorMode.MODE_OPEN); | ||
|
||
expect(root.getByText('Name')).toBeTruthy(); | ||
expect(root.getByText('Current Floor')).toBeTruthy(); | ||
expect(root.getByText('Type')).toBeTruthy(); | ||
expect(root.getByText('State')).toBeTruthy(); | ||
|
||
expect(root.getByText('test_door')).toBeTruthy(); | ||
expect(root.getByText('L1')).toBeTruthy(); | ||
expect(root.getByText('Single Swing')).toBeTruthy(); | ||
expect(root.getByText('OPEN')).toBeTruthy(); | ||
|
||
userEvent.keyboard('{Escape}'); | ||
await waitFor(() => expect(onCloseMock).toHaveBeenCalledTimes(1)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...-framework/src/components/doors/index.tsx → ...d-framework/src/components/doors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export * from './door-card'; | ||
export * from './door-summary'; | ||
export * from './doors-table'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters