Skip to content

Commit

Permalink
Fix favorite task confirmation text field, add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Jul 2, 2024
1 parent 1229865 commit c1269f7
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react-components/lib/tasks/create-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ export function CreateTaskForm({
}
helperText="Required"
error={favoriteTaskTitleError}
fullWidth
/>
)}
{callToDeleteFavoriteTask && (
Expand Down
109 changes: 109 additions & 0 deletions packages/react-components/lib/tasks/types/delivery-custom.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,126 @@ import {
cartPickupPhaseInsertPickup,
cartCustomPickupPhaseInsertCartId,
cartCustomPickupPhaseInsertPickup,
CartPickupPhase,
DeliveryCustomTaskDescription,
deliveryPhaseInsertDropoff,
deliveryPhaseInsertOnCancel,
DeliveryPickupTaskDescription,
DeliveryWithCancellationPhase,
DoubleComposeDeliveryTaskDescription,
makeDefaultDeliveryCustomTaskDescription,
makeDefaultDeliveryPickupTaskDescription,
makeDefaultDoubleComposeDeliveryTaskDescription,
} from '.';

describe('Custom deliveries', () => {
it('cart pickup phase', () => {
let parsedPhase: CartPickupPhase | null = null;
try {
parsedPhase = JSON.parse(`{
"activity": {
"category": "sequence",
"description": {
"activities": [
{
"category": "go_to_place",
"description": "test_pickup_place"
},
{
"category": "perform_action",
"description": {
"unix_millis_action_duration_estimate": 60000,
"category": "delivery_pickup",
"description": {
"cart_id": "test_cart_id",
"pickup_lot": "test_pickup_lot"
}
}
}
]
}
}
}
`) as CartPickupPhase;
} catch (e) {
parsedPhase = null;
}
expect(parsedPhase).not.toEqual(null);

const defaultDesc = makeDefaultDeliveryPickupTaskDescription();
let pickupPhase = cartPickupPhaseInsertPickup(
defaultDesc.phases[0],
'test_pickup_place',
'test_pickup_lot',
);
pickupPhase = cartPickupPhaseInsertCartId(pickupPhase, 'test_cart_id');
expect(parsedPhase).toEqual(pickupPhase);
});

it('delivery with cancellation phase', () => {
let parsedPhase: DeliveryWithCancellationPhase | null = null;
try {
parsedPhase = JSON.parse(`{
"activity": {
"category": "sequence",
"description": {
"activities": [
{
"category": "go_to_place",
"description": "test_dropoff_place"
}
]
}
},
"on_cancel": [
{
"category": "sequence",
"description": [
{
"category": "go_to_place",
"description": {
"one_of": [
{
"waypoint": "test_waypoint_1"
},
{
"waypoint": "test_waypoint_2"
},
{
"waypoint": "test_waypoint_3"
}
],
"constraints": [
{
"category": "prefer_same_map",
"description": ""
}
]
}
},
{
"category": "perform_action",
"description": {
"unix_millis_action_duration_estimate": 60000,
"category": "delivery_dropoff",
"description": {}
}
}
]
}
]
}
`) as DeliveryWithCancellationPhase;
} catch (e) {
parsedPhase = null;
}
expect(parsedPhase).not.toEqual(null);

const defaultDesc = makeDefaultDeliveryPickupTaskDescription();
const deliveryPhase = deliveryPhaseInsertDropoff(defaultDesc.phases[1], 'test_dropoff_place');
expect(parsedPhase).toEqual(deliveryPhase);
});

it('delivery pickup', () => {
let deliveryPickupTaskDescription: DeliveryPickupTaskDescription | null = null;
try {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/lib/tasks/types/delivery-custom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ interface CartCustomPickupPhase {
};
}

interface CartPickupPhase {
export interface CartPickupPhase {
activity: {
category: string;
description: {
Expand Down Expand Up @@ -109,7 +109,7 @@ interface OnCancelDropoff {
];
}

interface DeliveryWithCancellationPhase {
export interface DeliveryWithCancellationPhase {
activity: {
category: string;
description: {
Expand Down

0 comments on commit c1269f7

Please sign in to comment.