;
-
- beforeEach(() => {
- mockAddMoreRows = jasmine.createSpy();
- root = render(
- ,
- );
- });
-
- afterEach(cleanup);
-
- it('formats dates correctly', async () => {
- const tableFirstDateElement = (await root.getAllByTestId('task-table-date'))[0];
- expect(tableFirstDateElement.innerHTML).toBe(format(timestamp, 'MMM dd yyy hh:mm aaa'));
- });
-
- it('shows the correct number of rows', () => {
- const allRows = root.container.querySelectorAll('.MuiDataGrid-row').length;
- expect(allRows).toBe(100);
- });
-
- it('shows the correct headers', () => {
- expect(screen.queryByText('Task ID')).toBeTruthy();
- expect(screen.queryByText('Fleet')).toBeTruthy();
- expect(screen.queryByText('Robot')).toBeTruthy();
- expect(screen.queryByText('Task Description')).toBeTruthy();
- expect(screen.queryByText('State')).toBeTruthy();
- expect(screen.queryByText('Time')).toBeTruthy();
- expect(screen.queryByText('Timestamp')).toBeTruthy();
- });
-
- it('executes the addMoreRows function', () => {
- const nextPageButton = screen.queryByTitle('Go to next page');
- nextPageButton && fireEvent.click(nextPageButton);
- expect(mockAddMoreRows).toHaveBeenCalled();
- });
-});
diff --git a/packages/react-components/lib/reports/task-summary/task-summary-report-table.tsx b/packages/react-components/lib/reports/task-summary/task-summary-report-table.tsx
deleted file mode 100644
index bd64e9316..000000000
--- a/packages/react-components/lib/reports/task-summary/task-summary-report-table.tsx
+++ /dev/null
@@ -1,126 +0,0 @@
-import React from 'react';
-import { DataGrid, GridRenderCellParams } from '@mui/x-data-grid';
-import type { Time } from 'api-client';
-import { format } from 'date-fns';
-import { Typography } from '@mui/material';
-import { rosTimeToJs } from '../../utils';
-import { DefaultLogTableProps } from '../default-report-interface';
-import { returnTaskDetails } from './utils';
-
-export type TaskSummaryRowsType = {
- created: string; //date
- fleet: { id: number; name: string };
- robot: { id: number; name: string; model?: string };
- task_id: string;
- task_profile: unknown;
- state: string;
- status: string;
- submission_time: Time;
- start_time: Time;
- end_time: Time;
-}[];
-
-export interface TaskSummaryReportTable extends DefaultLogTableProps {
- rows: TaskSummaryRowsType | [];
-}
-
-export const TaskSummaryReportTable = (props: TaskSummaryReportTable): React.ReactElement => {
- const { rows, addMoreRows } = props;
-
- return (
-
- r.task_id}
- columns={[
- {
- headerName: 'Task ID',
- field: 'task_id',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.task_id};
- },
- },
- {
- headerName: 'Fleet',
- field: 'fleet_name',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.fleet.name};
- },
- },
- {
- headerName: 'Robot',
- field: 'robot_name',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.robot.name};
- },
- },
- {
- headerName: 'Task Description',
- field: 'description',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- const taskTypeDetails = returnTaskDetails(
- rowData.row.task_id,
- rowData.row.task_profile.description,
- );
- return taskTypeDetails;
- },
- },
- {
- headerName: 'State',
- field: 'state',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.state};
- },
- },
- {
- headerName: 'Time',
- field: 'time_information',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- const submissionTime = rosTimeToJs(
- rowData.row.task_profile.submission_time,
- ).toLocaleTimeString();
- const startTime = rosTimeToJs(rowData.row.start_time).toLocaleTimeString();
- const endTime = rosTimeToJs(rowData.row.end_time).toLocaleTimeString();
- return (
- <>
- Submitted: {submissionTime}
- Start: {startTime}
- End: {endTime}
- >
- );
- },
- },
- {
- headerName: 'Timestamp',
- field: 'created',
- type: 'datetime',
- filterable: false,
- align: 'center',
- renderCell: (rowData: GridRenderCellParams) => {
- return (
-
- {format(new Date(rowData.value as number), 'MMM dd yyyy hh:mm aaa')}
-
- );
- },
- },
- ]}
- rows={rows}
- pageSize={100}
- rowsPerPageOptions={[50, 100]}
- onPageChange={() => {
- if (addMoreRows) {
- addMoreRows();
- }
- }}
- disableColumnMenu={true}
- />
-
- );
-};
diff --git a/packages/react-components/lib/reports/task-summary/task-summary-report.spec.tsx b/packages/react-components/lib/reports/task-summary/task-summary-report.spec.tsx
deleted file mode 100644
index 60ce106e7..000000000
--- a/packages/react-components/lib/reports/task-summary/task-summary-report.spec.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { render, screen, waitFor, fireEvent } from '@testing-library/react';
-import React from 'react';
-import { TestLocalizationProvider } from '../../test/locale';
-import { getTaskSummaryLogs, reportConfigProps } from '../utils.spec';
-import { TaskSummaryReport } from './task-summary-report';
-
-const getLogsPromise = async () => getTaskSummaryLogs();
-
-it('smoke test', async () => {
- await waitFor(() => {
- render();
- });
-});
-
-it('does not show the table when the logs list is empty', async () => {
- await waitFor(() => {
- render( []} />);
- });
-
- expect(screen.queryByText('Task Summary')).toBeFalsy();
-});
-
-it('calls the Retrieve Logs function when the button is clicked', async () => {
- const getLogsPromiseMock = jasmine.createSpy();
- const getLogsPromise = async () => {
- getLogsPromiseMock();
- return getTaskSummaryLogs();
- };
-
- render(, {
- wrapper: TestLocalizationProvider,
- });
- const retrieveLogsButton = screen.getByRole('button', { name: /Retrieve Logs/i });
- expect(retrieveLogsButton).toBeTruthy();
- fireEvent.click(retrieveLogsButton);
- expect(getLogsPromiseMock).toHaveBeenCalled();
-});
diff --git a/packages/react-components/lib/reports/task-summary/task-summary-report.tsx b/packages/react-components/lib/reports/task-summary/task-summary-report.tsx
deleted file mode 100644
index f7d0c2835..000000000
--- a/packages/react-components/lib/reports/task-summary/task-summary-report.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from 'react';
-import {
- DefaultReportQueryPayload,
- defaultReportClasses,
- DefaultReportContainer,
-} from '../default-report-interface';
-import { DefaultDatesForm } from '../default-dates-form';
-import { TaskSummaryReportTable, TaskSummaryRowsType } from './task-summary-report-table';
-import { ReportConfigProps } from '../utils';
-
-export interface TaskSummaryReportProps extends ReportConfigProps {
- getLogs: (data: DefaultReportQueryPayload) => Promise;
-}
-
-export const TaskSummaryReport = (props: TaskSummaryReportProps): React.ReactElement => {
- const { getLogs, ...otherProps } = props;
- const [logs, setLogs] = React.useState([]);
- const [lastSearchParams, setLastSearchParams] = React.useState({});
-
- const searchLogs = async (payload: DefaultReportQueryPayload) => {
- setLastSearchParams(payload);
- setLogs(await getLogs(payload));
- };
-
- const getMoreLogs = async () => {
- setLogs(logs.concat(await getLogs({ ...lastSearchParams, offset: logs.length })));
- };
-
- return (
-
-
-
- {logs.length !== 0 && (
-
- )}
-
-
- );
-};
-
-export default TaskSummaryReport;
diff --git a/packages/react-components/lib/reports/task-summary/utils.tsx b/packages/react-components/lib/reports/task-summary/utils.tsx
deleted file mode 100644
index 2d0bb4851..000000000
--- a/packages/react-components/lib/reports/task-summary/utils.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Typography } from '@mui/material';
-// import type { TaskDescription } from 'api-client';
-import React from 'react';
-
-// FIXME: no `any`
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
-export const returnTaskDetails = (taskId: string, taskDescription: any): React.ReactNode => {
- let taskTypeDetails;
- if (taskId.includes('Loop')) {
- taskTypeDetails = taskDescription.loop;
- return (
- <>
- Num of Loops: {taskTypeDetails.num_loops}
- Start Point: {taskTypeDetails.start_name}
- End Point: {taskTypeDetails.finish_name}
- >
- );
- } else if (taskId.includes('Delivery')) {
- taskTypeDetails = taskDescription.delivery;
- return (
- <>
- Pick Up: {taskTypeDetails.pickup_place_name}
- Drop Off: {taskTypeDetails.dropoff_place_name}
- End Point: {taskTypeDetails.items}
- >
- );
- } else if (taskId.includes('Clean')) {
- taskTypeDetails = taskDescription.clean;
- return (
- <>
- Start Point: {taskTypeDetails.start_waypoint}
- >
- );
- }
-};
diff --git a/packages/react-components/lib/reports/user-report/index.ts b/packages/react-components/lib/reports/user-report/index.ts
deleted file mode 100644
index 9c04239c0..000000000
--- a/packages/react-components/lib/reports/user-report/index.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from './user-login-failure-report-table';
-export * from './user-login-failure-report';
-export * from './user-login-report';
-export * from './user-login-report-table';
-export * from './user-logout-report';
-export * from './user-logout-report-table';
diff --git a/packages/react-components/lib/reports/user-report/user-login-failure-report-table.tsx b/packages/react-components/lib/reports/user-report/user-login-failure-report-table.tsx
deleted file mode 100644
index c8198dfb9..000000000
--- a/packages/react-components/lib/reports/user-report/user-login-failure-report-table.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import React from 'react';
-import { DataGrid, GridRenderCellParams } from '@mui/x-data-grid';
-import { Typography } from '@mui/material';
-import { DefaultLogTableProps } from '../default-report-interface';
-import { format } from 'date-fns';
-
-export type UserLoginFailureRowsType = {
- created: string; //date
- ip_address: string;
- client_id: string;
- username: string;
- error: string;
-}[];
-
-export interface UserLoginFailureReportTable extends DefaultLogTableProps {
- rows: UserLoginFailureRowsType;
-}
-
-export const UserLoginFailureReportTable = (
- props: UserLoginFailureReportTable,
-): React.ReactElement => {
- const { rows, addMoreRows } = props;
-
- return (
-
- r.client_id}
- columns={[
- {
- headerName: 'Username',
- field: 'username',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.username};
- },
- },
-
- {
- headerName: 'Client ID',
- field: 'client_id',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.client_id};
- },
- },
- {
- headerName: 'IP Addr.',
- field: 'ip_address',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.ip_address};
- },
- },
-
- {
- headerName: 'Timestamp',
- field: 'created',
- type: 'datetime',
- filterable: false,
- align: 'center',
- renderCell: (rowData: GridRenderCellParams) => {
- return (
-
- {format(new Date(rowData.value as number), 'MMM dd yyyy hh:mm aaa')}
-
- );
- },
- },
- ]}
- rows={rows}
- pageSize={100}
- rowsPerPageOptions={[50, 100]}
- onPageChange={() => {
- if (addMoreRows) {
- addMoreRows();
- }
- }}
- disableColumnMenu={true}
- />
-
- );
-};
diff --git a/packages/react-components/lib/reports/user-report/user-login-failure-report.tsx b/packages/react-components/lib/reports/user-report/user-login-failure-report.tsx
deleted file mode 100644
index d40ee77af..000000000
--- a/packages/react-components/lib/reports/user-report/user-login-failure-report.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import React from 'react';
-import {
- DefaultReportQueryPayload,
- DefaultReportContainer,
- defaultReportClasses,
-} from '../default-report-interface';
-import { DefaultDatesForm } from '../default-dates-form';
-import {
- UserLoginFailureReportTable,
- UserLoginFailureRowsType,
-} from './user-login-failure-report-table';
-import { ReportConfigProps } from '../utils';
-
-export interface UserLoginFailureReportProps extends ReportConfigProps {
- getLogs: (data: DefaultReportQueryPayload) => Promise;
-}
-
-export const UserLoginFailureReport = (props: UserLoginFailureReportProps): React.ReactElement => {
- const { getLogs, ...otherProps } = props;
- const [logs, setLogs] = React.useState([]);
- const [lastSearchParams, setLastSearchParams] = React.useState({});
-
- const searchLogs = async (payload: DefaultReportQueryPayload) => {
- setLastSearchParams(payload);
- setLogs(await getLogs(payload));
- };
-
- const getMoreLogs = async () => {
- setLogs(logs.concat(await getLogs({ ...lastSearchParams, offset: logs.length })));
- };
-
- return (
-
-
-
- {logs.length !== 0 && (
-
- )}
-
-
- );
-};
-
-export default UserLoginFailureReport;
diff --git a/packages/react-components/lib/reports/user-report/user-login-report-table.tsx b/packages/react-components/lib/reports/user-report/user-login-report-table.tsx
deleted file mode 100644
index b1a95ba53..000000000
--- a/packages/react-components/lib/reports/user-report/user-login-report-table.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import React from 'react';
-import { DataGrid, GridRenderCellParams } from '@mui/x-data-grid';
-import { Typography } from '@mui/material';
-import { DefaultLogTableProps } from '../default-report-interface';
-import { format } from 'date-fns';
-
-export type UserLoginRowsType = {
- client_id: string;
- created: string; //date
- ip_address: string;
- user_id: string;
- username: string;
-}[];
-
-export interface UserLoginReportTable extends DefaultLogTableProps {
- rows: UserLoginRowsType;
-}
-
-export const UserLoginReportTable = (props: UserLoginReportTable): React.ReactElement => {
- const { rows, addMoreRows } = props;
-
- return (
-
- r.client_id}
- columns={[
- {
- headerName: 'Username',
- field: 'username',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.username};
- },
- },
- {
- headerName: 'Timestamp',
- field: 'created',
- type: 'datetime',
- filterable: false,
- align: 'center',
- renderCell: (rowData: GridRenderCellParams) => {
- return (
-
- {format(new Date(rowData.value as number), 'MMM dd yyyy hh:mm aaa')}
-
- );
- },
- },
- {
- headerName: 'Client ID',
- field: 'client_id',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.client_id};
- },
- },
- {
- headerName: 'User ID',
- field: 'user_id',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.user_id};
- },
- },
- {
- headerName: 'IP Addr',
- field: 'ip_address',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.ip_address};
- },
- },
- ]}
- rows={rows}
- pageSize={100}
- rowsPerPageOptions={[50, 100]}
- onPageChange={() => {
- if (addMoreRows) {
- addMoreRows();
- }
- }}
- disableColumnMenu={true}
- />
-
- );
-};
diff --git a/packages/react-components/lib/reports/user-report/user-login-report.tsx b/packages/react-components/lib/reports/user-report/user-login-report.tsx
deleted file mode 100644
index 630fa09dc..000000000
--- a/packages/react-components/lib/reports/user-report/user-login-report.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from 'react';
-import {
- DefaultReportQueryPayload,
- defaultReportClasses,
- DefaultReportContainer,
-} from '../default-report-interface';
-import { DefaultDatesForm } from '../default-dates-form';
-import { UserLoginReportTable, UserLoginRowsType } from './user-login-report-table';
-
-import { ReportConfigProps } from '../utils';
-export interface UserLoginReportProps extends ReportConfigProps {
- getLogs: (data: DefaultReportQueryPayload) => Promise;
-}
-
-export const UserLoginReport = (props: UserLoginReportProps): React.ReactElement => {
- const { getLogs, ...otherProps } = props;
- const [logs, setLogs] = React.useState([]);
- const [lastSearchParams, setLastSearchParams] = React.useState({});
-
- const searchLogs = async (payload: DefaultReportQueryPayload) => {
- setLastSearchParams(payload);
- setLogs(await getLogs(payload));
- };
-
- const getMoreLogs = async () => {
- setLogs(logs.concat(await getLogs({ ...lastSearchParams, offset: logs.length })));
- };
-
- return (
-
-
-
- {logs.length !== 0 && (
-
- )}
-
-
- );
-};
-
-export default UserLoginReport;
diff --git a/packages/react-components/lib/reports/user-report/user-logout-report-table.tsx b/packages/react-components/lib/reports/user-report/user-logout-report-table.tsx
deleted file mode 100644
index cc96e062f..000000000
--- a/packages/react-components/lib/reports/user-report/user-logout-report-table.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import React from 'react';
-import { DataGrid, GridRenderCellParams } from '@mui/x-data-grid';
-import { Typography } from '@mui/material';
-import { DefaultLogTableProps } from '../default-report-interface';
-import { format } from 'date-fns';
-
-export type UserLogoutRowsType = {
- created: string; //date
- ip_address: string;
- user_id: string;
- username: string;
-}[];
-
-export interface UserLogoutReportTable extends DefaultLogTableProps {
- rows: UserLogoutRowsType;
-}
-
-export const UserLogoutReportTable = (props: UserLogoutReportTable): React.ReactElement => {
- const { rows, addMoreRows } = props;
-
- return (
-
- r.user_id}
- columns={[
- {
- headerName: 'Username',
- field: 'username',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.username};
- },
- },
- {
- headerName: 'Timestamp',
- field: 'created',
- type: 'datetime',
- filterable: false,
- align: 'center',
- renderCell: (rowData: GridRenderCellParams) => {
- return (
-
- {format(new Date(rowData.value as number), 'MMM dd yyyy hh:mm aaa')}
-
- );
- },
- },
- {
- headerName: 'User ID',
- field: 'user_id',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.user_id};
- },
- },
- {
- headerName: 'IP Addr',
- field: 'ip_address',
- type: 'string',
- renderCell: (rowData: GridRenderCellParams) => {
- return {rowData.row.ip_address};
- },
- },
- ]}
- rows={rows}
- pageSize={100}
- rowsPerPageOptions={[50, 100]}
- onPageChange={() => {
- if (addMoreRows) {
- addMoreRows();
- }
- }}
- disableColumnMenu={true}
- />
-
- );
-};
diff --git a/packages/react-components/lib/reports/user-report/user-logout-report.tsx b/packages/react-components/lib/reports/user-report/user-logout-report.tsx
deleted file mode 100644
index 05198e7f9..000000000
--- a/packages/react-components/lib/reports/user-report/user-logout-report.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import React from 'react';
-import {
- DefaultReportQueryPayload,
- defaultReportClasses,
- DefaultReportContainer,
-} from '../default-report-interface';
-import { DefaultDatesForm } from '../default-dates-form';
-import { UserLogoutReportTable, UserLogoutRowsType } from './user-logout-report-table';
-import { ReportConfigProps } from '../utils';
-
-export interface UserLogoutReportProps extends ReportConfigProps {
- getLogs: (data: DefaultReportQueryPayload) => Promise;
-}
-
-export const UserLogoutReport = (props: UserLogoutReportProps): React.ReactElement => {
- const { getLogs, ...otherProps } = props;
- const [logs, setLogs] = React.useState([]);
- const [lastSearchParams, setLastSearchParams] = React.useState({});
-
- const searchLogs = async (payload: DefaultReportQueryPayload) => {
- setLastSearchParams(payload);
- setLogs(await getLogs(payload));
- };
-
- const getMoreLogs = async () => {
- setLogs(logs.concat(await getLogs({ ...lastSearchParams, offset: logs.length })));
- };
-
- return (
-
-
-
- {logs.length !== 0 && (
-
- )}
-
-
- );
-};
-
-export default UserLogoutReport;
diff --git a/packages/react-components/lib/reports/utils.spec.ts b/packages/react-components/lib/reports/utils.spec.ts
deleted file mode 100644
index d3ac72ada..000000000
--- a/packages/react-components/lib/reports/utils.spec.ts
+++ /dev/null
@@ -1,138 +0,0 @@
-import {
- DispenserStateRowsType,
- DoorStateRowsType,
- FleetStateRowsType,
- HealthRowsType,
- IngestorStateRowsType,
- LiftStateRowsType,
- TaskSummaryRowsType,
-} from '.';
-import { ReportConfigProps } from './utils';
-
-const timestamp = new Date('Mon Jan 1 00:00:02 UTC 2001').toISOString();
-
-export const getDispenserLogs = (): DispenserStateRowsType => {
- const rows = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- state: 'OPEN',
- guid: `dispenser_test_${i}`,
- created: timestamp,
- });
- }
- return rows;
-};
-
-export const getDoorLogs = (): DoorStateRowsType => {
- const rows = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- created: timestamp,
- state: 'OPEN',
- door: { id: i, name: 'door_test' },
- });
- }
- return rows;
-};
-
-export const getFleetLogs = (): FleetStateRowsType => {
- const rows: FleetStateRowsType = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- created: timestamp,
- fleet: { id: 1, name: 'fleet_test' },
- robot: { id: i, name: 'robot_test', model: 'model' },
- robot_battery_percent: 'test',
- robot_location: 'test',
- robot_mode: 'test',
- robot_seq: 1,
- robot_task_id: 'test',
- });
- }
- return rows as FleetStateRowsType;
-};
-
-export const getHealthLogs = (): HealthRowsType => {
- const rows = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- device: { id: i, type: 'door', actor: 'door-1' },
- health_status: 'DEAD',
- health_message: 'this is a message',
- created: timestamp,
- });
- }
- return rows;
-};
-
-export const getIngestorLogs = (): IngestorStateRowsType =>
- getDispenserLogs() as IngestorStateRowsType;
-
-export const getLiftLogs = (): LiftStateRowsType => {
- const rows = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- state: 'AVG',
- door_state: 'Closed',
- destination_floor: 'L1',
- motion_state: 'DOWN',
- current_floor: 'L2',
- session_id: 'session',
- created: timestamp,
- lift: { id: i, name: `lift_${i}` },
- });
- }
- return rows;
-};
-
-export const getTaskSummaryLogs = (): TaskSummaryRowsType => {
- const exampleData = {
- task_id: 'test',
- submission_time: { sec: 131, nanosec: 553000000 },
- description: {
- start_time: { sec: 1623383402, nanosec: 0 },
- priority: { value: 0 },
- task_type: { type: 1 },
- station: { task_id: '', robot_type: '', place_name: '' },
- loop: { task_id: '', robot_type: '', num_loops: 1, start_name: '', finish_name: '' },
- delivery: {
- task_id: '1',
- items: [],
- pickup_place_name: '',
- pickup_dispenser: '',
- pickup_behavior: { name: '', parameters: [] },
- dropoff_place_name: '',
- dropoff_ingestor: '',
- dropoff_behavior: { name: '', parameters: [] },
- },
- clean: { start_waypoint: '' },
- },
- };
- const rows = [];
- for (let i = 0; i < 200; i++) {
- rows.push({
- created: timestamp,
- fleet: { id: 1, name: 'fleet_test' },
- robot: { id: i, name: 'robot_test', model: 'model' },
- task_id: i.toString(),
- task_profile: exampleData,
- state: 'test',
- status: 'test',
- submission_time: { sec: 131, nanosec: 553000000 },
- start_time: { sec: 131, nanosec: 553000000 },
- end_time: { sec: 131, nanosec: 553000000 },
- });
- }
- return rows;
-};
-
-export const reportConfigProps: ReportConfigProps = {
- toLogDate: new Date(),
- fromLogDate: new Date(),
- onSelectFromDate: (/* date: Date */) => {
- /* no-op */
- },
- onSelectToDate: (/* date: Date */) => {
- /* no-op */
- },
-};
diff --git a/packages/react-components/lib/reports/utils.ts b/packages/react-components/lib/reports/utils.ts
deleted file mode 100644
index 1defe236c..000000000
--- a/packages/react-components/lib/reports/utils.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export interface ReportConfigProps {
- fromLogDate?: Date;
- toLogDate?: Date;
- onSelectFromDate?: (date: unknown) => void;
- onSelectToDate?: (date: unknown) => void;
-}
diff --git a/packages/react-components/lib/stack-navigator.spec.ts b/packages/react-components/lib/stack-navigator.spec.ts
index 705107ac1..1050be135 100644
--- a/packages/react-components/lib/stack-navigator.spec.ts
+++ b/packages/react-components/lib/stack-navigator.spec.ts
@@ -1,79 +1,57 @@
-import { renderHook, act } from '@testing-library/react';
-import { useStackNavigator } from '../lib';
+import { act, renderHook, RenderResult } from '@testing-library/react';
+import { StackNavigatorDispatch, useStackNavigator } from '../lib';
-describe('useStackNavigator', () => {
- it('should initialize with the correct initial state', () => {
- const initialState: number[] = [1, 2, 3];
- const homeView = 0;
+let hookResult: RenderResult<[number[], StackNavigatorDispatch]>;
+let stackDispatch: StackNavigatorDispatch;
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
+beforeEach(() => {
+ hookResult = renderHook(() => useStackNavigator([0], 0)).result;
+ stackDispatch = hookResult.current[1];
+});
- expect(result.current[0]).toEqual(initialState);
+describe('useStackNavigator', () => {
+ it('push', () => {
+ act(() => stackDispatch.push(10));
+ const stack = hookResult.current[0];
+ expect(stack).toHaveSize(2);
+ expect(stack[0]).toBe(0);
+ expect(stack[1]).toBe(10);
});
- it('should push a view onto the stack', () => {
- const initialState: number[] = [1, 2];
- const homeView = 0;
-
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
-
+ it('pop does not remove last item', () => {
act(() => {
- result.current[1].push(3);
+ stackDispatch.push(2);
+ stackDispatch.pop();
+ stackDispatch.pop();
});
-
- expect(result.current[0]).toEqual([1, 2, 3]);
+ const stack = hookResult.current[0];
+ expect(stack).toHaveSize(1);
+ expect(stack[0]).toBe(0);
});
- it('should pop a view from the stack', () => {
- const initialState: number[] = [1, 2, 3];
- const homeView = 0;
-
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
-
+ it('reset returns the stack to the initial state', () => {
act(() => {
- result.current[1].pop();
+ stackDispatch.push(2);
+ stackDispatch.push(3);
});
-
- expect(result.current[0]).toEqual([1, 2]);
- });
-
- it('should not remove the last view when popping', () => {
- const initialState: number[] = [1];
- const homeView = 0;
-
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
-
+ expect(hookResult.current[0]).toHaveSize(3);
act(() => {
- result.current[1].pop();
+ stackDispatch.reset();
});
-
- expect(result.current[0]).toEqual([1]);
+ expect(hookResult.current[0]).toHaveSize(1);
+ expect(hookResult.current[0][0]).toBe(0);
});
- it('should set the stack to the home view', () => {
- const initialState: number[] = [1, 2];
- const homeView = 0;
-
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
-
+ it('home pushes the home view onto the stack', () => {
act(() => {
- result.current[1].home();
+ stackDispatch.push(2);
+ stackDispatch.push(3);
});
-
- expect(result.current[0]).toEqual([1, 2, 0]);
- });
-
- it('should reset the stack to the initial state', () => {
- const initialState: number[] = [1, 2, 3];
- const homeView = 0;
-
- const { result } = renderHook(() => useStackNavigator(initialState, homeView));
-
+ expect(hookResult.current[0]).toHaveSize(3);
act(() => {
- result.current[1].push(4);
- result.current[1].reset();
+ stackDispatch.home();
});
-
- expect(result.current[0]).toEqual(initialState);
+ expect(hookResult.current[0]).toHaveSize(4);
+ expect(hookResult.current[0][3]).toBe(0);
});
});