Skip to content

Commit

Permalink
cleaned up robots/utils, test compose-clean
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Dec 6, 2024
1 parent 30a8f17 commit 8de1659
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 25 deletions.
24 changes: 0 additions & 24 deletions packages/rmf-dashboard-framework/src/components/robots/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ApiServerModelsRmfApiRobotStateStatus as Status2 } from 'api-client';
import { RobotMode as RmfRobotMode } from 'rmf-models/ros/rmf_fleet_msgs/msg';

/**
* Returns a uniquely identifiable string representing a robot.
Expand Down Expand Up @@ -28,26 +27,3 @@ export function robotStatusToUpperCase(status: Status2): string {
return `UNKNOWN (${status})`;
}
}

export function robotModeToString(robotMode: RmfRobotMode): string {
switch (robotMode.mode) {
case RmfRobotMode.MODE_CHARGING:
return 'Charging';
case RmfRobotMode.MODE_DOCKING:
return 'Docking';
case RmfRobotMode.MODE_EMERGENCY:
return 'Emergency';
case RmfRobotMode.MODE_GOING_HOME:
return 'Going Home';
case RmfRobotMode.MODE_IDLE:
return 'Idle';
case RmfRobotMode.MODE_MOVING:
return 'Moving';
case RmfRobotMode.MODE_PAUSED:
return 'Paused';
case RmfRobotMode.MODE_WAITING:
return 'Waiting';
default:
return `Unknown (${robotMode.mode})`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Meta, StoryObj } from '@storybook/react';

import { ComposeCleanTaskForm, makeDefaultComposeCleanTaskDescription } from './compose-clean';

export default {
title: 'Tasks/ComposeCleanTaskForm',
component: ComposeCleanTaskForm,
} satisfies Meta;

type Story = StoryObj<typeof ComposeCleanTaskForm>;

export const Default: Story = {
args: {
taskDesc: makeDefaultComposeCleanTaskDescription(),
cleaningZones: ['clean_zone_1', 'clean_zone_2'],
onChange: () => {},
onValidate: () => {},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';

import { ComposeCleanTaskForm, makeDefaultComposeCleanTaskDescription } from './compose-clean';

describe('Compose clean task form', () => {
it('Renders compose clean task form', async () => {
const onChange = vi.fn();
const onValidate = vi.fn();

render(
<ComposeCleanTaskForm
taskDesc={makeDefaultComposeCleanTaskDescription()}
cleaningZones={['test_clean_1', 'test_clean_2']}
onChange={onChange}
onValidate={onValidate}
/>,
);

expect(screen.getByText('Cleaning Zone')).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ export function ComposeCleanTaskForm({
taskDesc.phases[0].activity.description.activities[1].description.description.zone = zone;
onInputChange(taskDesc);
}}
renderInput={(params) => <TextField {...params} label="Cleaning Zone" required={true} />}
renderInput={(params) => (
<TextField
data-testid="cleaning-zone-input"
{...params}
label="Cleaning Zone"
required={true}
/>
)}
/>
);
}

0 comments on commit 8de1659

Please sign in to comment.