diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload_test.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload_test.go index a674b594e10..059cfab5dd5 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload_test.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload_test.go @@ -7,28 +7,6 @@ import ( "github.com/transcom/mymove/pkg/models" ) -func (suite *PayloadsSuite) TestMarketCode() { - suite.Run("returns nil when marketCode is nil", func() { - var marketCode *models.MarketCode = nil - result := MarketCode(marketCode) - suite.Equal(result, "") - }) - - suite.Run("returns string when marketCode is not nil", func() { - marketCodeDomestic := models.MarketCodeDomestic - result := MarketCode(&marketCodeDomestic) - suite.NotNil(result, "Expected result to not be nil when marketCode is not nil") - suite.Equal("d", result, "Expected result to be 'd' for domestic market code") - }) - - suite.Run("returns string when marketCode is international", func() { - marketCodeInternational := models.MarketCodeInternational - result := MarketCode(&marketCodeInternational) - suite.NotNil(result, "Expected result to not be nil when marketCode is not nil") - suite.Equal("i", result, "Expected result to be 'i' for international market code") - }) -} - func (suite *PayloadsSuite) TestFetchPPMShipment() { ppmShipmentID, _ := uuid.NewV4() @@ -88,3 +66,25 @@ func (suite *PayloadsSuite) TestFetchPPMShipment() { suite.True(*returnedPPMShipment.IsActualExpenseReimbursement) }) } + +func (suite *PayloadsSuite) TestMarketCode() { + suite.Run("returns nil when marketCode is nil", func() { + var marketCode *models.MarketCode = nil + result := MarketCode(marketCode) + suite.Equal(result, "") + }) + + suite.Run("returns string when marketCode is not nil", func() { + marketCodeDomestic := models.MarketCodeDomestic + result := MarketCode(&marketCodeDomestic) + suite.NotNil(result, "Expected result to not be nil when marketCode is not nil") + suite.Equal("d", result, "Expected result to be 'd' for domestic market code") + }) + + suite.Run("returns string when marketCode is international", func() { + marketCodeInternational := models.MarketCodeInternational + result := MarketCode(&marketCodeInternational) + suite.NotNil(result, "Expected result to not be nil when marketCode is not nil") + suite.Equal("i", result, "Expected result to be 'i' for international market code") + }) +} diff --git a/pkg/handlers/internalapi/internal/payloads/payload_to_model_test.go b/pkg/handlers/internalapi/internal/payloads/payload_to_model_test.go index 3525286f218..0713e199cd2 100644 --- a/pkg/handlers/internalapi/internal/payloads/payload_to_model_test.go +++ b/pkg/handlers/internalapi/internal/payloads/payload_to_model_test.go @@ -9,6 +9,7 @@ import ( "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/unit" ) func (suite *PayloadsSuite) TestAddressModel() { @@ -328,3 +329,124 @@ func (suite *PayloadsSuite) TestPPMShipmentModelWithOptionalDestinationStreet1Fr model3 := UpdatePPMShipmentModel(&ppmShipmentValidDestAddress1) suite.Equal(model3.DestinationAddress.StreetAddress1, streetAddress1) } + +func (suite *PayloadsSuite) TestPPMShipmentModelFromUpdate() { + time := time.Now() + expectedDepartureDate := handlers.FmtDatePtr(&time) + estimatedWeight := int64(5000) + proGearWeight := int64(500) + spouseProGearWeight := int64(50) + + address := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "12345", + Country: &models.Country{Country: "US"}, + } + address2 := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "11111", + } + address3 := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "54321", + } + + var pickupAddress internalmessages.Address + var secondaryPickupAddress internalmessages.Address + var tertiaryPickupAddress internalmessages.Address + var destinationAddress internalmessages.PPMDestinationAddress + var secondaryDestinationAddress internalmessages.Address + var tertiaryDestinationAddress internalmessages.Address + + pickupAddress = internalmessages.Address{ + City: &address.City, + Country: &address.Country.Country, + PostalCode: &address.PostalCode, + State: &address.State, + StreetAddress1: &address.StreetAddress1, + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + } + destinationAddress = internalmessages.PPMDestinationAddress{ + City: &address.City, + Country: &address.Country.Country, + PostalCode: &address.PostalCode, + State: &address.State, + StreetAddress1: &address.StreetAddress1, + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + } + secondaryPickupAddress = internalmessages.Address{ + City: &address2.City, + Country: &address.Country.Country, + PostalCode: &address2.PostalCode, + State: &address2.State, + StreetAddress1: &address2.StreetAddress1, + StreetAddress2: address2.StreetAddress2, + StreetAddress3: address2.StreetAddress3, + } + secondaryDestinationAddress = internalmessages.Address{ + City: &address2.City, + Country: &address.Country.Country, + PostalCode: &address2.PostalCode, + State: &address2.State, + StreetAddress1: &address2.StreetAddress1, + StreetAddress2: address2.StreetAddress2, + StreetAddress3: address2.StreetAddress3, + } + tertiaryPickupAddress = internalmessages.Address{ + City: &address3.City, + Country: &address.Country.Country, + PostalCode: &address3.PostalCode, + State: &address3.State, + StreetAddress1: &address3.StreetAddress1, + StreetAddress2: address3.StreetAddress2, + StreetAddress3: address3.StreetAddress3, + } + tertiaryDestinationAddress = internalmessages.Address{ + City: &address3.City, + Country: &address.Country.Country, + PostalCode: &address3.PostalCode, + State: &address3.State, + StreetAddress1: &address3.StreetAddress1, + StreetAddress2: address3.StreetAddress2, + StreetAddress3: address3.StreetAddress3, + } + + ppmShipment := internalmessages.UpdatePPMShipment{ + ExpectedDepartureDate: expectedDepartureDate, + PickupAddress: &pickupAddress, + SecondaryPickupAddress: &secondaryPickupAddress, + TertiaryPickupAddress: &tertiaryPickupAddress, + DestinationAddress: &destinationAddress, + SecondaryDestinationAddress: &secondaryDestinationAddress, + TertiaryDestinationAddress: &tertiaryDestinationAddress, + SitExpected: models.BoolPointer(true), + EstimatedWeight: &estimatedWeight, + HasProGear: models.BoolPointer(true), + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), + } + + model := UpdatePPMShipmentModel(&ppmShipment) + + suite.NotNil(model) + suite.True(*model.SITExpected) + suite.Equal(unit.Pound(estimatedWeight), *model.EstimatedWeight) + suite.True(*model.HasProGear) + suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) + suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.Nil(model.HasSecondaryPickupAddress) + suite.Nil(model.HasSecondaryDestinationAddress) + suite.Nil(model.HasTertiaryPickupAddress) + suite.Nil(model.HasTertiaryDestinationAddress) + suite.True(*model.IsActualExpenseReimbursement) + suite.NotNil(model) +} diff --git a/pkg/handlers/primeapi/payloads/payload_to_model_test.go b/pkg/handlers/primeapi/payloads/payload_to_model_test.go index fe4e4b9b649..c7beddad167 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model_test.go @@ -501,12 +501,13 @@ func (suite *PayloadsSuite) TestPPMShipmentModelFromCreate() { spouseProGearWeight := int64(50) ppmShipment := primemessages.CreatePPMShipment{ - ExpectedDepartureDate: expectedDepartureDate, - SitExpected: &sitExpected, - EstimatedWeight: &estimatedWeight, - HasProGear: &hasProGear, - ProGearWeight: &proGearWeight, - SpouseProGearWeight: &spouseProGearWeight, + ExpectedDepartureDate: expectedDepartureDate, + SitExpected: &sitExpected, + EstimatedWeight: &estimatedWeight, + HasProGear: &hasProGear, + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), } model := PPMShipmentModelFromCreate(&ppmShipment) @@ -518,6 +519,36 @@ func (suite *PayloadsSuite) TestPPMShipmentModelFromCreate() { suite.True(*model.HasProGear) suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.True(*model.IsActualExpenseReimbursement) +} + +func (suite *PayloadsSuite) TestPPMShipmentModelFromUpdate() { + time := time.Now() + expectedDepartureDate := handlers.FmtDatePtr(&time) + estimatedWeight := int64(5000) + proGearWeight := int64(500) + spouseProGearWeight := int64(50) + + ppmShipment := primemessages.UpdatePPMShipment{ + ExpectedDepartureDate: expectedDepartureDate, + SitExpected: models.BoolPointer(true), + EstimatedWeight: &estimatedWeight, + HasProGear: models.BoolPointer(true), + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), + } + + model := PPMShipmentModelFromUpdate(&ppmShipment) + + suite.NotNil(model) + suite.True(*model.SITExpected) + suite.Equal(unit.Pound(estimatedWeight), *model.EstimatedWeight) + suite.True(*model.HasProGear) + suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) + suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.True(*model.IsActualExpenseReimbursement) + suite.NotNil(model) } func (suite *PayloadsSuite) TestCountryModel_WithValidCountry() { diff --git a/pkg/handlers/primeapiv2/payloads/payload_to_model_test.go b/pkg/handlers/primeapiv2/payloads/payload_to_model_test.go index e50f6428cbf..9b3187d947c 100644 --- a/pkg/handlers/primeapiv2/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapiv2/payloads/payload_to_model_test.go @@ -469,12 +469,13 @@ func (suite *PayloadsSuite) TestPPMShipmentModelFromCreate() { spouseProGearWeight := int64(50) ppmShipment := primev2messages.CreatePPMShipment{ - ExpectedDepartureDate: expectedDepartureDate, - SitExpected: &sitExpected, - EstimatedWeight: &estimatedWeight, - HasProGear: &hasProGear, - ProGearWeight: &proGearWeight, - SpouseProGearWeight: &spouseProGearWeight, + ExpectedDepartureDate: expectedDepartureDate, + SitExpected: &sitExpected, + EstimatedWeight: &estimatedWeight, + HasProGear: &hasProGear, + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), } model := PPMShipmentModelFromCreate(&ppmShipment) @@ -486,6 +487,36 @@ func (suite *PayloadsSuite) TestPPMShipmentModelFromCreate() { suite.True(*model.HasProGear) suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.True(*model.IsActualExpenseReimbursement) +} + +func (suite *PayloadsSuite) TestPPMShipmentModelFromUpdate() { + time := time.Now() + expectedDepartureDate := handlers.FmtDatePtr(&time) + estimatedWeight := int64(5000) + proGearWeight := int64(500) + spouseProGearWeight := int64(50) + + ppmShipment := primev2messages.UpdatePPMShipment{ + ExpectedDepartureDate: expectedDepartureDate, + SitExpected: models.BoolPointer(true), + EstimatedWeight: &estimatedWeight, + HasProGear: models.BoolPointer(true), + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), + } + + model := PPMShipmentModelFromUpdate(&ppmShipment) + + suite.NotNil(model) + suite.True(*model.SITExpected) + suite.Equal(unit.Pound(estimatedWeight), *model.EstimatedWeight) + suite.True(*model.HasProGear) + suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) + suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.True(*model.IsActualExpenseReimbursement) + suite.NotNil(model) } func (suite *PayloadsSuite) TestCountryModel_WithValidCountry() { diff --git a/pkg/handlers/primeapiv3/payloads/payload_to_model_test.go b/pkg/handlers/primeapiv3/payloads/payload_to_model_test.go index 831d260414f..f3c464d44a6 100644 --- a/pkg/handlers/primeapiv3/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapiv3/payloads/payload_to_model_test.go @@ -655,6 +655,136 @@ func (suite *PayloadsSuite) TestPPMShipmentModelFromCreate() { suite.NotNil(model) } +func (suite *PayloadsSuite) TestPPMShipmentModelFromUpdate() { + time := time.Now() + expectedDepartureDate := handlers.FmtDatePtr(&time) + estimatedWeight := int64(5000) + proGearWeight := int64(500) + spouseProGearWeight := int64(50) + + country := models.Country{ + Country: "US", + CountryName: "United States", + } + + address := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "12345", + Country: &country, + } + address2 := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "11111", + Country: &country, + } + address3 := models.Address{ + StreetAddress1: "some address", + City: "city", + State: "state", + PostalCode: "54321", + Country: &country, + } + + var pickupAddress primev3messages.Address + var secondaryPickupAddress primev3messages.Address + var tertiaryPickupAddress primev3messages.Address + var destinationAddress primev3messages.PPMDestinationAddress + var secondaryDestinationAddress primev3messages.Address + var tertiaryDestinationAddress primev3messages.Address + + pickupAddress = primev3messages.Address{ + City: &address.City, + Country: &address.Country.Country, + PostalCode: &address.PostalCode, + State: &address.State, + StreetAddress1: &address.StreetAddress1, + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + } + destinationAddress = primev3messages.PPMDestinationAddress{ + City: &address.City, + Country: &address.Country.Country, + PostalCode: &address.PostalCode, + State: &address.State, + StreetAddress1: &address.StreetAddress1, + StreetAddress2: address.StreetAddress2, + StreetAddress3: address.StreetAddress3, + } + secondaryPickupAddress = primev3messages.Address{ + City: &address2.City, + Country: &address2.Country.Country, + PostalCode: &address2.PostalCode, + State: &address2.State, + StreetAddress1: &address2.StreetAddress1, + StreetAddress2: address2.StreetAddress2, + StreetAddress3: address2.StreetAddress3, + } + secondaryDestinationAddress = primev3messages.Address{ + City: &address2.City, + Country: &address2.Country.Country, + PostalCode: &address2.PostalCode, + State: &address2.State, + StreetAddress1: &address2.StreetAddress1, + StreetAddress2: address2.StreetAddress2, + StreetAddress3: address2.StreetAddress3, + } + tertiaryPickupAddress = primev3messages.Address{ + City: &address3.City, + Country: &address3.Country.Country, + PostalCode: &address3.PostalCode, + State: &address3.State, + StreetAddress1: &address3.StreetAddress1, + StreetAddress2: address3.StreetAddress2, + StreetAddress3: address3.StreetAddress3, + } + tertiaryDestinationAddress = primev3messages.Address{ + City: &address3.City, + Country: &address3.Country.Country, + PostalCode: &address3.PostalCode, + State: &address3.State, + StreetAddress1: &address3.StreetAddress1, + StreetAddress2: address3.StreetAddress2, + StreetAddress3: address3.StreetAddress3, + } + + ppmShipment := primev3messages.UpdatePPMShipment{ + ExpectedDepartureDate: expectedDepartureDate, + PickupAddress: struct{ primev3messages.Address }{pickupAddress}, + SecondaryPickupAddress: struct{ primev3messages.Address }{secondaryPickupAddress}, + TertiaryPickupAddress: struct{ primev3messages.Address }{tertiaryPickupAddress}, + DestinationAddress: struct { + primev3messages.PPMDestinationAddress + }{destinationAddress}, + SecondaryDestinationAddress: struct{ primev3messages.Address }{secondaryDestinationAddress}, + TertiaryDestinationAddress: struct{ primev3messages.Address }{tertiaryDestinationAddress}, + SitExpected: models.BoolPointer(true), + EstimatedWeight: &estimatedWeight, + HasProGear: models.BoolPointer(true), + ProGearWeight: &proGearWeight, + SpouseProGearWeight: &spouseProGearWeight, + IsActualExpenseReimbursement: models.BoolPointer(true), + } + + model := PPMShipmentModelFromUpdate(&ppmShipment) + + suite.NotNil(model) + suite.True(*model.SITExpected) + suite.Equal(unit.Pound(estimatedWeight), *model.EstimatedWeight) + suite.True(*model.HasProGear) + suite.Equal(unit.Pound(proGearWeight), *model.ProGearWeight) + suite.Equal(unit.Pound(spouseProGearWeight), *model.SpouseProGearWeight) + suite.Nil(model.HasSecondaryPickupAddress) + suite.Nil(model.HasSecondaryDestinationAddress) + suite.Nil(model.HasTertiaryPickupAddress) + suite.Nil(model.HasTertiaryDestinationAddress) + suite.True(*model.IsActualExpenseReimbursement) + suite.NotNil(model) +} + func (suite *PayloadsSuite) TestMobileHomeShipmentModelFromCreate() { make := "BrandA" model := "ModelX" diff --git a/playwright/tests/office/ppms/happyPathFlows.spec.js b/playwright/tests/office/ppms/happyPathFlows.spec.js index 010a1d8e4a4..8df004b255f 100644 --- a/playwright/tests/office/ppms/happyPathFlows.spec.js +++ b/playwright/tests/office/ppms/happyPathFlows.spec.js @@ -32,6 +32,7 @@ test.describe('Services counselor user', () => { // Update page 2 await ppmPage.fillOutIncentiveAndAdvance(); + await expect(page.locator('[data-testid="errorMessage"]')).toHaveCount(1); await expect(page.locator('[data-testid="errorMessage"]')).toContainText('Required'); await page.locator('[data-testid="counselor-remarks"]').fill('Increased incentive to max'); await page.locator('[data-testid="counselor-remarks"]').blur(); @@ -89,6 +90,7 @@ test.describe('Services counselor user', () => { // Fill out page two await ppmPage.fillOutIncentiveAndAdvance({ advance: '10000' }); + await expect(page.locator('[data-testid="errorMessage"]')).toHaveCount(1); await expect(page.locator('[data-testid="errorMessage"]')).toContainText('Required'); await page.locator('[data-testid="counselor-remarks"]').fill('Added correct incentive'); await page.locator('[data-testid="counselor-remarks"]').blur(); diff --git a/playwright/tests/office/ppms/ppmTestFixture.js b/playwright/tests/office/ppms/ppmTestFixture.js index f23467c32b4..9e36d49394d 100644 --- a/playwright/tests/office/ppms/ppmTestFixture.js +++ b/playwright/tests/office/ppms/ppmTestFixture.js @@ -120,6 +120,7 @@ export class PpmPage extends ServiceCounselorPage { await this.page.locator('label[for="hasRequestedAdvanceYes"]').click(); await this.page.locator('input[name="advance"]').clear(); await this.page.locator('input[name="advance"]').fill(advance); + await this.page.locator('input[name="advance"]').blur(); await this.page.locator('label[for="approveAdvanceRequest"]').click(); } else { await this.page.locator('label[for="hasRequestedAdvanceNo"]').click(); diff --git a/src/pages/MyMove/Profile/BackupAddress.test.jsx b/src/pages/MyMove/Profile/BackupAddress.test.jsx index 806997ee901..6a047ebe65f 100644 --- a/src/pages/MyMove/Profile/BackupAddress.test.jsx +++ b/src/pages/MyMove/Profile/BackupAddress.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render, waitFor, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { MockProviders } from 'testUtils'; diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx index bb9d4715501..0245f4ad114 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx @@ -522,7 +522,7 @@ describe('CreateCustomerForm', () => { it('submits the form and tests for unsupported state validation', async () => { createCustomerWithOktaOption.mockImplementation(() => Promise.resolve(fakeResponse)); - const { getByLabelText, getByTestId, getByRole, getByText } = render( + const { getByLabelText, getByTestId, getByRole } = render( , @@ -567,7 +567,7 @@ describe('CreateCustomerForm', () => { await userEvent.selectOptions(getByTestId('backup-add-state'), 'HI'); await userEvent.tab(); - const msg = getByText('Moves to this state are not supported at this time.'); + const msg = screen.getByText('Moves to this state are not supported at this time.'); expect(msg).toBeVisible(); await userEvent.selectOptions(getByTestId('backup-add-state'), [fakePayload.residential_address.state]);