From b5043fe12f03dcb3093181585d9703f572d3a063 Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Mon, 24 Oct 2022 17:47:34 -0400 Subject: [PATCH 01/50] create templates, update sql query, and add field maps --- .../sql_scripts/move_history_fetcher.sql | 21 +++++++++++++++++++ .../MoveHistory/Database/FieldMappings.js | 3 +++ src/constants/MoveHistory/Database/Tables.js | 1 + .../createServiceMemberBackupContact.jsx | 14 +++++++++++++ .../updateServiceMemberBackupContact.jsx | 14 +++++++++++++ .../MoveHistory/EventTemplates/index.js | 2 ++ .../MoveHistory/UIDisplay/Operations.js | 2 ++ 7 files changed, 57 insertions(+) create mode 100644 src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx diff --git a/pkg/services/query/sql_scripts/move_history_fetcher.sql b/pkg/services/query/sql_scripts/move_history_fetcher.sql index baf28a60fd7..f182c14ecbe 100644 --- a/pkg/services/query/sql_scripts/move_history_fetcher.sql +++ b/pkg/services/query/sql_scripts/move_history_fetcher.sql @@ -372,6 +372,21 @@ WITH move AS ( GROUP BY move_addresses.shipment_id, move_addresses.service_member_id, audit_history.id ), + move_backup_contacts AS ( + SELECT backup_contacts.* + FROM + backup_contacts + WHERE + backup_contacts.service_member_id = (SELECT id FROM move_service_members) + ), + backup_contacts_logs as ( + SELECT audit_history.*, + NULL AS context, + NULL AS context_id + FROM + audit_history + JOIN move_backup_contacts ON move_backup_contacts.id = audit_history.object_id + ), combined_logs AS ( SELECT * @@ -437,6 +452,12 @@ WITH move AS ( * FROM service_members_logs + UNION ALL + SELECT + * + FROM + backup_contacts_logs + ) SELECT DISTINCT combined_logs.*, diff --git a/src/constants/MoveHistory/Database/FieldMappings.js b/src/constants/MoveHistory/Database/FieldMappings.js index 7f859da3868..1efd3169bce 100644 --- a/src/constants/MoveHistory/Database/FieldMappings.js +++ b/src/constants/MoveHistory/Database/FieldMappings.js @@ -76,4 +76,7 @@ export default { residential_address: 'Current mailing address', backup_address: 'Backup mailing address', current_duty_location_name: 'Current duty location name', + name: 'Backup contact name', + email: 'Backup contact email', + phone: 'Backup contact phone', }; diff --git a/src/constants/MoveHistory/Database/Tables.js b/src/constants/MoveHistory/Database/Tables.js index 2c17e212a24..662e928e5c8 100644 --- a/src/constants/MoveHistory/Database/Tables.js +++ b/src/constants/MoveHistory/Database/Tables.js @@ -12,4 +12,5 @@ export default { mto_service_item_dimensions: 'mto_service_item_dimensions', mto_service_item_customer_contacts: 'mto_service_item_customer_contacts', service_members: 'service_members', + backup_contacts: 'backup_contacts', }; diff --git a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx new file mode 100644 index 00000000000..334ecb207dc --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; + +export default { + action: a.INSERT, + eventName: o.createServiceMemberBackupContact, + tableName: t.backup_contacts, + getEventNameDisplay: () => 'Updated profile', + getDetails: (historyRecord) => , +}; diff --git a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx new file mode 100644 index 00000000000..09f00580e50 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx @@ -0,0 +1,14 @@ +import React from 'react'; + +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; + +export default { + action: a.UPDATE, + eventName: o.updateServiceMemberBackupContact, + tableName: t.backup_contacts, + getEventNameDisplay: () => 'Updated profile', + getDetails: (historyRecord) => , +}; diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index 5d4411b5504..ab5558a668b 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -52,3 +52,5 @@ export { default as updateAllowanceServiceMemberByTOO } from './UpdateAllowances export { default as createServiceMember } from './CreateServiceMember/createServiceMember'; export { default as patchServiceMember } from './PatchServiceMember/patchServiceMember'; export { default as updateAddress } from './UpdateAddress/updateAddress'; +export { default as updateServiceMemberBackupContacts } from './UpdateServiceMemberBackupContact/updateServiceMemberBackupContact'; +export { default as createServiceMemberBackupContacts } from './CreateServiceMemberBackupContact/createServiceMemberBackupContact'; diff --git a/src/constants/MoveHistory/UIDisplay/Operations.js b/src/constants/MoveHistory/UIDisplay/Operations.js index f3c4a3d9ecf..6415ca92dc9 100644 --- a/src/constants/MoveHistory/UIDisplay/Operations.js +++ b/src/constants/MoveHistory/UIDisplay/Operations.js @@ -36,4 +36,6 @@ export default { uploadAmendedOrders: 'uploadAmendedOrders', // internal.yaml patchServiceMember: 'patchServiceMember', // internal.yaml createServiceMember: 'createServiceMember', // internal.yaml + createServiceMemberBackupContact: 'createServiceMemberBackupContact', // internal.yaml + updateServiceMemberBackupContact: 'updateServiceMemberBackupContact', // internal.yaml }; From e2e4c9208ed115b1308e50057bd78534e562ce21 Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Tue, 25 Oct 2022 16:06:32 -0400 Subject: [PATCH 02/50] Add test for the new templates --- .../createServiceMemberBackupContact.test.jsx | 38 +++++++++++++++++++ .../updateServiceMemberBackupContact.test.jsx | 38 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx diff --git a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx new file mode 100644 index 00000000000..ca4d48bfdbe --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx @@ -0,0 +1,38 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import t from 'constants/MoveHistory/Database/Tables'; +import createServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact'; + +const BACKUP_CONTACT = { + name: 'Tom Haverford', + email: 'tommyHavie@example.com', + phone: '555-555-5555', +}; + +describe('When a service members updates their profile', () => { + const template = { + action: 'INSERT', + eventName: o.createServiceMemberBackupContact, + tableName: t.backup_contacts, + eventNameDisplay: 'Updated profile', + }; + it('correctly matches the patch service member event template', () => { + const result = getTemplate(template); + expect(result).toMatchObject(createServiceMemberBackupContact); + }); + describe('it correctly renders the details component for an updated backup contact', () => { + it.each([ + ['Backup contact name', ': Tom Haverford'], + ['Backup contact email', ': tommyHavie@example.com'], + ['Backup contact phone', ': 555-555-5555'], + ])('displays the correct details value for %s', async (label, value) => { + const historyRecord = { changedValues: BACKUP_CONTACT }; + const result = getTemplate(template); + render(result.getDetails(historyRecord)); + expect(screen.getByText(label)).toBeInTheDocument(); + expect(screen.getByText(value)).toBeInTheDocument(); + }); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx new file mode 100644 index 00000000000..326a19fa4bd --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx @@ -0,0 +1,38 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import t from 'constants/MoveHistory/Database/Tables'; +import updateServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact'; + +const BACKUP_CONTACT = { + name: 'Ben Wyatt', + email: 'benwyatt@example.com', + phone: '555-555-2222', +}; + +describe('When a service members updates their profile', () => { + const template = { + action: 'UPDATE', + eventName: o.updateServiceMemberBackupContact, + tableName: t.backup_contacts, + eventNameDisplay: 'Updated profile', + }; + it('correctly matches the patch service member event template', () => { + const result = getTemplate(template); + expect(result).toMatchObject(updateServiceMemberBackupContact); + }); + describe('it correctly renders the details component for an updated backup contact', () => { + it.each([ + ['Backup contact name', ': Ben Wyatt'], + ['Backup contact email', ': benwyatt@example.com'], + ['Backup contact phone', ': 555-555-2222'], + ])('displays the correct details value for %s', async (label, value) => { + const historyRecord = { changedValues: BACKUP_CONTACT }; + const result = getTemplate(template); + render(result.getDetails(historyRecord)); + expect(screen.getByText(label)).toBeInTheDocument(); + expect(screen.getByText(value)).toBeInTheDocument(); + }); + }); +}); From 12644a21f7f820a306e41960f2c0bcd1b9d60bc1 Mon Sep 17 00:00:00 2001 From: Marjo Poindexter Date: Mon, 17 Oct 2022 19:57:03 +0000 Subject: [PATCH 03/50] convert dberr --- pkg/db/dberr/dberr_test.go | 8 ++++++-- pkg/db/dberr/errors_test.go | 15 +++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pkg/db/dberr/dberr_test.go b/pkg/db/dberr/dberr_test.go index fb1688ab4a4..e7466583b7a 100644 --- a/pkg/db/dberr/dberr_test.go +++ b/pkg/db/dberr/dberr_test.go @@ -9,9 +9,13 @@ import ( ) type DBErrSuite struct { - testingsuite.BaseTestSuite + *testingsuite.PopTestSuite } func TestDBFmtSuite(t *testing.T) { - suite.Run(t, new(DBErrSuite)) + ts := &DBErrSuite{ + PopTestSuite: testingsuite.NewPopTestSuite(testingsuite.CurrentPackage(), testingsuite.WithPerTestTransaction()), + } + suite.Run(t, ts) + ts.PopTestSuite.TearDown() } diff --git a/pkg/db/dberr/errors_test.go b/pkg/db/dberr/errors_test.go index cbb5ca27cf0..05521c80ecb 100644 --- a/pkg/db/dberr/errors_test.go +++ b/pkg/db/dberr/errors_test.go @@ -2,7 +2,6 @@ package dberr import ( "errors" - "testing" "github.com/jackc/pgerrcode" "github.com/lib/pq" @@ -14,16 +13,16 @@ func (suite *DBErrSuite) TestIsDBError() { Code: pq.ErrorCode(errCode), } - suite.T().Run("db error and code match", func(t *testing.T) { + suite.Run("db error and code match", func() { suite.True(IsDBError(&dbErr, errCode)) }) - suite.T().Run("not a db error", func(t *testing.T) { + suite.Run("not a db error", func() { err := errors.New("some random error") suite.False(IsDBError(err, errCode)) }) - suite.T().Run("not the right db error code", func(t *testing.T) { + suite.Run("not the right db error code", func() { suite.False(IsDBError(&dbErr, pgerrcode.UniqueViolation)) }) } @@ -36,20 +35,20 @@ func (suite *DBErrSuite) TestIsDBErrorForConstraint() { Constraint: constraintName, } - suite.T().Run("db error, code, and constraint match", func(t *testing.T) { + suite.Run("db error, code, and constraint match", func() { suite.True(IsDBErrorForConstraint(&dbErr, errCode, constraintName)) }) - suite.T().Run("not a db error", func(t *testing.T) { + suite.Run("not a db error", func() { err := errors.New("some random error") suite.False(IsDBErrorForConstraint(err, errCode, constraintName)) }) - suite.T().Run("not the right db error code", func(t *testing.T) { + suite.Run("not the right db error code", func() { suite.False(IsDBErrorForConstraint(&dbErr, pgerrcode.InternalError, constraintName)) }) - suite.T().Run("not the right constraint name", func(t *testing.T) { + suite.Run("not the right constraint name", func() { suite.False(IsDBErrorForConstraint(&dbErr, errCode, "bogus")) }) } From 48ccc3cf8870065040639bab3097c5769fd13601 Mon Sep 17 00:00:00 2001 From: Marjo Poindexter Date: Mon, 17 Oct 2022 20:20:19 +0000 Subject: [PATCH 04/50] convert dates --- pkg/dates/calculators_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/dates/calculators_test.go b/pkg/dates/calculators_test.go index 539bcfc2afc..4af44230ad0 100644 --- a/pkg/dates/calculators_test.go +++ b/pkg/dates/calculators_test.go @@ -49,7 +49,7 @@ func (suite *DatesSuite) TestCreateFutureMoveDates() { }, } for _, testCase := range cases { - suite.T().Run(testCase.name, func(t *testing.T) { + suite.Run(testCase.name, func() { dates := CreateFutureMoveDates(moveDate, numDays, testCase.includeWeekendsAndHolidays, usCalendar) suite.Equal(testCase.dates, dates, "%v: Future dates did not match, expected %v, got %v", testCase.name, testCase.dates, dates) }) @@ -90,7 +90,7 @@ func (suite *DatesSuite) TestCreatePastMoveDates() { }, } for _, testCase := range cases { - suite.T().Run(testCase.name, func(t *testing.T) { + suite.Run(testCase.name, func() { dates := CreatePastMoveDates(moveDate, numDays, testCase.includeWeekendsAndHolidays, usCalendar) suite.Equal(testCase.dates, dates, "%v: Past dates did not match, expected %v, got %v", testCase.name, testCase.dates, dates) }) From 24b33f16ab8d5d4a7873586ae019d745215daf71 Mon Sep 17 00:00:00 2001 From: Marjo Poindexter Date: Wed, 19 Oct 2022 21:39:19 +0000 Subject: [PATCH 05/50] ghcimport --- pkg/services/ghcimport/ghc_rateengine_importer_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/ghcimport/ghc_rateengine_importer_test.go b/pkg/services/ghcimport/ghc_rateengine_importer_test.go index 56e3d84d4f8..9784c7ae834 100644 --- a/pkg/services/ghcimport/ghc_rateengine_importer_test.go +++ b/pkg/services/ghcimport/ghc_rateengine_importer_test.go @@ -78,9 +78,9 @@ func (suite *GHCRateEngineImportSuite) TestGHCRateEngineImporter_Import() { }, } for _, tt := range tests { - suite.T().Run(tt.name, func(t *testing.T) { + suite.Run(tt.name, func() { if err := tt.gre.Import(suite.AppContextForTest()); (err != nil) != tt.wantErr { - t.Errorf("GHCRateEngineImporter.Import() error = %v, wantErr %v", err, tt.wantErr) + suite.T().Errorf("GHCRateEngineImporter.Import() error = %v, wantErr %v", err, tt.wantErr) } }) } From c31a46bbb123c3129224687e496766f8cdeee6c7 Mon Sep 17 00:00:00 2001 From: Marjo Poindexter Date: Wed, 19 Oct 2022 21:51:48 +0000 Subject: [PATCH 06/50] tsp --- ...ation_service_provider_performance_fetcher_test.go | 5 ++--- ..._service_provider_performance_list_fetcher_test.go | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/services/tsp/transportation_service_provider_performance_fetcher_test.go b/pkg/services/tsp/transportation_service_provider_performance_fetcher_test.go index 8a3ca8ec572..aee716603a1 100644 --- a/pkg/services/tsp/transportation_service_provider_performance_fetcher_test.go +++ b/pkg/services/tsp/transportation_service_provider_performance_fetcher_test.go @@ -3,7 +3,6 @@ package tsp import ( "errors" "reflect" - "testing" "github.com/gofrs/uuid" @@ -23,7 +22,7 @@ func (t *testTransportationServiceProviderPerformanceQueryBuilder) FetchOne(appC } func (suite *TSPServiceSuite) TestFetchTransportationServiceProviderPerformance() { - suite.T().Run("if the TSPP is fetched, it should be returned", func(t *testing.T) { + suite.Run("if the TSPP is fetched, it should be returned", func() { id, err := uuid.NewV4() suite.NoError(err) fakeFetchOne := func(appCtx appcontext.AppContext, model interface{}) error { @@ -43,7 +42,7 @@ func (suite *TSPServiceSuite) TestFetchTransportationServiceProviderPerformance( suite.Equal(id, tspp.ID) }) - suite.T().Run("if there is an error, we get it with zero TSPP", func(t *testing.T) { + suite.Run("if there is an error, we get it with zero TSPP", func() { fakeFetchOne := func(appCtx appcontext.AppContext, model interface{}) error { return errors.New("Fetch error") } diff --git a/pkg/services/tsp/transportation_service_provider_performance_list_fetcher_test.go b/pkg/services/tsp/transportation_service_provider_performance_list_fetcher_test.go index a3f2635f928..e442e5cddb1 100644 --- a/pkg/services/tsp/transportation_service_provider_performance_list_fetcher_test.go +++ b/pkg/services/tsp/transportation_service_provider_performance_list_fetcher_test.go @@ -3,7 +3,6 @@ package tsp import ( "errors" "reflect" - "testing" "github.com/gofrs/uuid" @@ -43,7 +42,7 @@ func defaultOrdering() services.QueryOrder { } func (suite *TSPServiceSuite) TestFetchTSPPList() { - suite.T().Run("if the TSPP is fetched, it should be returned", func(t *testing.T) { + suite.Run("if the TSPP is fetched, it should be returned", func() { id, err := uuid.NewV4() suite.NoError(err) fakeFetchMany := func(appCtx appcontext.AppContext, model interface{}) error { @@ -66,7 +65,7 @@ func (suite *TSPServiceSuite) TestFetchTSPPList() { suite.Equal(id, tspps[0].ID) }) - suite.T().Run("if TSPPs are fetched, it should be returned", func(t *testing.T) { + suite.Run("if TSPPs are fetched, it should be returned", func() { id, err := uuid.NewV4() id2, err2 := uuid.NewV4() @@ -93,7 +92,7 @@ func (suite *TSPServiceSuite) TestFetchTSPPList() { suite.Len(tspps, 2) }) - suite.T().Run("if there is an error, we get it with no tspps", func(t *testing.T) { + suite.Run("if there is an error, we get it with no tspps", func() { fakeFetchMany := func(appCtx appcontext.AppContext, model interface{}) error { return errors.New("Fetch error") } @@ -113,7 +112,7 @@ func (suite *TSPServiceSuite) TestFetchTSPPList() { func (suite *TSPServiceSuite) TestCountTSPPs() { - suite.T().Run("if TSPPs are found, they should be counted", func(t *testing.T) { + suite.Run("if TSPPs are found, they should be counted", func() { id, err := uuid.NewV4() suite.NoError(err) @@ -136,7 +135,7 @@ func (suite *TSPServiceSuite) TestCountTSPPs() { suite.Equal(2, count) }) - suite.T().Run("if there is an error, we get it with no count", func(t *testing.T) { + suite.Run("if there is an error, we get it with no count", func() { fakeCount := func(appCtx appcontext.AppContext, model interface{}) (int, error) { return 0, errors.New("Fetch error") } From 6f20421530ffc2e7c7f2653e25480cc47ac263cd Mon Sep 17 00:00:00 2001 From: Marjo Poindexter Date: Wed, 19 Oct 2022 21:53:47 +0000 Subject: [PATCH 07/50] testingsuite --- pkg/testingsuite/pop_suite_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/testingsuite/pop_suite_test.go b/pkg/testingsuite/pop_suite_test.go index 079ac2b9231..f656915c176 100644 --- a/pkg/testingsuite/pop_suite_test.go +++ b/pkg/testingsuite/pop_suite_test.go @@ -56,7 +56,7 @@ func (suite *SimplePopSuite) TestRunWithPreloadData() { suite.NotEqual(address2.ID, foundAddress.ID) }) - suite.T().Run("non testify subtest", func(t *testing.T) { + suite.Run("non testify subtest", func() { var foundAddress models.Address err := suite.DB().Find(&foundAddress, address.ID) suite.NoError(err) From 65ace1cc47e31103d689a916a370f3a3d44c67fe Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Thu, 27 Oct 2022 15:42:02 -0400 Subject: [PATCH 08/50] change field mapping label to less generic one --- .../MoveHistory/Database/FieldMappings.js | 6 +++--- .../createServiceMemberBackupContact.jsx | 20 ++++++++++++++++++- .../createServiceMemberBackupContact.test.jsx | 6 +++--- .../updateServiceMemberBackupContact.jsx | 20 ++++++++++++++++++- .../updateServiceMemberBackupContact.test.jsx | 6 +++--- 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/constants/MoveHistory/Database/FieldMappings.js b/src/constants/MoveHistory/Database/FieldMappings.js index 1efd3169bce..7a07d4ab251 100644 --- a/src/constants/MoveHistory/Database/FieldMappings.js +++ b/src/constants/MoveHistory/Database/FieldMappings.js @@ -76,7 +76,7 @@ export default { residential_address: 'Current mailing address', backup_address: 'Backup mailing address', current_duty_location_name: 'Current duty location name', - name: 'Backup contact name', - email: 'Backup contact email', - phone: 'Backup contact phone', + backup_contact_name: 'Backup contact name', + backup_contact_email: 'Backup contact email', + backup_contact_phone: 'Backup contact phone', }; diff --git a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx index 334ecb207dc..4e33033785b 100644 --- a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx +++ b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.jsx @@ -5,10 +5,28 @@ import t from 'constants/MoveHistory/Database/Tables'; import o from 'constants/MoveHistory/UIDisplay/Operations'; import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; +const formatChangedValues = (historyRecord) => { + const { changedValues } = historyRecord; + const { name, phone, email } = changedValues; + const newChangedValues = changedValues; + if (name) { + newChangedValues.backup_contact_name = changedValues.name; + delete newChangedValues.name; + } + if (email) { + newChangedValues.backup_contact_email = changedValues.email; + delete newChangedValues.email; + } + if (phone) { + newChangedValues.backup_contact_phone = changedValues.phone; + delete newChangedValues.phone; + } + return { ...historyRecord, changedValues: newChangedValues }; +}; export default { action: a.INSERT, eventName: o.createServiceMemberBackupContact, tableName: t.backup_contacts, getEventNameDisplay: () => 'Updated profile', - getDetails: (historyRecord) => , + getDetails: (historyRecord) => , }; diff --git a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx index ca4d48bfdbe..62cb6901aa8 100644 --- a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx @@ -6,9 +6,9 @@ import t from 'constants/MoveHistory/Database/Tables'; import createServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact'; const BACKUP_CONTACT = { - name: 'Tom Haverford', - email: 'tommyHavie@example.com', - phone: '555-555-5555', + backup_contact_name: 'Tom Haverford', + backup_contact_email: 'tommyHavie@example.com', + backup_contact_phone: '555-555-5555', }; describe('When a service members updates their profile', () => { diff --git a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx index 09f00580e50..d2f05107708 100644 --- a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx +++ b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.jsx @@ -5,10 +5,28 @@ import t from 'constants/MoveHistory/Database/Tables'; import o from 'constants/MoveHistory/UIDisplay/Operations'; import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; +const formatChangedValues = (historyRecord) => { + const { changedValues } = historyRecord; + const { name, phone, email } = changedValues; + const newChangedValues = changedValues; + if (name) { + newChangedValues.backup_contact_name = changedValues.name; + delete newChangedValues.name; + } + if (email) { + newChangedValues.backup_contact_email = changedValues.email; + delete newChangedValues.email; + } + if (phone) { + newChangedValues.backup_contact_phone = changedValues.phone; + delete newChangedValues.phone; + } + return { ...historyRecord, changedValues: newChangedValues }; +}; export default { action: a.UPDATE, eventName: o.updateServiceMemberBackupContact, tableName: t.backup_contacts, getEventNameDisplay: () => 'Updated profile', - getDetails: (historyRecord) => , + getDetails: (historyRecord) => , }; diff --git a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx index 326a19fa4bd..d134b7a311b 100644 --- a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx @@ -6,9 +6,9 @@ import t from 'constants/MoveHistory/Database/Tables'; import updateServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact'; const BACKUP_CONTACT = { - name: 'Ben Wyatt', - email: 'benwyatt@example.com', - phone: '555-555-2222', + backup_contact_name: 'Ben Wyatt', + backup_contact_email: 'benwyatt@example.com', + backup_contact_phone: '555-555-2222', }; describe('When a service members updates their profile', () => { From 8757203e033632756ef8ee4256176c35225746ac Mon Sep 17 00:00:00 2001 From: Duncan Spencer Date: Thu, 27 Oct 2022 21:26:49 +0000 Subject: [PATCH 09/50] add PPM shipment summary for payment submission, rework story names and component statuses --- .../PPMSummaryList/PPMSummaryList.jsx | 133 ++++++++++++++---- .../PPMSummaryList/PPMSummaryList.module.scss | 4 + .../PPMSummaryList/PPMSummaryList.stories.jsx | 49 ++++++- 3 files changed, 152 insertions(+), 34 deletions(-) diff --git a/src/components/PPMSummaryList/PPMSummaryList.jsx b/src/components/PPMSummaryList/PPMSummaryList.jsx index a91309e6d65..5edf8f71277 100644 --- a/src/components/PPMSummaryList/PPMSummaryList.jsx +++ b/src/components/PPMSummaryList/PPMSummaryList.jsx @@ -5,30 +5,118 @@ import { Button } from '@trussworks/react-uswds'; import styles from './PPMSummaryList.module.scss'; import SectionWrapper from 'components/Customer/SectionWrapper'; -import { ppmShipmentStatuses, shipmentStatuses } from 'constants/shipments'; +import { ppmShipmentStatuses } from 'constants/shipments'; import { ShipmentShape } from 'types/shipment'; import { formatCustomerDate } from 'utils/formatters'; -const ppmContent = (canUpload, approvedOn) => { - return canUpload ? ( +const submittedContent = ( + <> +

After a counselor approves your PPM, you will be able to:

+
    +
  • Download paperwork for an advance, if you requested one
  • +
  • Upload PPM documents and start the payment request process
  • +
+ +); + +const approvedContent = (approvedAt) => { + return ( <> -

{`PPM approved: ${formatCustomerDate(approvedOn)}.`}

-

- When you are ready to request payment for this PPM, select Upload PPM Documents to add paperwork, calculate your - incentive, and create a payment request packet. -

+
+

{`PPM approved: ${formatCustomerDate(approvedAt)}.`}

+
+
+

+ When you are ready to request payment for this PPM, select Upload PPM Documents to add paperwork, calculate + your incentive, and create a payment request packet. +

+
- ) : ( + ); +}; + +const paymentSubmitted = (approvedAt, submittedAt) => { + return ( <> -

After a counselor approves your PPM, you will be able to:

-
    -
  • Download paperwork for an advance, if you requested one
  • -
  • Upload PPM documents and start the payment request process
  • -
+
+

{`PPM approved: ${formatCustomerDate(approvedAt)}`}

+

{`PPM documentation submitted: ${formatCustomerDate(submittedAt)}`}

+
+
+

+ A counselor will review your documentation. When it's verified, you can visit MilMove to download the + incentive packet that you'll need to give to Finance. +

+
); }; +const paymentReviewed = (approvedAt, submittedAt, reviewedAt) => { + return ( + <> +
+

{`PPM approved: ${formatCustomerDate(approvedAt)}`}

+

{`PPM documentation submitted: ${formatCustomerDate(submittedAt)}`}

+

{`Documentation accepted and verified: ${formatCustomerDate(reviewedAt)}`}

+
+
+

+ You can now download your incentive packet and submit it to Finance to request payment. You will also need to + include a completed DD-1351-2, and any other paperwork required by your service. +

+
+ + ); +}; + +const PPMSummaryStatus = (shipment, orderLabel, onButtonClick) => { + const { + ppmShipment: { status, approvedAt, submittedAt, reviewedAt }, + } = shipment; + + let actionButton; + let content; + + switch (status) { + case ppmShipmentStatuses.SUBMITTED: + actionButton = ( + + ); + content = submittedContent; + break; + case ppmShipmentStatuses.WAITING_ON_CUSTOMER: + actionButton = ; + content = approvedContent(approvedAt); + break; + case ppmShipmentStatuses.NEEDS_PAYMENT_APPROVAL: + actionButton = ( + + ); + content = paymentSubmitted(approvedAt, submittedAt); + break; + case ppmShipmentStatuses.PAYMENT_APPROVED: + actionButton = ; + content = paymentReviewed(approvedAt, submittedAt, reviewedAt); + break; + default: + } + + return ( + +
+ {orderLabel} + {actionButton} +
+
{content}
+
+ ); +}; + const PPMSummaryList = ({ shipments, onUploadClick }) => { const { length } = shipments; return shipments.map((shipment, i) => { @@ -45,20 +133,9 @@ const PPMSummaryList = ({ shipments, onUploadClick }) => { }; const PPMSummaryListItem = ({ shipment, hasMany, index, onUploadClick }) => { - const canUpload = - shipment.status === shipmentStatuses.APPROVED && - shipment?.ppmShipment?.status === ppmShipmentStatuses.WAITING_ON_CUSTOMER; - return ( - -
- {hasMany ? `PPM ${index + 1}` : 'PPM'} - -
-
{ppmContent(canUpload, shipment?.ppmShipment?.approvedAt)}
-
- ); + const orderLabel = hasMany ? `PPM ${index + 1}` : 'PPM'; + + return PPMSummaryStatus(shipment, orderLabel, onUploadClick); }; PPMSummaryList.propTypes = { diff --git a/src/components/PPMSummaryList/PPMSummaryList.module.scss b/src/components/PPMSummaryList/PPMSummaryList.module.scss index 10487c503c2..2af4e8df892 100644 --- a/src/components/PPMSummaryList/PPMSummaryList.module.scss +++ b/src/components/PPMSummaryList/PPMSummaryList.module.scss @@ -32,6 +32,10 @@ @include u-margin-top(2); } + .dateSummary { + @include u-margin-bottom(2); + } + &:last-of-type { @include u-margin-bottom(0); } diff --git a/src/components/PPMSummaryList/PPMSummaryList.stories.jsx b/src/components/PPMSummaryList/PPMSummaryList.stories.jsx index 1fd8ace96c8..da6eb5a99c0 100644 --- a/src/components/PPMSummaryList/PPMSummaryList.stories.jsx +++ b/src/components/PPMSummaryList/PPMSummaryList.stories.jsx @@ -14,8 +14,8 @@ export default { const Template = (args) => ; -export const SingleDisabled = Template.bind({}); -SingleDisabled.args = { +export const Submitted = Template.bind({}); +Submitted.args = { shipments: [ { id: '1', @@ -30,8 +30,8 @@ SingleDisabled.args = { ], }; -export const SingleEnabled = Template.bind({}); -SingleEnabled.args = { +export const Approved = Template.bind({}); +Approved.args = { shipments: [ { id: '1', @@ -47,8 +47,8 @@ SingleEnabled.args = { ], }; -export const MultipleEnabled = Template.bind({}); -MultipleEnabled.args = { +export const ApprovedMultiple = Template.bind({}); +ApprovedMultiple.args = { shipments: [ { id: '1', @@ -74,3 +74,40 @@ MultipleEnabled.args = { }, ], }; + +export const PaymentSubmitted = Template.bind({}); +PaymentSubmitted.args = { + shipments: [ + { + id: '1', + status: shipmentStatuses.APPROVED, + ppmShipment: { + id: '11', + status: ppmShipmentStatuses.NEEDS_PAYMENT_APPROVAL, + approvedAt: '2022-04-15T15:38:07.103Z', + submittedAt: '2022-04-19T15:38:07.103Z', + hasRequestedAdvance: true, + advanceAmountRequested: 10000, + }, + }, + ], +}; + +export const PaymentReviewed = Template.bind({}); +PaymentReviewed.args = { + shipments: [ + { + id: '1', + status: shipmentStatuses.APPROVED, + ppmShipment: { + id: '11', + status: ppmShipmentStatuses.PAYMENT_APPROVED, + approvedAt: '2022-04-15T15:38:07.103Z', + submittedAt: '2022-04-19T15:38:07.103Z', + reviewedAt: '2022-04-23T15:38:07.103Z', + hasRequestedAdvance: true, + advanceAmountRequested: 10000, + }, + }, + ], +}; From 505fcee99a7d3b563fbd94742119e4bf4914e60a Mon Sep 17 00:00:00 2001 From: Amanda P Date: Fri, 28 Oct 2022 10:53:03 -0400 Subject: [PATCH 10/50] violations and serious incident in ER table show no data until radio buttons are selected --- .../EvaluationReportTable.jsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx b/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx index 3722a51b656..d107caeae51 100644 --- a/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx +++ b/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx @@ -45,6 +45,24 @@ const EvaluationReportTable = ({ }; const row = (report) => { + let violations; + let seriousIncident; + + if (report.violationsObserved) { + violations = 'Yes'; + } else if (report.violationsObserved === false) { + violations = 'No'; + } else { + violations = ''; + } + + if (report.seriousIncident) { + seriousIncident = 'Yes'; + } else if (report.seriousIncident === false) { + seriousIncident = 'No'; + } else { + seriousIncident = ''; + } return ( @@ -52,8 +70,8 @@ const EvaluationReportTable = ({ {report.submittedAt && formatCustomerDate(report.submittedAt)} {formatEvaluationReportLocation(report.location)} - {report.violationsObserved ? 'Yes' : 'No'} - {report.seriousIncident ? 'Yes' : 'No'} + {violations} + {seriousIncident} {report.submittedAt && ( - ); + actionButton = ; content = submittedContent; break; case ppmShipmentStatuses.WAITING_ON_CUSTOMER: @@ -92,11 +88,7 @@ const PPMSummaryStatus = (shipment, orderLabel, onButtonClick) => { content = approvedContent(approvedAt); break; case ppmShipmentStatuses.NEEDS_PAYMENT_APPROVAL: - actionButton = ( - - ); + actionButton = ; content = paymentSubmitted(approvedAt, submittedAt); break; case ppmShipmentStatuses.PAYMENT_APPROVED: diff --git a/src/components/PPMSummaryList/PPMSummaryList.test.jsx b/src/components/PPMSummaryList/PPMSummaryList.test.jsx index 25f6cc54f6f..6633041badc 100644 --- a/src/components/PPMSummaryList/PPMSummaryList.test.jsx +++ b/src/components/PPMSummaryList/PPMSummaryList.test.jsx @@ -28,6 +28,31 @@ const shipments = [ advanceAmountRequested: 10000, }, }, + { + id: '3', + status: shipmentStatuses.APPROVED, + ppmShipment: { + id: '33', + status: ppmShipmentStatuses.NEEDS_PAYMENT_APPROVAL, + approvedAt: '2022-04-15T15:38:07.103Z', + submittedAt: '2022-04-19T15:38:07.103Z', + hasRequestedAdvance: true, + advanceAmountRequested: 10000, + }, + }, + { + id: '4', + status: shipmentStatuses.APPROVED, + ppmShipment: { + id: '44', + status: ppmShipmentStatuses.PAYMENT_APPROVED, + approvedAt: '2022-04-15T15:38:07.103Z', + submittedAt: '2022-04-19T15:38:07.103Z', + reviewedAt: '2022-04-23T15:38:07.103Z', + hasRequestedAdvance: true, + advanceAmountRequested: 10000, + }, + }, ]; const onUploadClick = jest.fn(); @@ -49,7 +74,7 @@ describe('PPMSummaryList component', () => { it('should have button enabled', () => { render(); const uploadButton = screen.getByRole('button', { name: 'Upload PPM Documents' }); - expect(uploadButton).not.toBeDisabled(); + expect(uploadButton).toBeEnabled(); userEvent.click(uploadButton); expect(onUploadClick).toHaveBeenCalledWith(props.shipments[0].id); // called with mtoShipmentId expect(onUploadClick).toHaveBeenCalledTimes(1); @@ -60,6 +85,39 @@ describe('PPMSummaryList component', () => { }); }); + describe('payment docs submitted for closeout review', () => { + it('should display submitted date and disabled button with copy', () => { + render(); + expect(screen.getByRole('button', { name: 'Download Incentive Packet' })).toBeDisabled(); + + expect(screen.queryByText(`PPM approved: 15 Apr 2022`)).toBeInTheDocument(); + expect(screen.queryByText(`PPM documentation submitted: 19 Apr 2022`)).toBeInTheDocument(); + + expect( + screen.queryByText( + "A counselor will review your documentation. When it's verified, you can visit MilMove to download the incentive packet that you'll need to give to Finance.", + ), + ).toBeInTheDocument(); + }); + }); + + describe('payment docs reviewed', () => { + it('should display reviewed date and enabled button with copy', () => { + render(); + expect(screen.getByRole('button', { name: 'Download Incentive Packet' })).toBeEnabled(); + + expect(screen.queryByText(`PPM approved: 15 Apr 2022`)).toBeInTheDocument(); + expect(screen.queryByText(`PPM documentation submitted: 19 Apr 2022`)).toBeInTheDocument(); + expect(screen.queryByText(`Documentation accepted and verified: 23 Apr 2022`)).toBeInTheDocument(); + + expect( + screen.queryByText( + 'You can now download your incentive packet and submit it to Finance to request payment. You will also need to include a completed DD-1351-2, and any other paperwork required by your service.', + ), + ).toBeInTheDocument(); + }); + }); + describe('there is only one shipment', () => { it('should not render numbers next to PPM', () => { const props = { ...defaultProps, shipments: shipments.slice(0, 1) }; From d03d55bf057e6dee86c67a214a38b270d56fc135 Mon Sep 17 00:00:00 2001 From: Duncan Spencer Date: Fri, 28 Oct 2022 17:37:42 +0000 Subject: [PATCH 12/50] add submittedAt timestamp to testdatagen payment submitted PPM move --- pkg/testdatagen/scenario/shared.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/testdatagen/scenario/shared.go b/pkg/testdatagen/scenario/shared.go index b5c2972402f..d80cc5ecf5f 100644 --- a/pkg/testdatagen/scenario/shared.go +++ b/pkg/testdatagen/scenario/shared.go @@ -877,6 +877,7 @@ func createApprovedMoveWithPPMCloseoutComplete(appCtx appcontext.AppContext, use PPMShipment: models.PPMShipment{ ID: testdatagen.ConvertUUIDStringToUUID("defb263e-bf01-4c67-85f5-b64ab54fd4fe"), ApprovedAt: &approvedAt, + SubmittedAt: models.TimePointer(approvedAt.Add(7 * time.Hour * 24)), Status: models.PPMShipmentStatusNeedsPaymentApproval, ActualMoveDate: models.TimePointer(time.Date(testdatagen.GHCTestYear, time.March, 16, 0, 0, 0, 0, time.UTC)), ActualPickupPostalCode: models.StringPointer("42444"), From fa84a293ea2f90da398cafd493d90a51a4278e99 Mon Sep 17 00:00:00 2001 From: Duncan Spencer Date: Fri, 28 Oct 2022 18:46:42 +0000 Subject: [PATCH 13/50] add PPM shipment statuses to incomplete storybook data --- src/pages/MyMove/Home/index.stories.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/MyMove/Home/index.stories.jsx b/src/pages/MyMove/Home/index.stories.jsx index 6c53f9819b7..2e6057160b2 100644 --- a/src/pages/MyMove/Home/index.stories.jsx +++ b/src/pages/MyMove/Home/index.stories.jsx @@ -88,6 +88,9 @@ const withShipmentProps = { { id: 'testMove', shipmentType: 'PPM', + ppmShipment: { + status: ppmShipmentStatuses.DRAFT, + }, }, { id: 'testShipment2', @@ -96,6 +99,7 @@ const withShipmentProps = { ppmShipment: { id: 'ppmShipmentIncomplete', hasRequestedAdvance: null, + status: ppmShipmentStatuses.DRAFT, }, }, { @@ -105,6 +109,7 @@ const withShipmentProps = { ppmShipment: { id: 'ppmShipmentComplete', hasRequestedAdvance: true, + status: ppmShipmentStatuses.SUBMITTED, }, }, ], From 6033973a241f0d126ede302244504ab26b1ba5d0 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 28 Oct 2022 21:12:54 +0000 Subject: [PATCH 14/50] createStandardServiceItem refactor --- .../createStandardServiceItem.jsx | 18 +++++++++++ .../createStandardServiceItem.test.jsx | 31 +++++++++++++++++++ .../createStandardServiceItem.js | 18 ----------- .../createStandardServiceItem.test.js | 23 -------------- .../MoveHistory/EventTemplates/index.js | 2 +- 5 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx delete mode 100644 src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js delete mode 100644 src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx new file mode 100644 index 00000000000..4b4c9e1ba4b --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx @@ -0,0 +1,18 @@ +import React from 'react'; + +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import { shipmentTypes as s } from 'constants/shipments'; + +export default { + action: a.INSERT, + eventName: o.approveShipment, + tableName: t.mto_service_items, + getEventNameDisplay: () => 'Approved service item', + getDetails: ({ context }) => ( + <> + {s[context[0]?.shipment_type]} shipment #{context[0].shipment_id_abbr.toUpperCase()}, {context[0]?.name} + + ), +}; diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx new file mode 100644 index 00000000000..d6326231dda --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx @@ -0,0 +1,31 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem'; + +describe('when given a Create standard service item history record', () => { + const historyRecord = { + action: 'INSERT', + context: [ + { + shipment_type: 'HHG', + shipment_id_abbr: 'a1b2c', + name: 'Domestic linehaul', + }, + ], + eventName: 'approveShipment', + tableName: 'mto_service_items', + }; + + it('correctly matches the Create standard service item template', () => { + const template = getTemplate(historyRecord); + expect(template).toMatchObject(e); + }); + + it('displays the correct values in the details column', () => { + const template = getTemplate(historyRecord); + + render(template.getDetails(historyRecord)); + expect(screen.getByText('HHG shipment #A1B2C, Domestic linehaul')).toBeInTheDocument(); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js deleted file mode 100644 index e5a37c7d30e..00000000000 --- a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js +++ /dev/null @@ -1,18 +0,0 @@ -import o from 'constants/MoveHistory/UIDisplay/Operations'; -import d from 'constants/MoveHistory/UIDisplay/DetailsTypes'; -import a from 'constants/MoveHistory/Database/Actions'; -import t from 'constants/MoveHistory/Database/Tables'; -import { shipmentTypes } from 'constants/shipments'; - -export default { - action: a.INSERT, - eventName: o.approveShipment, - tableName: t.mto_service_items, - detailsType: d.PLAIN_TEXT, - getEventNameDisplay: () => 'Approved service item', - getDetailsPlainText: (historyRecord) => { - const shipmentType = historyRecord.context[0]?.shipment_type; - const shipmentIdDisplay = historyRecord.context[0].shipment_id_abbr.toUpperCase(); - return `${shipmentTypes[shipmentType]} shipment #${shipmentIdDisplay}, ${historyRecord.context[0]?.name}`; - }, -}; diff --git a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js deleted file mode 100644 index 3633378c954..00000000000 --- a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import getTemplate from 'constants/MoveHistory/TemplateManager'; -import e from 'constants/MoveHistory/EventTemplates/createStandardServiceItem'; - -describe('when given a Create standard service item history record', () => { - const item = { - action: 'INSERT', - context: [ - { - shipment_type: 'HHG', - shipment_id_abbr: 'a1b2c', - name: 'Domestic linehaul', - }, - ], - eventName: 'approveShipment', - tableName: 'mto_service_items', - }; - it('correctly matches the Create standard service item event', () => { - const result = getTemplate(item); - expect(result).toMatchObject(e); - expect(result.getEventNameDisplay(result)).toEqual('Approved service item'); - expect(result.getDetailsPlainText(item)).toEqual('HHG shipment #A1B2C, Domestic linehaul'); - }); -}); diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index 7b781ddfa7f..f4c0148dd4a 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -15,7 +15,7 @@ export { default as createPaymentRequest } from './createPaymentRequest'; export { default as createPaymentRequestReweighUpdate } from './createPaymentRequestReweighUpdate'; export { default as createPaymentRequestShipmentUpdate } from './createPaymentRequestShipmentUpdate'; export { default as createReweighRequestWeightUpdate } from './createReweighRequestWeightUpdate'; -export { default as createStandardServiceItem } from './createStandardServiceItem'; +export { default as createStandardServiceItem } from './ApproveShipment/createStandardServiceItem'; export { default as deleteShipment } from './DeleteShipment/deleteShipment'; export { default as proofOfServiceDocUpload } from './proofOfServiceDocUpload'; export { default as requestShipmentCancellation } from './requestShipmentCancellation'; From 6c09ceedbfb58170b9e1c6dbbad1c6454a5a1835 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:19:25 -0800 Subject: [PATCH 15/50] Fix initial population of saved observed pickup date --- .../Office/EvaluationViolationsForm/EvaluationViolationsForm.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.jsx b/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.jsx index ed9d57cc8c2..0844d161a34 100644 --- a/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.jsx +++ b/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.jsx @@ -231,6 +231,7 @@ const EvaluationViolationsForm = ({ observedPickupSpreadStartDate: evaluationReport?.observedPickupSpreadStartDate, observedPickupSpreadEndDate: evaluationReport?.observedPickupSpreadEndDate, observedClaimsResponseDate: evaluationReport?.observedClaimsResponseDate, + observedPickupDate: evaluationReport?.observedPickupDate, observedDeliveryDate: evaluationReport?.observedDeliveryDate, kpiViolations, }; From 218a8b73e034e7cb80a8fc0957e901a1a799b4f7 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:20:55 -0800 Subject: [PATCH 16/50] Add preview row component --- .../PreviewRow/PreviewRow.jsx | 33 +++++++++++++++++++ .../PreviewRow/PreviewRow.module.scss | 14 ++++++++ .../PreviewRow/PreviewRow.test.jsx | 20 +++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.jsx create mode 100644 src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.module.scss create mode 100644 src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.test.jsx diff --git a/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.jsx b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.jsx new file mode 100644 index 00000000000..a9569e6b44e --- /dev/null +++ b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.jsx @@ -0,0 +1,33 @@ +import React from 'react'; +import * as PropTypes from 'prop-types'; + +import styles from './PreviewRow.module.scss'; + +import descriptionListStyles from 'styles/descriptionList.module.scss'; + +/** This component renders a row for display in a eval report preview. + * For the most part it is just doing some style overriding of description list items so that the displayed label/value pairs match the designs for the eval report */ +const PreviewRow = ({ isShown, label, data }) => { + if (!isShown) return null; + + return ( +
+
{label}
+
{data}
+
+ ); +}; + +export default PreviewRow; + +PreviewRow.propTypes = { + isShown: PropTypes.bool, + label: PropTypes.node, + data: PropTypes.node, +}; + +PreviewRow.defaultProps = { + isShown: true, + label: '', + data: '', +}; diff --git a/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.module.scss b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.module.scss new file mode 100644 index 00000000000..8ebf22dd8cc --- /dev/null +++ b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.module.scss @@ -0,0 +1,14 @@ +@import 'shared/styles/_basics'; +@import 'shared/styles/colors'; + +.label { + width: 200px !important; + @include u-padding-x(1 !important); + @include u-padding-y(1.5 !important); +} + +.data { + flex-grow: 1; + @include u-padding-x(1 !important); + @include u-padding-y(1.5 !important); +} diff --git a/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.test.jsx b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.test.jsx new file mode 100644 index 00000000000..c51a3ac82a5 --- /dev/null +++ b/src/components/Office/EvaluationReportPreview/PreviewRow/PreviewRow.test.jsx @@ -0,0 +1,20 @@ +import { render, screen } from '@testing-library/react'; +import React from 'react'; + +import PreviewRow from './PreviewRow'; + +describe('Preview Row', () => { + it('renders a basic preview row', async () => { + render(); + + expect(screen.getByText('Label')).toBeInTheDocument(); + expect(screen.getByText('Data')).toBeInTheDocument(); + }); + + it('does not render if isShown is false', async () => { + render(); + + expect(screen.queryByText('Label')).not.toBeInTheDocument(); + expect(screen.queryByText('Data')).not.toBeInTheDocument(); + }); +}); From 8dc0c60480525725fefaa1885dfa74409cdc4e4d Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:21:54 -0800 Subject: [PATCH 17/50] Use preview row in eval report list --- .../DefinitionLists/EvaluationReportList.jsx | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/components/Office/DefinitionLists/EvaluationReportList.jsx b/src/components/Office/DefinitionLists/EvaluationReportList.jsx index 78206dac9d8..bdb640c3f4c 100644 --- a/src/components/Office/DefinitionLists/EvaluationReportList.jsx +++ b/src/components/Office/DefinitionLists/EvaluationReportList.jsx @@ -1,10 +1,10 @@ import React from 'react'; -import classnames from 'classnames'; import { formatEvaluationReportLocation } from '../../../utils/formatters'; import styles from './OfficeDefinitionLists.module.scss'; +import PreviewRow from 'components/Office/EvaluationReportPreview/PreviewRow/PreviewRow'; import descriptionListStyles from 'styles/descriptionList.module.scss'; import { EvaluationReportShape } from 'types/evaluationReport'; @@ -31,30 +31,30 @@ const EvaluationReportList = ({ evaluationReport }) => { return (
-
-
Evaluation type
-
{evaluationReport.inspectionType ? inspectionTypeFormatting(evaluationReport.inspectionType) : ''}
-
-
-
Evaluation location
-
- {formatEvaluationReportLocation(evaluationReport.location)} -
- {evaluationReport.locationDescription || ''} -
-
- {evaluationReport.travelTimeMinutes >= 0 && ( -
-
Travel time to inspection
-
{convertToHoursAndMinutes(evaluationReport.travelTimeMinutes)}
-
- )} - {evaluationReport.evaluationLengthMinutes >= 0 && ( -
-
Evaluation length
-
{convertToHoursAndMinutes(evaluationReport.evaluationLengthMinutes)}
-
- )} + + + {formatEvaluationReportLocation(evaluationReport.location)} +
+ {evaluationReport.locationDescription || ''} + + } + /> + = 0} + label="Travel time to inspection" + data={convertToHoursAndMinutes(evaluationReport.travelTimeMinutes)} + /> + = 0} + label="Evaluation length" + data={convertToHoursAndMinutes(evaluationReport.evaluationLengthMinutes)} + />
); From 8ff7b965b418c48f7ee078af14b2959cb94df59f Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:24:04 -0800 Subject: [PATCH 18/50] Styling cleanup to better match designs, removed unused classes --- .../EvaluationReportPreview.module.scss | 42 ++++++------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss index 3b91df4b72c..838523ea265 100644 --- a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss +++ b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss @@ -1,12 +1,9 @@ @import 'shared/styles/_basics'; @import 'shared/styles/colors'; -.bordered { +.evaluationReportPreview { @include u-border-top('base-lighter'); -} - -.borderless { - margin-top: -32px; + @include u-margin-top(4); } .pageHeader { @@ -37,7 +34,6 @@ } .detailsRight { - @include u-margin-left(2); @include u-margin-bottom(3); } @@ -46,13 +42,9 @@ @include u-margin-bottom(3); } -.counselingDetails { - @include u-margin-bottom(3); -} - .section { @include u-margin-top(2); - @include u-padding(4); + @include u-padding(5); @include u-radius('05'); @include u-border('base-lighter'); @include u-border('1px'); @@ -62,36 +54,26 @@ h3 { @include u-margin-top(1); } + dl { + @include u-margin(0); + } } .shipmentDisplayContainer { @include u-margin-top(2); } -.qaeRemarks, -.violationsRemarks { - width: 75%; +.qaeRemarks { + width: 711px; } -.qaeRemarksLabel, -.violationsLabel { - width: 25%; +.label { + width: 200px !important; + @include u-padding-x(1 !important); + @include u-padding-y(1.5 !important); } .qaeAndCustomerInfo { @include u-margin-left(4); @include u-margin-top(6); } - -.violation { - @include u-padding-x(2); - @include u-padding-y(1); - border: 1px solid $base-light; - border-radius: 2px; - max-width: 648px; - margin-bottom: -1px; - - p { - padding-top: 4px; - } -} From d780cf1617e344f433255803e1babd86fd0f4b59 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:27:26 -0800 Subject: [PATCH 19/50] Create eval report violations list for display of violations fields on preview --- .../EvaluationReportViolationsList.jsx | 74 +++++++++++++++++++ ...EvaluationReportViolationsList.module.scss | 26 +++++++ 2 files changed, 100 insertions(+) create mode 100644 src/components/Office/DefinitionLists/EvaluationReportViolationsList.jsx create mode 100644 src/components/Office/DefinitionLists/EvaluationReportViolationsList.module.scss diff --git a/src/components/Office/DefinitionLists/EvaluationReportViolationsList.jsx b/src/components/Office/DefinitionLists/EvaluationReportViolationsList.jsx new file mode 100644 index 00000000000..355491530a2 --- /dev/null +++ b/src/components/Office/DefinitionLists/EvaluationReportViolationsList.jsx @@ -0,0 +1,74 @@ +import React from 'react'; + +import styles from './EvaluationReportViolationsList.module.scss'; + +import PreviewRow from 'components/Office/EvaluationReportPreview/PreviewRow/PreviewRow'; +import descriptionListStyles from 'styles/descriptionList.module.scss'; +import { EvaluationReportShape } from 'types/evaluationReport'; +import { formatDate } from 'shared/dates'; + +const EvaluationReportViolationsList = ({ evaluationReport, reportViolations }) => { + const hasViolations = reportViolations && reportViolations.length > 0; + const showIncidentDescription = evaluationReport?.seriousIncident; + + return ( +
+
+
+ Violations observed +
+ {hasViolations ? ( +
+ {reportViolations.map((reportViolation) => ( +
+
{`${reportViolation?.violation?.paragraphNumber} ${reportViolation?.violation?.title}`}
+

+ {reportViolation?.violation?.requirementSummary} +

+
+ ))} +
+ ) : ( +
+ No +
+ )} +
+ + + + + + +
+ ); +}; +EvaluationReportViolationsList.propTypes = { + evaluationReport: EvaluationReportShape.isRequired, +}; +export default EvaluationReportViolationsList; diff --git a/src/components/Office/DefinitionLists/EvaluationReportViolationsList.module.scss b/src/components/Office/DefinitionLists/EvaluationReportViolationsList.module.scss new file mode 100644 index 00000000000..08f1e8e6f72 --- /dev/null +++ b/src/components/Office/DefinitionLists/EvaluationReportViolationsList.module.scss @@ -0,0 +1,26 @@ +@import 'shared/styles/_basics'; +@import 'shared/styles/colors'; + +.violationsRemarks { + @include u-padding-x(1 !important); + flex-grow: 1; +} + +.label { + width: 200px !important; + @include u-padding-x(1 !important); + @include u-padding-y(1.5 !important); +} + +.violation { + @include u-padding-x(2); + @include u-padding-y(1); + border: 1px solid $base-light; + border-radius: 2px; + max-width: 648px; + margin-bottom: -1px; + + p { + padding-top: 4px; + } +} From ab090d0cc796e2c51f89fe42c25e7a8c2479741b Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:28:13 -0800 Subject: [PATCH 20/50] Use eval report violations list and styling cleanup --- .../EvaluationReportPreview.jsx | 64 +++++-------------- .../EvaluationViolationsForm.module.scss | 10 +-- 2 files changed, 21 insertions(+), 53 deletions(-) diff --git a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx index 31ce51325ec..c2e9fc43e5b 100644 --- a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx +++ b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx @@ -11,6 +11,7 @@ import EvaluationReportShipmentDisplay from 'components/Office/EvaluationReportS import DataTable from 'components/DataTable'; import DataTableWrapper from 'components/DataTableWrapper'; import EvaluationReportList from 'components/Office/DefinitionLists/EvaluationReportList'; +import EvaluationReportViolationsList from 'components/Office/DefinitionLists/EvaluationReportViolationsList'; import { ORDERS_BRANCH_OPTIONS, ORDERS_RANK_OPTIONS } from 'constants/orders'; import { CustomerShape, EvaluationReportShape, ShipmentShape } from 'types'; import { formatDateFromIso, formatQAReportID } from 'utils/formatters'; @@ -27,8 +28,6 @@ const EvaluationReportPreview = ({ destinationDutyLocationPostalCode, }) => { const isShipment = evaluationReport.type === EVALUATION_REPORT_TYPE.SHIPMENT; - const hasViolations = reportViolations && reportViolations.length > 0; - const showIncidentDescription = evaluationReport?.seriousIncident; let mtoShipmentsToShow; if (evaluationReport.shipmentID) { @@ -74,16 +73,17 @@ const EvaluationReportPreview = ({ return (
-
-
-

{`${isShipment ? 'Shipment' : 'Counseling'} report`}

-
-
REPORT ID {formatQAReportID(evaluationReport.id)}
-
MOVE CODE #{moveCode}
-
MTO REFERENCE ID #{evaluationReport.moveReferenceID}
-
+ {/* Page Header */} +
+

{`${isShipment ? 'Shipment' : 'Counseling'} report`}

+
+
REPORT ID {formatQAReportID(evaluationReport.id)}
+
MOVE CODE #{moveCode}
+
MTO REFERENCE ID #{evaluationReport.moveReferenceID}
+ + {/* Move and Customer/QAE info */}
@@ -109,6 +109,8 @@ const EvaluationReportPreview = ({
+ + {/* Report content */}

Evaluation report

{isShipment && evaluationReport.location !== 'OTHER' ? ( @@ -165,49 +167,13 @@ const EvaluationReportPreview = ({ )}

Violations

-
-
-
- Violations observed -
- {hasViolations ? ( -
- {reportViolations.map((reportViolation) => ( -
-
{`${reportViolation?.violation?.paragraphNumber} ${reportViolation?.violation?.title}`}
-

- {reportViolation?.violation?.requirementSummary} -

-
- ))} -
- ) : ( -
- No -
- )} -
- {hasViolations && ( - <> -
-
Serious incident
-
{showIncidentDescription ? 'Yes' : 'No'}
-
- {showIncidentDescription && ( -
-
Serious incident description
-
{evaluationReport?.seriousIncidentDesc}
-
- )} - - )} -
+

QAE remarks

-
-
Evaluation remarks
+
+
Evaluation remarks
{evaluationReport.remarks}
diff --git a/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.module.scss b/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.module.scss index bf36b4057db..8dee3d6195b 100644 --- a/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.module.scss +++ b/src/components/Office/EvaluationViolationsForm/EvaluationViolationsForm.module.scss @@ -45,7 +45,6 @@ @include u-font-weight(700); @include u-color('base-darker'); font-size: 13px; - } .siHeading { @@ -57,7 +56,6 @@ } .incident { - :global { .usa-form-group { @include u-margin-top(0); @@ -83,7 +81,6 @@ } .claimDatePicker { - :global { .usa-label { @include u-font-weight(700); @@ -97,7 +94,6 @@ @include u-color('base-lighter'); @include u-margin-top(4); border: 1px solid; - } .backIcon { @@ -122,3 +118,9 @@ .submitModalBtn { @include u-margin(0 !important); } + +.title { + h3 { + @include u-margin-bottom(1.5); + } +} From e59dd9306a0f8b4afe2522b40ff3079e6489b618 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 10:28:46 -0800 Subject: [PATCH 21/50] Cypress test updates to ensure all kpi dates are populated and verified --- cypress/integration/office/qaecsr/qaeFlows.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/cypress/integration/office/qaecsr/qaeFlows.js b/cypress/integration/office/qaecsr/qaeFlows.js index acd3ee5732f..27d122a9689 100644 --- a/cypress/integration/office/qaecsr/qaeFlows.js +++ b/cypress/integration/office/qaecsr/qaeFlows.js @@ -290,12 +290,14 @@ describe('Quality Evaluation Report', () => { selectViolation('Counseling', '1.2.5.3 Scheduling'); selectViolation('ShipmentSchedule', '1.2.6.7 Pickup'); selectViolation('LossDamage', '1.2.7.2.2 Claims Settlement'); + selectViolation('ShipmentSchedule', '1.2.6.15 Delivery'); // Fill out date fields for violations with KPIs cy.get('input[name="observedClaimsResponseDate"]').clear().type('03 Oct 2022').blur(); // Observed claims response date cy.get('input[name="observedPickupDate"]').clear().type('04 Oct 2022').blur(); // Observed pickup date - cy.get('input[name="observedPickupSpreadStartDate"]').clear().type('05 Oct 2022').blur(); // Observed pickup spread start date - cy.get('input[name="observedPickupSpreadEndDate"]').clear().type('05 Oct 2022').blur(); // Observed pickup spread end date + cy.get('input[name="observedDeliveryDate"]').clear().type('05 Oct 2022').blur(); // Observed delivery date + cy.get('input[name="observedPickupSpreadStartDate"]').clear().type('06 Oct 2022').blur(); // Observed pickup spread start date + cy.get('input[name="observedPickupSpreadEndDate"]').clear().type('07 Oct 2022').blur(); // Observed pickup spread end date // Serious violations cy.get('[data-testid="radio"] [for="yes"]').click(); @@ -313,14 +315,21 @@ describe('Quality Evaluation Report', () => { cy.get('h3').contains('Violations'); cy.get('h3').contains('QAE remarks'); - // Verify preview has correct sections/headers + // Verify preview has correct sections/headers/content cy.get('@report').within(() => { - cy.get('td').contains('01 Oct 2022'); - cy.get('dd').contains('Physical'); - cy.get('dd').contains('Other'); - cy.get('dd').contains('This is a test other location text'); - cy.get('dd').contains('1 hr 15 min'); - cy.get('dd').contains('This is a test evaluation report'); + cy.contains('td', '01 Oct 2022'); + cy.contains('dd', 'Physical'); + cy.contains('dd', 'Other'); + cy.contains('dd', 'This is a test other location text'); + cy.contains('dd', '1 hr 15 min'); + cy.contains('dd', 'This is a test evaluation report'); + + // kpi dates + cy.contains('dd', '03 Oct 2022'); + cy.contains('dd', '04 Oct 2022'); + cy.contains('dd', '05 Oct 2022'); + cy.contains('dd', '06 Oct 2022'); + cy.contains('dd', '07 Oct 2022'); }); // Submit report From babed002651b72c4a1867182e9cdb6115c33f4c9 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Fri, 28 Oct 2022 13:14:14 -0800 Subject: [PATCH 22/50] Removed bad style --- .../EvaluationReportPreview/EvaluationReportPreview.jsx | 2 +- .../EvaluationReportPreview.module.scss | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx index c2e9fc43e5b..05e78a7599f 100644 --- a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx +++ b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx @@ -71,7 +71,7 @@ const EvaluationReportPreview = ({ }; return ( -
+
{/* Page Header */}
diff --git a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss index 838523ea265..275832bf13e 100644 --- a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss +++ b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.module.scss @@ -1,11 +1,6 @@ @import 'shared/styles/_basics'; @import 'shared/styles/colors'; -.evaluationReportPreview { - @include u-border-top('base-lighter'); - @include u-margin-top(4); -} - .pageHeader { @include u-margin-y(4); display: flex; From a9699fa5f2972aace3bca37bb1c9d7780a0c4ab6 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 28 Oct 2022 22:15:34 +0000 Subject: [PATCH 23/50] [MB-14392] approveShipmentDiversion refactor and now includes ID --- .../approveShipmentDiversion.jsx} | 12 ++++---- .../approveShipmentDiversion.test.jsx | 29 +++++++++++++++++++ .../approveShipmentDiversion.test.js | 15 ---------- .../MoveHistory/EventTemplates/index.js | 2 +- 4 files changed, 37 insertions(+), 21 deletions(-) rename src/constants/MoveHistory/EventTemplates/{approveShipmentDiversion.js => ApproveShipmentDiversion/approveShipmentDiversion.jsx} (55%) create mode 100644 src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.test.jsx delete mode 100644 src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.test.js diff --git a/src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.js b/src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.jsx similarity index 55% rename from src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.js rename to src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.jsx index 2c3afb75512..02004f55fd9 100644 --- a/src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.js +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.jsx @@ -1,4 +1,5 @@ -import d from 'constants/MoveHistory/UIDisplay/DetailsTypes'; +import React from 'react'; + import o from 'constants/MoveHistory/UIDisplay/Operations'; import { shipmentTypes as s } from 'constants/shipments'; @@ -6,9 +7,10 @@ export default { action: '*', eventName: o.approveShipmentDiversion, tableName: '*', - detailsType: d.PLAIN_TEXT, getEventNameDisplay: () => 'Approved diversion', - getDetailsPlainText: (historyRecord) => { - return `${s[historyRecord.oldValues?.shipment_type]} shipment`; - }, + getDetails: ({ context }) => ( + <> + {s[context[0].shipment_type]} shipment #{context[0].shipment_id_abbr.toUpperCase()} + + ), }; diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.test.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.test.jsx new file mode 100644 index 00000000000..73201ca849f --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion.test.jsx @@ -0,0 +1,29 @@ +import { screen, render } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import e from 'constants/MoveHistory/EventTemplates/ApproveShipmentDiversion/approveShipmentDiversion'; + +describe('when given an Approved shipment diversion history record', () => { + const historyRecord = { + changedValues: { status: 'APPROVED' }, + eventName: 'approveShipmentDiversion', + context: [ + { + shipment_id_abbr: '2fa5c', + shipment_type: 'HHG', + }, + ], + }; + + it('correctly matches the Approved shipment event', () => { + const template = getTemplate(historyRecord); + expect(template).toMatchObject(e); + }); + + it('correctly displays the proper details message', () => { + const template = getTemplate(historyRecord); + + render(template.getDetails(historyRecord)); + expect(screen.getByText('HHG shipment #2FA5C')).toBeInTheDocument(); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.test.js b/src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.test.js deleted file mode 100644 index 2a774aa7227..00000000000 --- a/src/constants/MoveHistory/EventTemplates/approveShipmentDiversion.test.js +++ /dev/null @@ -1,15 +0,0 @@ -import getTemplate from 'constants/MoveHistory/TemplateManager'; -import e from 'constants/MoveHistory/EventTemplates/approveShipmentDiversion'; - -describe('when given an Approved shipment diversion history record', () => { - const item = { - changedValues: { status: 'APPROVED' }, - eventName: 'approveShipmentDiversion', - oldValues: { shipment_type: 'HHG' }, - }; - it('correctly matches the Approved shipment event', () => { - const result = getTemplate(item); - expect(result).toMatchObject(e); - expect(result.getDetailsPlainText(item)).toEqual('HHG shipment'); - }); -}); diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index f4c0148dd4a..5e7230d8553 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -1,6 +1,6 @@ export { default as acknowledgeExcessWeightRisk } from './AcknowledgeExcessWeightRisk/acknowledgeExcessWeightRisk'; export { default as approveShipment } from './ApproveShipment/approveShipment'; -export { default as approveShipmentDiversion } from './approveShipmentDiversion'; +export { default as approveShipmentDiversion } from './ApproveShipmentDiversion/approveShipmentDiversion'; export { default as createBasicServiceItem } from './createBasicServiceItem'; export { default as createMTOServiceItem } from './CreateMTOServiceItem/createMTOServiceItem'; export { default as createMTOServiceItemCustomerContacts } from './CreateMTOServiceItem/createMTOServiceItemCustomerContacts'; From a2eb856fa7a06636cc32f25b657599b701f765ea Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 28 Oct 2022 22:39:54 +0000 Subject: [PATCH 24/50] these files should not be in this pr --- .../createStandardServiceItem.jsx | 18 ----------- .../createStandardServiceItem.test.jsx | 31 ------------------- .../createStandardServiceItem.js | 18 +++++++++++ .../createStandardServiceItem.test.js | 23 ++++++++++++++ .../MoveHistory/EventTemplates/index.js | 2 +- 5 files changed, 42 insertions(+), 50 deletions(-) delete mode 100644 src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx delete mode 100644 src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js create mode 100644 src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx deleted file mode 100644 index 4b4c9e1ba4b..00000000000 --- a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; - -import o from 'constants/MoveHistory/UIDisplay/Operations'; -import a from 'constants/MoveHistory/Database/Actions'; -import t from 'constants/MoveHistory/Database/Tables'; -import { shipmentTypes as s } from 'constants/shipments'; - -export default { - action: a.INSERT, - eventName: o.approveShipment, - tableName: t.mto_service_items, - getEventNameDisplay: () => 'Approved service item', - getDetails: ({ context }) => ( - <> - {s[context[0]?.shipment_type]} shipment #{context[0].shipment_id_abbr.toUpperCase()}, {context[0]?.name} - - ), -}; diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx deleted file mode 100644 index d6326231dda..00000000000 --- a/src/constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem.test.jsx +++ /dev/null @@ -1,31 +0,0 @@ -import { render, screen } from '@testing-library/react'; - -import getTemplate from 'constants/MoveHistory/TemplateManager'; -import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/createStandardServiceItem'; - -describe('when given a Create standard service item history record', () => { - const historyRecord = { - action: 'INSERT', - context: [ - { - shipment_type: 'HHG', - shipment_id_abbr: 'a1b2c', - name: 'Domestic linehaul', - }, - ], - eventName: 'approveShipment', - tableName: 'mto_service_items', - }; - - it('correctly matches the Create standard service item template', () => { - const template = getTemplate(historyRecord); - expect(template).toMatchObject(e); - }); - - it('displays the correct values in the details column', () => { - const template = getTemplate(historyRecord); - - render(template.getDetails(historyRecord)); - expect(screen.getByText('HHG shipment #A1B2C, Domestic linehaul')).toBeInTheDocument(); - }); -}); diff --git a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js new file mode 100644 index 00000000000..e5a37c7d30e --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.js @@ -0,0 +1,18 @@ +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import d from 'constants/MoveHistory/UIDisplay/DetailsTypes'; +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import { shipmentTypes } from 'constants/shipments'; + +export default { + action: a.INSERT, + eventName: o.approveShipment, + tableName: t.mto_service_items, + detailsType: d.PLAIN_TEXT, + getEventNameDisplay: () => 'Approved service item', + getDetailsPlainText: (historyRecord) => { + const shipmentType = historyRecord.context[0]?.shipment_type; + const shipmentIdDisplay = historyRecord.context[0].shipment_id_abbr.toUpperCase(); + return `${shipmentTypes[shipmentType]} shipment #${shipmentIdDisplay}, ${historyRecord.context[0]?.name}`; + }, +}; diff --git a/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js new file mode 100644 index 00000000000..3633378c954 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/createStandardServiceItem.test.js @@ -0,0 +1,23 @@ +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import e from 'constants/MoveHistory/EventTemplates/createStandardServiceItem'; + +describe('when given a Create standard service item history record', () => { + const item = { + action: 'INSERT', + context: [ + { + shipment_type: 'HHG', + shipment_id_abbr: 'a1b2c', + name: 'Domestic linehaul', + }, + ], + eventName: 'approveShipment', + tableName: 'mto_service_items', + }; + it('correctly matches the Create standard service item event', () => { + const result = getTemplate(item); + expect(result).toMatchObject(e); + expect(result.getEventNameDisplay(result)).toEqual('Approved service item'); + expect(result.getDetailsPlainText(item)).toEqual('HHG shipment #A1B2C, Domestic linehaul'); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index 5e7230d8553..0ad45c8e0e7 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -15,7 +15,7 @@ export { default as createPaymentRequest } from './createPaymentRequest'; export { default as createPaymentRequestReweighUpdate } from './createPaymentRequestReweighUpdate'; export { default as createPaymentRequestShipmentUpdate } from './createPaymentRequestShipmentUpdate'; export { default as createReweighRequestWeightUpdate } from './createReweighRequestWeightUpdate'; -export { default as createStandardServiceItem } from './ApproveShipment/createStandardServiceItem'; +export { default as createStandardServiceItem } from './createStandardServiceItem'; export { default as deleteShipment } from './DeleteShipment/deleteShipment'; export { default as proofOfServiceDocUpload } from './proofOfServiceDocUpload'; export { default as requestShipmentCancellation } from './requestShipmentCancellation'; From e229456ceb6bd389cf222360857df1dbbab74474 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 28 Oct 2022 23:18:36 +0000 Subject: [PATCH 25/50] fixing up files --- .../requestShipmentDiversion.jsx} | 0 .../RequestShipmentDiversion/requestShipmentDiversion.test.jsx | 0 src/constants/MoveHistory/EventTemplates/index.js | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename src/constants/MoveHistory/EventTemplates/{requestShipmentDiversion.js => RequestShipmentDiversion/requestShipmentDiversion.jsx} (100%) create mode 100644 src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx diff --git a/src/constants/MoveHistory/EventTemplates/requestShipmentDiversion.js b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx similarity index 100% rename from src/constants/MoveHistory/EventTemplates/requestShipmentDiversion.js rename to src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx diff --git a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index 7b781ddfa7f..8be22dbc2e7 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -19,7 +19,7 @@ export { default as createStandardServiceItem } from './createStandardServiceIte export { default as deleteShipment } from './DeleteShipment/deleteShipment'; export { default as proofOfServiceDocUpload } from './proofOfServiceDocUpload'; export { default as requestShipmentCancellation } from './requestShipmentCancellation'; -export { default as requestShipmentDiversion } from './requestShipmentDiversion'; +export { default as requestShipmentDiversion } from './RequestShipmentDiversion/requestShipmentDiversion'; export { default as requestShipmentReweigh } from './RequestShipmentReweigh/requestShipmentReweigh'; export { default as setFinancialReviewFlag } from './SetFinancialReviewFlag/setFinancialReviewFlag'; export { default as submitMoveForApproval } from './SubmitMoveForApproval/submitMoveForApproval'; From db7913a88cafc9aec4f731c6c9718426540cf4e7 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 28 Oct 2022 23:54:54 +0000 Subject: [PATCH 26/50] templaste and testing --- .../requestShipmentDiversion.jsx | 20 +++++++----- .../requestShipmentDiversion.test.jsx | 31 +++++++++++++++++++ 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx index 025b350fa79..8d3cb9066b5 100644 --- a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx +++ b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx @@ -1,14 +1,18 @@ +import React from 'react'; + import o from 'constants/MoveHistory/UIDisplay/Operations'; -import d from 'constants/MoveHistory/UIDisplay/DetailsTypes'; -import { shipmentTypes } from 'constants/shipments'; +import t from 'constants/MoveHistory/Database/Tables'; +import a from 'constants/MoveHistory/Database/Actions'; +import { shipmentTypes as s } from 'constants/shipments'; export default { - action: '*', + action: a.UPDATE, eventName: o.requestShipmentDiversion, - tableName: '*', - detailsType: d.PLAIN_TEXT, + tableName: t.mto_shipments, getEventNameDisplay: () => 'Requested diversion', - getDetailsPlainText: (historyRecord) => { - return `Requested diversion for ${shipmentTypes[historyRecord.oldValues?.shipment_type]} shipment`; - }, + getDetails: ({ context }) => ( + <> + Requested diversion for {s[context[0]?.shipment_type]} shipment #{context[0].shipment_id_abbr.toUpperCase()} + + ), }; diff --git a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx index e69de29bb2d..1baf7e282c6 100644 --- a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.test.jsx @@ -0,0 +1,31 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import e from 'constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion'; + +describe('when a shipment diversion is requested', () => { + const historyRecord = { + action: 'UPDATE', + changedValues: { status: 'DIVERSION_REQUESTED' }, + eventName: 'requestShipmentDiversion', + context: [ + { + shipment_id_abbr: '2fa5c', + shipment_type: 'HHG', + }, + ], + tableName: 'mto_shipments', + }; + + it('correctly matches to the proper template', () => { + const template = getTemplate(historyRecord); + expect(template).toMatchObject(e); + }); + + it('correctly displays the proper details message', () => { + const template = getTemplate(historyRecord); + + render(template.getDetails(historyRecord)); + expect(screen.getByText('Requested diversion for HHG shipment #2FA5C')).toBeInTheDocument(); + }); +}); From 4d7de752deec0a566ec7674002053d5e7d295f2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 11:02:41 +0000 Subject: [PATCH 27/50] Bump github.com/vektra/mockery/v2 from 2.14.0 to 2.14.1 Bumps [github.com/vektra/mockery/v2](https://github.com/vektra/mockery) from 2.14.0 to 2.14.1. - [Release notes](https://github.com/vektra/mockery/releases) - [Changelog](https://github.com/vektra/mockery/blob/master/.goreleaser.yml) - [Commits](https://github.com/vektra/mockery/compare/v2.14.0...v2.14.1) --- updated-dependencies: - dependency-name: github.com/vektra/mockery/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index de109a1c6d7..fbc94117656 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,7 @@ require ( github.com/tealeg/xlsx/v3 v3.2.4 github.com/tiaguinho/gosoap v1.4.4 github.com/trussworks/otelhttp v0.0.0-20220801182039-09272611890b - github.com/vektra/mockery/v2 v2.14.0 + github.com/vektra/mockery/v2 v2.14.1 go.mozilla.org/pkcs7 v0.0.0-20181213175627-3cffc6fbfe83 go.opentelemetry.io/contrib/detectors/aws/ecs v1.11.1 go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.36.4 diff --git a/go.sum b/go.sum index 89af0059255..b1289abda6b 100644 --- a/go.sum +++ b/go.sum @@ -699,8 +699,8 @@ github.com/trussworks/otelhttp v0.0.0-20220801182039-09272611890b h1:GfWBTYwftTB github.com/trussworks/otelhttp v0.0.0-20220801182039-09272611890b/go.mod h1:tYMe+82scvKImZgix8ICds9ULHKR8nt4A1QV4WbFaw4= github.com/urfave/cli v1.21.0 h1:wYSSj06510qPIzGSua9ZqsncMmWE3Zr55KBERygyrxE= github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ= -github.com/vektra/mockery/v2 v2.14.0 h1:KZ1p5Hrn8tiY+LErRMr14HHle6khxo+JKOXLBW/yfqs= -github.com/vektra/mockery/v2 v2.14.0/go.mod h1:bnD1T8tExSgPD1ripLkDbr60JA9VtQeu12P3wgLZd7M= +github.com/vektra/mockery/v2 v2.14.1 h1:Xamr4zUkFBDGdZhJ6iCiJ1AwkGRmUgZd8zkwjRXt+TU= +github.com/vektra/mockery/v2 v2.14.1/go.mod h1:bnD1T8tExSgPD1ripLkDbr60JA9VtQeu12P3wgLZd7M= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= From 5485c5412d1d45a16993c154fd197e72f7d05f41 Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Mon, 31 Oct 2022 12:25:55 -0400 Subject: [PATCH 28/50] update test --- .../createServiceMemberBackupContact.test.jsx | 6 +++--- .../updateServiceMemberBackupContact.test.jsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx index 62cb6901aa8..ca4d48bfdbe 100644 --- a/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact.test.jsx @@ -6,9 +6,9 @@ import t from 'constants/MoveHistory/Database/Tables'; import createServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/CreateServiceMemberBackupContact/createServiceMemberBackupContact'; const BACKUP_CONTACT = { - backup_contact_name: 'Tom Haverford', - backup_contact_email: 'tommyHavie@example.com', - backup_contact_phone: '555-555-5555', + name: 'Tom Haverford', + email: 'tommyHavie@example.com', + phone: '555-555-5555', }; describe('When a service members updates their profile', () => { diff --git a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx index d134b7a311b..326a19fa4bd 100644 --- a/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact.test.jsx @@ -6,9 +6,9 @@ import t from 'constants/MoveHistory/Database/Tables'; import updateServiceMemberBackupContact from 'constants/MoveHistory/EventTemplates/UpdateServiceMemberBackupContact/updateServiceMemberBackupContact'; const BACKUP_CONTACT = { - backup_contact_name: 'Ben Wyatt', - backup_contact_email: 'benwyatt@example.com', - backup_contact_phone: '555-555-2222', + name: 'Ben Wyatt', + email: 'benwyatt@example.com', + phone: '555-555-2222', }; describe('When a service members updates their profile', () => { From 649271985d8300c5d151ae326e66860004bfdf64 Mon Sep 17 00:00:00 2001 From: DymonMoore Date: Mon, 31 Oct 2022 16:35:12 +0000 Subject: [PATCH 29/50] Displays report submission date in preview before save --- .../EvaluationReportPreview/EvaluationReportPreview.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx index 4b8a09f0c9f..7a56bf7bddd 100644 --- a/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx +++ b/src/components/Office/EvaluationReportPreview/EvaluationReportPreview.jsx @@ -157,7 +157,9 @@ const EvaluationReportPreview = ({ columnHeaders={['Inspection date', 'Report submission']} dataRow={[ evaluationReport.inspectionDate ? formatDate(evaluationReport.inspectionDate, 'DD MMM YYYY') : '—', - evaluationReport.submittedAt ? formatDateFromIso(evaluationReport.submittedAt, 'DD MMM YYYY') : '—', + evaluationReport.submittedAt + ? formatDateFromIso(evaluationReport.submittedAt, 'DD MMM YYYY') + : formatDate(new Date(), 'DD MMM YYYY'), ]} /> From 710c9636f6fa45809435cf36a4a7dea6ad432a78 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Mon, 31 Oct 2022 16:58:25 +0000 Subject: [PATCH 30/50] template refactored and now includes ID --- .../EventTemplates/ApproveShipment/approveShipment.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.jsx index 897624028e3..e32d27b9432 100644 --- a/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.jsx +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.jsx @@ -1,3 +1,5 @@ +import React from 'react'; + import a from 'constants/MoveHistory/Database/Actions'; import t from 'constants/MoveHistory/Database/Tables'; import o from 'constants/MoveHistory/UIDisplay/Operations'; @@ -8,7 +10,9 @@ export default { eventName: o.approveShipment, tableName: t.mto_shipments, getEventNameDisplay: () => 'Approved shipment', - getDetails: (historyRecord) => { - return `${s[historyRecord.oldValues?.shipment_type]} shipment`; - }, + getDetails: ({ context }) => ( + <> + {s[context[0]?.shipment_type]} shipment #{context[0]?.shipment_id_abbr.toUpperCase()} + + ), }; From 5b6f9404bd80063535274c3fa89ebff5ae649531 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Mon, 31 Oct 2022 17:57:18 +0000 Subject: [PATCH 31/50] broke up testing and added context --- .../ApproveShipment/approveShipment.test.jsx | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.test.jsx b/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.test.jsx index 6d7091abd92..4438fb0042e 100644 --- a/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.test.jsx +++ b/src/constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment.test.jsx @@ -4,17 +4,28 @@ import getTemplate from 'constants/MoveHistory/TemplateManager'; import e from 'constants/MoveHistory/EventTemplates/ApproveShipment/approveShipment'; describe('when given an Approved shipment history record', () => { - const item = { + const historyRecord = { action: 'UPDATE', changedValues: { status: 'APPROVED' }, eventName: 'approveShipment', oldValues: { shipment_type: 'HHG' }, tableName: 'mto_shipments', + context: [ + { + shipment_id_abbr: '2fa5c', + shipment_type: 'HHG', + }, + ], }; - it('correctly matches the Approved shipment event', () => { - const result = getTemplate(item); - expect(result).toMatchObject(e); - render(result.getDetails(item)); - expect(screen.getByText('HHG shipment')).toBeInTheDocument(); + it('correctly matches to the Approved shipment template', () => { + const template = getTemplate(historyRecord); + expect(template).toMatchObject(e); + }); + + it('displays the proper value in the details field', () => { + const template = getTemplate(historyRecord); + + render(template.getDetails(historyRecord)); + expect(screen.getByText('HHG shipment #2FA5C')).toBeInTheDocument(); }); }); From eb0cdfaf23ad1464c38ebcda338faa60e1518ee1 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Mon, 31 Oct 2022 17:58:11 +0000 Subject: [PATCH 32/50] added context to test data, will fail otherwise --- src/pages/Office/MoveHistory/MoveHistory.test.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pages/Office/MoveHistory/MoveHistory.test.jsx b/src/pages/Office/MoveHistory/MoveHistory.test.jsx index 6e871ff0139..f438c0182a4 100644 --- a/src/pages/Office/MoveHistory/MoveHistory.test.jsx +++ b/src/pages/Office/MoveHistory/MoveHistory.test.jsx @@ -109,6 +109,12 @@ jest.mock('hooks/queries', () => ({ uses_external_vendor: '', }, tableName: 'mto_shipments', + context: [ + { + shipment_id_abbr: '2fa5c', + shipment_type: 'HHG', + }, + ], }, ], }, From 3a187afc114a9f5e16cda20c84fd863b7d8d3457 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Mon, 31 Oct 2022 19:18:24 +0000 Subject: [PATCH 33/50] updated event name per design --- .../RequestShipmentDiversion/requestShipmentDiversion.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx index 8d3cb9066b5..e150f5b8b2d 100644 --- a/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx +++ b/src/constants/MoveHistory/EventTemplates/RequestShipmentDiversion/requestShipmentDiversion.jsx @@ -9,7 +9,7 @@ export default { action: a.UPDATE, eventName: o.requestShipmentDiversion, tableName: t.mto_shipments, - getEventNameDisplay: () => 'Requested diversion', + getEventNameDisplay: () => 'Updated shipment', getDetails: ({ context }) => ( <> Requested diversion for {s[context[0]?.shipment_type]} shipment #{context[0].shipment_id_abbr.toUpperCase()} From 4a06b76301f3d93169effefd6d6456f301a107fd Mon Sep 17 00:00:00 2001 From: Amanda P Date: Mon, 31 Oct 2022 15:37:24 -0400 Subject: [PATCH 34/50] Add unit tests for violation and incident in report table --- .../EvaluationReportTable/EvaluationReportTable.jsx | 8 ++++++-- .../EvaluationReportTable/EvaluationReportTable.test.jsx | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx b/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx index d107caeae51..030f556750c 100644 --- a/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx +++ b/src/components/Office/EvaluationReportTable/EvaluationReportTable.jsx @@ -70,8 +70,12 @@ const EvaluationReportTable = ({ {report.submittedAt && formatCustomerDate(report.submittedAt)} {formatEvaluationReportLocation(report.location)} - {violations} - {seriousIncident} + + {violations} + + + {seriousIncident} + {report.submittedAt && (