Skip to content

Commit

Permalink
Merge branch 'integrationTesting' into B-21941-INT-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
traskowskycaci committed Jan 8, 2025
2 parents 0b061d0 + 7f0b037 commit 79670f6
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/services/mto_shipment/shipment_approver.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (f *shipmentApprover) ApproveShipment(appCtx appcontext.AppContext, shipmen
transactionError := appCtx.NewTransaction(func(txnAppCtx appcontext.AppContext) error {
// create international shipment service items before approving
// we use a database proc to create the basic auto-approved service items
if shipment.ShipmentType == models.MTOShipmentTypeHHG && shipment.MarketCode == models.MarketCodeInternational {
if (shipment.ShipmentType == models.MTOShipmentTypeHHG || shipment.ShipmentType == models.MTOShipmentTypeUnaccompaniedBaggage) && shipment.MarketCode == models.MarketCodeInternational {
err := models.CreateApprovedServiceItemsForShipment(appCtx.DB(), shipment)
if err != nil {
return err
Expand Down
180 changes: 180 additions & 0 deletions pkg/services/mto_shipment/shipment_approver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,4 +854,184 @@ func (suite *MTOShipmentServiceSuite) TestApproveShipment() {

suite.NotNil(shipment.MoveTaskOrder.ExcessWeightQualifiedAt)
})

suite.Run("If the CONUS to OCONUS UB mtoShipment is approved successfully it should create pre approved mtoServiceItems", func() {
internationalShipment := factory.BuildMTOShipment(suite.AppContextForTest().DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: models.Address{
StreetAddress1: "Tester Address",
City: "Des Moines",
State: "IA",
PostalCode: "50314",
IsOconus: models.BoolPointer(false),
},
Type: &factory.Addresses.PickupAddress,
},
{
Model: models.MTOShipment{
MarketCode: models.MarketCodeInternational,
Status: models.MTOShipmentStatusSubmitted,
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
},
},
{
Model: models.Address{
StreetAddress1: "JBER",
City: "Anchorage",
State: "AK",
PostalCode: "99505",
IsOconus: models.BoolPointer(true),
},
Type: &factory.Addresses.DeliveryAddress,
},
}, nil)

internationalShipmentEtag := etag.GenerateEtag(internationalShipment.UpdatedAt)
shipmentApprover := suite.createApproveShipmentSubtestData().shipmentApprover
_, err := shipmentApprover.ApproveShipment(suite.AppContextForTest(), internationalShipment.ID, internationalShipmentEtag)
suite.NoError(err)

// Get created pre approved service items
var serviceItems []models.MTOServiceItem
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
models.ReServiceCodePOEFSC,
}

suite.Equal(4, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
}
})

suite.Run("If the OCONUS to CONUS UB mtoShipment is approved successfully it should create pre approved mtoServiceItems", func() {
internationalShipment := factory.BuildMTOShipment(suite.AppContextForTest().DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: models.Address{
StreetAddress1: "JBER",
City: "Anchorage",
State: "AK",
PostalCode: "99505",
IsOconus: models.BoolPointer(true),
},
Type: &factory.Addresses.PickupAddress,
},
{
Model: models.MTOShipment{
MarketCode: models.MarketCodeInternational,
Status: models.MTOShipmentStatusSubmitted,
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
},
},
{
Model: models.Address{
StreetAddress1: "Tester Address",
City: "Des Moines",
State: "IA",
PostalCode: "50314",
IsOconus: models.BoolPointer(false),
},
Type: &factory.Addresses.DeliveryAddress,
},
}, nil)

internationalShipmentEtag := etag.GenerateEtag(internationalShipment.UpdatedAt)
shipmentApprover := suite.createApproveShipmentSubtestData().shipmentApprover
_, err := shipmentApprover.ApproveShipment(suite.AppContextForTest(), internationalShipment.ID, internationalShipmentEtag)
suite.NoError(err)

// Get created pre approved service items
var serviceItems []models.MTOServiceItem
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
models.ReServiceCodePODFSC,
}

suite.Equal(4, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
}
})

suite.Run("If the OCONUS to OCONUS UB mtoShipment is approved successfully it should create pre approved mtoServiceItems", func() {
internationalShipment := factory.BuildMTOShipment(suite.AppContextForTest().DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: models.Address{
StreetAddress1: "JBER",
City: "Anchorage",
State: "AK",
PostalCode: "99505",
IsOconus: models.BoolPointer(true),
},
Type: &factory.Addresses.PickupAddress,
},
{
Model: models.MTOShipment{
MarketCode: models.MarketCodeInternational,
Status: models.MTOShipmentStatusSubmitted,
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
},
},
{
Model: models.Address{
StreetAddress1: "Tester Address",
City: "Fairbanks",
State: "AK",
PostalCode: "99701",
IsOconus: models.BoolPointer(true),
},
Type: &factory.Addresses.DeliveryAddress,
},
}, nil)

internationalShipmentEtag := etag.GenerateEtag(internationalShipment.UpdatedAt)
shipmentApprover := suite.createApproveShipmentSubtestData().shipmentApprover
_, err := shipmentApprover.ApproveShipment(suite.AppContextForTest(), internationalShipment.ID, internationalShipmentEtag)
suite.NoError(err)

// Get created pre approved service items
var serviceItems []models.MTOServiceItem
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
}

suite.Equal(3, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
}
})

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ function filterPortFuelSurcharge(shipment, autoApprovedItems) {
const { destinationAddress, pickupAddress } = shipment;
let filteredPortFuelSurchargeList = autoApprovedItems;
if (pickupAddress.isOconus) {
filteredPortFuelSurchargeList = autoApprovedItems.filter((serviceItem) => {
filteredPortFuelSurchargeList = filteredPortFuelSurchargeList.filter((serviceItem) => {
return serviceItem.serviceCode !== SERVICE_ITEM_CODES.POEFSC;
});
}
if (destinationAddress.isOconus) {
filteredPortFuelSurchargeList = autoApprovedItems.filter((serviceItem) => {
filteredPortFuelSurchargeList = filteredPortFuelSurchargeList.filter((serviceItem) => {
return serviceItem.serviceCode !== SERVICE_ITEM_CODES.PODFSC;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ const intlUbOconusToConusShipment = {
destinationAddress,
};

const intlUbOconusToOconusShipment = {
shipmentType: SHIPMENT_OPTIONS.UNACCOMPANIED_BAGGAGE,
marketCode: MARKET_CODES.INTERNATIONAL,
pickupAddress: oconusPickupAddress,
destinationAddress: oconusDestinationAddress,
};

describe('Shipment Service Items Table', () => {
describe('renders the hhg longhaul shipment type with service items', () => {
it.each([
Expand Down Expand Up @@ -390,4 +397,17 @@ describe('Shipment Service Items Table', () => {
expect(screen.getByText(serviceItem)).toBeInTheDocument();
});
});

describe('renders the intl UB shipment type (OCONUS -> OCONUS) with service items', () => {
it.each([['International UB'], ['International UB pack'], ['International UB unpack']])(
'expects %s to be in the document',
async (serviceItem) => {
render(<ShipmentServiceItemsTable shipment={intlUbOconusToOconusShipment} />);
expect(
await screen.findByRole('heading', { name: 'Service items for this shipment 3 items', level: 4 }),
).toBeInTheDocument();
expect(screen.getByText(serviceItem)).toBeInTheDocument();
},
);
});
});

0 comments on commit 79670f6

Please sign in to comment.