From 7a0cf975605d25b0b83b9fed8bc4504d38e2ed61 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Wed, 21 Jun 2023 12:07:17 -0700 Subject: [PATCH 1/9] PSP-6286 : Restrict changing final compensation requisition status back to draft --- .../api/Services/AcquisitionFileService.cs | 8 +- .../CompensationRequisitionService.cs | 25 +++- .../CompensationRequisitionServiceTest.cs | 137 +++++++++++++++++ .../CompensationRequisitionTrayView.tsx | 1 - ...nsationRequisitionDetailContainer.test.tsx | 1 - ...CompensationRequisitionDetailContainer.tsx | 12 +- ...CompensationRequisitionDetailView.test.tsx | 97 ++++++++++-- .../CompensationRequisitionDetailView.tsx | 51 +++++-- ...nsationRequisitionDetailView.test.tsx.snap | 95 +++++++++--- .../frontend/src/mocks/compensations.mock.ts | 139 ++++++++++++++++++ 10 files changed, 499 insertions(+), 67 deletions(-) diff --git a/source/backend/api/Services/AcquisitionFileService.cs b/source/backend/api/Services/AcquisitionFileService.cs index dbea7225b0..7de5932010 100644 --- a/source/backend/api/Services/AcquisitionFileService.cs +++ b/source/backend/api/Services/AcquisitionFileService.cs @@ -361,14 +361,8 @@ public PimsCompensationRequisition AddCompensationRequisition(long acquisitionFi throw new BadRequestException("Invalid acquisitionFileId."); } - // The compensation requisition can only have one payee and one checke, for now add them at creation. - var newPayee = new PimsAcquisitionPayee(); - // TODO fix this - /*var newCheque = new PimsAcqPayeeCheque(); - newPayee.PimsAcqPayeeCheques = new List() { newCheque };*/ - compensationRequisition.IsDraft = compensationRequisition.IsDraft ?? true; - compensationRequisition.PimsAcquisitionPayees = new List() { newPayee }; + compensationRequisition.PimsAcquisitionPayees = new List() { new PimsAcquisitionPayee() }; var newCompensationRequisition = _compensationRequisitionRepository.Add(compensationRequisition); diff --git a/source/backend/api/Services/CompensationRequisitionService.cs b/source/backend/api/Services/CompensationRequisitionService.cs index 8a24793140..04c9a26692 100644 --- a/source/backend/api/Services/CompensationRequisitionService.cs +++ b/source/backend/api/Services/CompensationRequisitionService.cs @@ -2,9 +2,11 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using DocumentFormat.OpenXml.Office2010.Excel; using Microsoft.Extensions.Logging; using Pims.Core.Extensions; using Pims.Dal.Entities; +using Pims.Dal.Exceptions; using Pims.Dal.Helpers.Extensions; using Pims.Dal.Repositories; using Pims.Dal.Security; @@ -18,14 +20,18 @@ public class CompensationRequisitionService : ICompensationRequisitionService private readonly ICompensationRequisitionRepository _compensationRequisitionRepository; private readonly IAcquisitionPayeeRepository _acquisitionPayeeRepository; private readonly IEntityNoteRepository _entityNoteRepository; + private readonly IUserRepository _userRepository; + private readonly IAcquisitionFileRepository _acqFileRepository; - public CompensationRequisitionService(ClaimsPrincipal user, ILogger logger, ICompensationRequisitionRepository compensationRequisitionRepository, IAcquisitionPayeeRepository acquisitionPayeeRepository, IEntityNoteRepository entityNoteRepository) + public CompensationRequisitionService(ClaimsPrincipal user, ILogger logger, ICompensationRequisitionRepository compensationRequisitionRepository, IAcquisitionPayeeRepository acquisitionPayeeRepository, IEntityNoteRepository entityNoteRepository, IUserRepository userRepository, IAcquisitionFileRepository acqFileRepository) { _user = user; _logger = logger; _compensationRequisitionRepository = compensationRequisitionRepository; _acquisitionPayeeRepository = acquisitionPayeeRepository; _entityNoteRepository = entityNoteRepository; + _userRepository = userRepository; + _acqFileRepository = acqFileRepository; } public PimsCompensationRequisition GetById(long compensationRequisitionId) @@ -68,10 +74,14 @@ public PimsCompensationRequisition Update(PimsCompensationRequisition compensati { _user.ThrowIfNotAuthorized(Permissions.CompensationRequisitionEdit); compensationRequisition.ThrowIfNull(nameof(compensationRequisition)); + _user.ThrowInvalidAccessToAcquisitionFile(_userRepository, _acqFileRepository, compensationRequisition.AcquisitionFileId); + _logger.LogInformation($"Updating Compensation Requisition with id ${compensationRequisition.CompensationRequisitionId}"); var currentCompensation = _compensationRequisitionRepository.GetById(compensationRequisition.CompensationRequisitionId); - (bool? currentStatus, bool? newStatus) compReqStatusComparable = (currentStatus: currentCompensation.IsDraft, newStatus: compensationRequisition.IsDraft); + (bool? currentIsDraft, bool? newIsDraft) compReqStatusComparable = (currentIsDraft: currentCompensation.IsDraft, newIsDraft: compensationRequisition.IsDraft); + + CheckDraftStatusUpdateAuthorized(compReqStatusComparable); PimsCompensationRequisition updatedEntity = _compensationRequisitionRepository.Update(compensationRequisition); AddNoteIfStatusChanged(compensationRequisition.Internal_Id, compensationRequisition.AcquisitionFileId, compReqStatusComparable); @@ -87,6 +97,7 @@ public bool DeleteCompensation(long compensationId) var fileFormToDelete = _compensationRequisitionRepository.TryDelete(compensationId); _compensationRequisitionRepository.CommitTransaction(); + return fileFormToDelete; } @@ -128,5 +139,15 @@ private void AddNoteIfStatusChanged(long compensationRequisitionId, long acquisi _entityNoteRepository.Add(fileNoteInstance); } + + private void CheckDraftStatusUpdateAuthorized((bool? currentStatus, bool? newStatus) statusComparable) + { + if (statusComparable.currentStatus.HasValue && statusComparable.currentStatus.Value.Equals(false) + && ((statusComparable.newStatus.HasValue && statusComparable.newStatus.Value.Equals(true)) || !statusComparable.newStatus.HasValue) + && !_user.HasPermission(Permissions.AdminUsers)) + { + throw new NotAuthorizedException(); + } + } } } diff --git a/source/backend/tests/unit/api/Services/CompensationRequisitionServiceTest.cs b/source/backend/tests/unit/api/Services/CompensationRequisitionServiceTest.cs index 1e867ec3f8..889282b5ea 100644 --- a/source/backend/tests/unit/api/Services/CompensationRequisitionServiceTest.cs +++ b/source/backend/tests/unit/api/Services/CompensationRequisitionServiceTest.cs @@ -9,6 +9,7 @@ using Pims.Api.Helpers.Exceptions; using Pims.Api.Services; using Pims.Core.Test; +using Pims.Dal; using Pims.Dal.Entities; using Pims.Dal.Exceptions; using Pims.Dal.Repositories; @@ -143,6 +144,114 @@ public void Update_Success_Skips_StatusChanged_Note() && x.Note.NoteTxt.Equals("Compensation Requisition with # 1, changed status from 'Draft' to 'Final'"))), Times.Never); } + [Fact] + public void Update_Status_BackToDraft_NoPermission() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(Permissions.CompensationRequisitionEdit); + var noteRepository = _helper.GetService>(); + var repository = _helper.GetService>(); + + repository.Setup(x => x.GetById(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = false }); + + // Act + Action act = () => service.Update(new PimsCompensationRequisition() + { + Internal_Id = 1, + AcquisitionFileId = 1, + ConcurrencyControlNumber = 2, + IsDraft = true + }); + + // Assert + act.Should().Throw(); + } + + [Fact] + public void Update_Status_BackToNull_NoPermission() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(Permissions.CompensationRequisitionEdit); + var noteRepository = _helper.GetService>(); + var repository = _helper.GetService>(); + + repository.Setup(x => x.GetById(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = false }); + + // Act + Action act = () => service.Update(new PimsCompensationRequisition() + { + Internal_Id = 1, + AcquisitionFileId = 1, + ConcurrencyControlNumber = 2, + IsDraft = null + }); + + // Assert + act.Should().Throw(); + } + + [Fact] + public void Update_Status_BackToDraft_AuthorizedAdmin() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(Permissions.CompensationRequisitionEdit, Permissions.AdminUsers); + var noteRepository = _helper.GetService>(); + var repository = _helper.GetService>(); + + repository.Setup(x => x.GetById(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = false }); + + repository.Setup(x => x.Update(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = true }); + + // Act + var result = service.Update(new PimsCompensationRequisition() + { + Internal_Id = 1, + AcquisitionFileId = 1, + ConcurrencyControlNumber = 2, + IsDraft = true + }); + + // Assert + result.Should().NotBeNull(); + repository.Verify(x => x.Update(It.IsAny()), Times.Once); + noteRepository.Verify(x => x.Add(It.Is(x => x.AcquisitionFileId == 1 + && x.Note.NoteTxt.Equals("Compensation Requisition with # 1, changed status from 'Final' to 'Draft'"))), Times.Once); + } + + [Fact] + public void Update_Status_BackToNull_AuthorizedAdmin() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(Permissions.CompensationRequisitionEdit, Permissions.AdminUsers); + var noteRepository = _helper.GetService>(); + var repository = _helper.GetService>(); + + repository.Setup(x => x.GetById(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = false }); + + repository.Setup(x => x.Update(It.IsAny())) + .Returns(new PimsCompensationRequisition { Internal_Id = 1, AcquisitionFileId = 1, IsDraft = null }); + + // Act + var result = service.Update(new PimsCompensationRequisition() + { + Internal_Id = 1, + AcquisitionFileId = 1, + ConcurrencyControlNumber = 2, + IsDraft = null + }); + + // Assert + result.Should().NotBeNull(); + repository.Verify(x => x.Update(It.IsAny()), Times.Once); + noteRepository.Verify(x => x.Add(It.Is(x => x.AcquisitionFileId == 1 + && x.Note.NoteTxt.Equals("Compensation Requisition with # 1, changed status from 'Final' to 'No Status'"))), Times.Once); + } + [Fact] public void Update_Success_Skips_StatusChanged_Note_FromNoStatus() { @@ -173,6 +282,34 @@ public void Update_Success_Skips_StatusChanged_Note_FromNoStatus() && x.Note.NoteTxt.Equals("Compensation Requisition with # 1, changed status from 'No Status' to 'Draft'"))), Times.Once); } + [Fact] + public void Delete_NoPermission() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(); + + // Act + Action act = () => service.DeleteCompensation(1); + + // Assert + act.Should().Throw(); + } + + [Fact] + public void Delete_Success() + { + // Arrange + var service = CreateCompRequisitionServiceWithPermissions(Permissions.CompensationRequisitionDelete); + var repo = _helper.GetService>(); + repo.Setup(x => x.TryDelete(It.IsAny())); + + // Act + var result = service.DeleteCompensation(1); + + // Assert + repo.Verify(x => x.TryDelete(It.IsAny()), Times.Once); + } + private CompensationRequisitionService CreateCompRequisitionServiceWithPermissions(params Permissions[] permissions) { var user = PrincipalHelper.CreateForPermission(permissions); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/CompensationRequisitionTrayView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/CompensationRequisitionTrayView.tsx index a82b934d32..e0178df46b 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/CompensationRequisitionTrayView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/CompensationRequisitionTrayView.tsx @@ -54,7 +54,6 @@ export const CompensationRequisitionTrayView: React.FunctionComponent< acquisitionFile={acquistionFile} View={CompensationRequisitionDetailView} clientConstant={clientConstant} - gstConstant={gstConstant ?? 0} loading={loading} setEditMode={setEditMode} > diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.test.tsx index f2d0b58497..3cb2d751f1 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.test.tsx @@ -26,7 +26,6 @@ describe('Compensation Detail View container', () => { setEditMode={setEditMode} compensation={renderOptions.props?.compensation ?? getMockApiCompensation()} acquisitionFile={renderOptions.props?.acquisitionFile ?? mockAcquisitionFileResponse()} - gstConstant={renderOptions.props?.gstConstant ?? 0} clientConstant={renderOptions.props?.clientConstant ?? '034'} />, { diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.tsx index c5a479ea97..3c8886d472 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailContainer.tsx @@ -12,7 +12,6 @@ export interface CompensationRequisitionDetailContainerProps { compensation: Api_CompensationRequisition; acquisitionFile: Api_AcquisitionFile; clientConstant: string; - gstConstant: number; loading: boolean; setEditMode: (editMode: boolean) => void; View: React.FunctionComponent>; @@ -20,15 +19,7 @@ export interface CompensationRequisitionDetailContainerProps { export const CompensationRequisitionDetailContainer: React.FunctionComponent< React.PropsWithChildren -> = ({ - compensation, - setEditMode, - View, - clientConstant, - acquisitionFile, - gstConstant, - loading, -}) => { +> = ({ compensation, setEditMode, View, clientConstant, acquisitionFile, loading }) => { const onGenerate = useGenerateH120(); const [compensationPayee, setCompensationPayee] = useState(); const { @@ -60,7 +51,6 @@ export const CompensationRequisitionDetailContainer: React.FunctionComponent< acqFileProduct={acquisitionFile?.product} setEditMode={setEditMode} clientConstant={clientConstant} - gstConstant={gstConstant} onGenerate={onGenerate} > ) : null; diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.test.tsx index 0b7ec2cc89..5a1736f40a 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.test.tsx @@ -1,7 +1,12 @@ import { createMemoryHistory } from 'history'; import Claims from '@/constants/claims'; -import { getMockApiCompensation } from '@/mocks/compensations.mock'; +import { + getMockApiCompensation, + getMockApiCompensationPayee, + getMockApiDefaultCompensation, + getMockApiFinalCompensation, +} from '@/mocks/compensations.mock'; import { act, render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; import CompensationRequisitionDetailView, { @@ -14,16 +19,16 @@ const history = createMemoryHistory(); jest.mock('@react-keycloak/web'); describe('Compensation Detail View Component', () => { - const setup = ( + const setup = async ( renderOptions: RenderOptions & { props?: Partial }, ) => { // render component under test const component = render( , @@ -44,30 +49,98 @@ describe('Compensation Detail View Component', () => { }); it('renders as expected', async () => { - const { asFragment } = setup({}); + const { asFragment } = await setup({}); const fragment = await waitFor(() => asFragment()); expect(fragment).toMatchSnapshot(); }); - it('Edit Compensation Button not displayed without claims', async () => { - const { queryByTitle } = setup({ + it('Displays the Comensation Requisition Header Information with Draft Status', async () => { + const mockCompensation = getMockApiDefaultCompensation(); + const { queryByTestId } = await setup({ + claims: [Claims.COMPENSATION_REQUISITION_VIEW], + props: { compensation: mockCompensation }, + }); + + const editButton = queryByTestId('compensation-client'); + expect(editButton).toHaveTextContent('034'); + + const compensationNumber = queryByTestId('compensation-number'); + expect(compensationNumber).toHaveTextContent('Draft'); + + const headerPreTaxAmount = queryByTestId('header-pretax-amount'); + expect(headerPreTaxAmount).toHaveTextContent('$0.00'); + + const headerTaxAmount = queryByTestId('header-tax-amount'); + expect(headerTaxAmount).toHaveTextContent('$0.00'); + + const headerTotalAmount = queryByTestId('header-total-amount'); + expect(headerTotalAmount).toHaveTextContent('$0.00'); + }); + + it('Displays the Comensation Requisition Header Information with Final Status', async () => { + const mockCompensation = getMockApiFinalCompensation(); + const { queryByTestId } = await setup({ + claims: [Claims.COMPENSATION_REQUISITION_VIEW], + props: { compensation: mockCompensation }, + }); + + const editButton = queryByTestId('compensation-client'); + expect(editButton).toHaveTextContent('034'); + + const compensationNumber = queryByTestId('compensation-number'); + expect(compensationNumber).toHaveTextContent('1'); + + const headerPreTaxAmount = queryByTestId('header-pretax-amount'); + expect(headerPreTaxAmount).toHaveTextContent('$30,000.00'); + + const headerTaxAmount = queryByTestId('header-tax-amount'); + expect(headerTaxAmount).toHaveTextContent('$1,500.00'); + + const headerTotalAmount = queryByTestId('header-total-amount'); + expect(headerTotalAmount).toHaveTextContent('$31,500.00'); + }); + + it('Edit Compensation Button not displayed without claims when is in "Draft" status', async () => { + const { queryByTitle } = await setup({ claims: [Claims.COMPENSATION_REQUISITION_VIEW], }); const editButton = queryByTitle('Edit compensation requisition'); - expect(editButton).toBeNull(); + expect(editButton).not.toBeInTheDocument(); }); - it('Can click on the Edit Compensation Button', async () => { - const { getByTitle } = setup({ + it('Can click on the Edit Compensation Button when is in "Draft" status', async () => { + const { getByTitle } = await setup({ claims: [Claims.COMPENSATION_REQUISITION_EDIT], }); const editButton = getByTitle('Edit compensation requisition'); expect(editButton).toBeVisible(); - act(() => userEvent.click(editButton)); - await waitFor(() => { - expect(setEditMode).toHaveBeenCalled(); + + await act(async () => userEvent.click(editButton)); + + expect(setEditMode).toHaveBeenCalled(); + }); + + it('User does not have the option to Edit Compensation when is in "FINAL" status', async () => { + const mockFinalCompensation = getMockApiFinalCompensation(); + const { queryByTitle } = await setup({ + claims: [Claims.COMPENSATION_REQUISITION_EDIT], + props: { compensation: mockFinalCompensation }, }); + + const editButton = queryByTitle('Edit compensation requisition'); + expect(editButton).not.toBeInTheDocument(); + }); + + it('Admin user should be able to Edit Compensation when is in "FINAL" status', async () => { + const mockFinalCompensation = getMockApiFinalCompensation(); + const { queryByTitle } = await setup({ + claims: [Claims.ADMIN_USERS], + props: { compensation: mockFinalCompensation }, + }); + + const editButton = queryByTitle('Edit compensation requisition'); + expect(editButton).toBeInTheDocument(); }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.tsx index 95ee89dfdf..4a087ca9b0 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/CompensationRequisitionDetailView.tsx @@ -26,7 +26,6 @@ export interface CompensationRequisitionDetailViewProps { acqFileProject?: Api_Project; acqFileProduct?: Api_Product | undefined; clientConstant: string; - gstConstant: number | undefined; loading: boolean; setEditMode: (editMode: boolean) => void; onGenerate: (compensation: Api_CompensationRequisition) => void; @@ -116,18 +115,28 @@ export const CompensationRequisitionDetailView: React.FunctionComponent< const payeeDetails = getPayeeDetails(compensationPayee); + const editButtonBlock = ( + { + setEditMode(true); + }} + /> + ); return ( - {setEditMode !== undefined && hasClaim(Claims.COMPENSATION_REQUISITION_EDIT) && ( - { - setEditMode(true); - }} - /> - )} + {setEditMode !== undefined && + compensation.isDraft && + hasClaim(Claims.COMPENSATION_REQUISITION_EDIT) && + editButtonBlock} + + {setEditMode !== undefined && + !compensation.isDraft && + hasClaim(Claims.ADMIN_USERS) && + editButtonBlock} + { onGenerate(compensation); @@ -140,21 +149,33 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
- + {clientConstant} - + {compensation.isDraft ? 'Draft' : compensation.id} - + {formatMoney(payeeDetails?.preTaxAmount ?? 0)} - + {formatMoney(payeeDetails?.taxAmount ?? 0)} - + {formatMoney(payeeDetails?.totalAmount ?? 0)} @@ -162,7 +183,7 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
- + {compensation.isDraft ? 'Draft' : 'Final'} diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap index 7a8bfa92ca..703b5186d3 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/detail/__snapshots__/CompensationRequisitionDetailView.test.tsx.snap @@ -180,6 +180,17 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` font-weight: bold; } +.c10 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + .c1 { display: -webkit-box; display: -webkit-flex; @@ -190,7 +201,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` flex-direction: row-reverse; } -.c11 { +.c12 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -210,7 +221,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` font-weight: 600; } -.c11 span { +.c12 span { margin-left: 1.25rem; } @@ -232,7 +243,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` padding-bottom: 1rem; } -.c10 { +.c11 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -252,14 +263,14 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` margin-bottom: 2rem; } -.c10 label { +.c11 label { font-family: 'BCSans-Bold'; font-size: 1.75rem; width: 100%; text-align: left; } -.c10 button { +.c11 button { margin-bottom: 1rem; } @@ -337,6 +348,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
Draft @@ -359,9 +371,10 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
- $0.00 + $30,000.00
@@ -377,9 +390,10 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
- $0.00 + $1,500.00
@@ -395,9 +409,10 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
- $0.00 + $31,500.00
@@ -748,7 +763,33 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
-
@@ -767,7 +808,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = `
- $0.00 + $30,000.00
- No + Yes +
+ +
+
+ +
+
+ $1,500.00
- $0.00 + $31,500.00
@@ -853,7 +912,7 @@ exports[`Compensation Detail View Component renders as expected 1`] = ` class="collapse show" >
diff --git a/source/frontend/src/mocks/compensations.mock.ts b/source/frontend/src/mocks/compensations.mock.ts index b522d3c2c8..19f712482d 100644 --- a/source/frontend/src/mocks/compensations.mock.ts +++ b/source/frontend/src/mocks/compensations.mock.ts @@ -1,3 +1,4 @@ +import { Api_CompensationPayee } from '@/models/api/CompensationPayee'; import { Api_CompensationRequisition } from '@/models/api/CompensationRequisition'; export const getMockApiDefaultCompensation = (): Api_CompensationRequisition => ({ @@ -116,6 +117,99 @@ export const getMockApiCompensation = (): Api_CompensationRequisition => ({ rowVersion: 1, }); +export const getMockApiFinalCompensation = (): Api_CompensationRequisition => ({ + id: 1, + acquisitionFileId: 2, + isDraft: false, + fiscalYear: '2023/2024', + yearlyFinancialId: 100, + yearlyFinancial: null, + chartOfAccountsId: 101, + chartOfAccounts: null, + responsibilityId: 102, + responsibility: null, + agreementDate: null, + expropriationNoticeServedDate: null, + expropriationVestingDate: null, + generationDate: null, + specialInstruction: 'SPECIAL INSTRUCTION', + detailedRemarks: 'DETAILED REMARKS', + isDisabled: false, + financials: [ + { + id: 1, + financialActivityCodeId: 2, + financialActivityCode: { + id: 2, + description: 'Market', + }, + compensationId: 1, + pretaxAmount: 10000.0, + isGstRequired: true, + taxAmount: 500.0, + totalAmount: 10500.0, + isDisabled: false, + appCreateTimestamp: '2023-06-12T17:57:08.397', + appLastUpdateTimestamp: '2023-06-13T15:39:31.167', + appLastUpdateUserid: 'JOHNDOE', + appCreateUserid: 'JOHNDOE', + appLastUpdateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + appCreateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + rowVersion: 1, + }, + { + id: 2, + financialActivityCodeId: 9, + financialActivityCode: { + id: 9, + description: 'Owners Entitlements', + }, + compensationId: 1, + pretaxAmount: 20000.0, + isGstRequired: true, + taxAmount: 1000.0, + totalAmount: 21000.0, + isDisabled: false, + appCreateTimestamp: '2023-06-12T17:57:35.28', + appLastUpdateTimestamp: '2023-06-13T15:39:31.167', + appLastUpdateUserid: 'JOHNDOE', + appCreateUserid: 'JOHNDOE', + appLastUpdateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + appCreateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + rowVersion: 8, + }, + ], + payees: [ + { + id: 1, + compensationRequisitionId: 1, + compensationRequisition: null, + isPaymentInTrust: true, + gstNumber: '9999', + ownerSolicitorId: 1, + ownerSolicitor: null, + acquisitionOwnerId: null, + acquisitionOwner: null, + interestHolderId: null, + interestHolder: null, + ownerRepresentativeId: null, + ownerRepresentative: null, + motiSolicitorId: null, + motiSolicitor: null, + acquisitionFilePersonId: null, + appCreateTimestamp: '2023-06-12T17:47:08.617', + appLastUpdateTimestamp: '2023-06-13T15:39:31.167', + appLastUpdateUserid: 'EHERRERA', + appCreateUserid: 'EHERRERA', + appLastUpdateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + appCreateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + rowVersion: 7, + isDisabled: false, + }, + ], + rowVersion: 1, +}); + export const getMockApiCompensationList = (): Api_CompensationRequisition[] => [ { id: 1, @@ -312,3 +406,48 @@ export const getMockApiCompensationList = (): Api_CompensationRequisition[] => [ rowVersion: 1, }, ]; + +export const getMockApiCompensationPayee = (): Api_CompensationPayee => ({ + id: 1, + compensationRequisitionId: 1, + compensationRequisition: null, + isPaymentInTrust: true, + gstNumber: '99999', + acquisitionOwnerId: null, + acquisitionOwner: null, + interestHolderId: null, + interestHolder: null, + ownerRepresentativeId: null, + ownerRepresentative: null, + motiSolicitorId: null, + motiSolicitor: null, + acquisitionFilePersonId: null, + ownerSolicitorId: 1, + ownerSolicitor: { + id: 1, + personId: 9, + acquisitionFileId: 2, + organizationId: 100, + organization: null, + person: { + id: 9, + isDisabled: false, + surname: 'Monga', + firstName: 'Aman', + personOrganizations: [], + personAddresses: [], + contactMethods: [], + rowVersion: 1, + }, + isDisabled: false, + rowVersion: 1, + }, + appCreateTimestamp: '2023-06-19T22:30:15.533', + appLastUpdateTimestamp: '2023-06-19T22:30:53.79', + appLastUpdateUserid: 'EHERRERA', + appCreateUserid: 'EHERRERA', + appLastUpdateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + appCreateUserGuid: '939a27d0-76cd-49b0-b474-53166adb73da', + rowVersion: 2, + isDisabled: false, +}); From a25d58bbcbc464eff5d333af07d6c036f5d50c72 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Wed, 21 Jun 2023 14:53:22 -0700 Subject: [PATCH 2/9] - fix tests --- ...eCompensationRequisitionContainer.test.tsx | 115 ++++++++++-------- 1 file changed, 64 insertions(+), 51 deletions(-) diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx index d430c011f9..fc0e912462 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx @@ -3,14 +3,20 @@ import { mockAcquisitionFileOwnersResponse, mockAcquisitionFileResponse, } from '@/mocks/acquisitionFiles.mock'; -import { getMockApiDefaultCompensation } from '@/mocks/compensations.mock'; +import { + getMockApiCompensation, + getMockApiDefaultCompensation, + getMockApiFinalCompensation, +} from '@/mocks/compensations.mock'; import { mockLookups } from '@/mocks/lookups.mock'; -import { Api_CompensationRequisition } from '@/models/api/CompensationRequisition'; import { lookupCodesSlice } from '@/store/slices/lookupCodes'; +import { systemConstantsSlice } from '@/store/slices/systemConstants/systemConstantsSlice'; import { act, render, RenderOptions } from '@/utils/test-utils'; import { CompensationRequisitionFormModel, PayeeOption } from './models'; -import UpdateCompensationRequisitionContainer from './UpdateCompensationRequisitionContainer'; +import UpdateCompensationRequisitionContainer, { + UpdateCompensationRequisitionContainerProps, +} from './UpdateCompensationRequisitionContainer'; import { CompensationRequisitionFormProps } from './UpdateCompensationRequisitionForm'; jest.mock('@/hooks/repositories/useRequisitionCompensationRepository'); @@ -79,6 +85,29 @@ jest.mock('@/hooks/repositories/useInterestHolderRepository', () => ({ }, })); +jest.mock('@/hooks/repositories/useFinancialCodeRepository', () => ({ + useInterestHolderRepository: () => { + return { + getFinancialActivityCodeTypes: { + execute: jest.fn(), + loading: false, + }, + getChartOfAccountsCodeTypes: { + execute: jest.fn(), + loading: false, + }, + getYearlyFinancialsCodeTypes: { + execute: jest.fn(), + loading: false, + }, + getResponsibilityCodeTypes: { + execute: jest.fn(), + loading: false, + }, + }; + }, +})); + const mockGetApi = { error: undefined, response: [], @@ -108,11 +137,12 @@ const onSuccess = jest.fn(); const onCancel = jest.fn(); describe('UpdateCompensationRequisition Container component', () => { - const setup = (renderOptions: RenderOptions = {}) => { - const utils = render( + const setup = async ( + renderOptions: RenderOptions & { props?: Partial } ) => { + const component = render( { { store: { [lookupCodesSlice.name]: { lookupCodes: mockLookups }, + [systemConstantsSlice.name]: { systemConstants: [{ name: 'GST', value: '5.0' }] }, }, useMockAuthentication: true, claims: renderOptions?.claims ?? [], @@ -128,7 +159,7 @@ describe('UpdateCompensationRequisition Container component', () => { ); return { - ...utils, + ...component, }; }; @@ -141,73 +172,55 @@ describe('UpdateCompensationRequisition Container component', () => { }); it('Renders the underlying form', async () => { - const { getByText } = setup(); + const { getByText } = await setup({}); expect(getByText(/Content Rendered/)).toBeVisible(); }); - it.skip('Calls onSuccess when the compensation is saved successfully', async () => { - setup(); - mockUpdateCompensation.mockResolvedValue(mockCompensation); + it('Calls onSuccess when the compensation is saved successfully', async () => { + const mockCompensationUpdate = getMockApiFinalCompensation(); + await setup({ + props: { compensation: mockCompensationUpdate }, + }); + mockUpdateCompensation.mockResolvedValue(mockCompensationUpdate); - let updatedCompensationModel = new CompensationRequisitionFormModel( - mockCompensation.id, - mockCompensation.acquisitionFileId, - ); - updatedCompensationModel.detailedRemarks = 'Remarks updated value'; - updatedCompensationModel.fiscalYear = '2022/2023'; - updatedCompensationModel.payeeKey = '1'; + const model = CompensationRequisitionFormModel.fromApi(mockCompensationUpdate); + model.detailedRemarks = 'Remarks updated value'; + model.fiscalYear = '2022/2023'; await act(async () => { - viewProps?.onSave(updatedCompensationModel); + viewProps?.onSave(model); }); expect(mockUpdateCompensation).toHaveBeenCalled(); expect(onSuccess).toHaveBeenCalled(); }); - it.skip('does not call onSucess if the returned value is invalid', async () => { - setup(); + it('does not call onSucess if the returned value is invalid', async () => { + const mockCompensationUpdate = getMockApiFinalCompensation(); mockUpdateCompensation.mockResolvedValue(undefined); - let updatedCompensationModel = new CompensationRequisitionFormModel( - mockCompensation.id, - mockCompensation.acquisitionFileId, - ); + await setup({ + props: { compensation: mockCompensationUpdate }, + }); + const model = CompensationRequisitionFormModel.fromApi(mockCompensationUpdate); + model.detailedRemarks = 'update'; await act(async () => { - await viewProps?.onSave(updatedCompensationModel); + await viewProps?.onSave(model); }); expect(mockUpdateCompensation).toHaveBeenCalled(); expect(onSuccess).not.toHaveBeenCalled(); }); - it.skip('makes request to update the compensation and returns the response', async () => { - setup(); - mockCompensation.detailedRemarks = 'my update'; - mockUpdateCompensation.mockResolvedValue(mockCompensation); - let updatedCompensation: Api_CompensationRequisition | undefined; - - let updatedCompensationModel = new CompensationRequisitionFormModel( - mockCompensation.id, - mockCompensation.acquisitionFileId, - ); - updatedCompensationModel.detailedRemarks = 'my update'; - updatedCompensationModel.payeeKey = '1'; - - await act(async () => { - updatedCompensation = await viewProps?.onSave(updatedCompensationModel); - }); - - expect(mockUpdateCompensation).toHaveBeenCalledWith(updatedCompensationModel.toApi([])); - expect(updatedCompensation).toStrictEqual(mockCompensation); - }); - it('makes request to update the compensation with payees', async () => { - await setup(); + const mockCompensationUpdate = getMockApiFinalCompensation(); + await setup({ + props: { compensation: mockCompensationUpdate }, + }); - mockCompensation.detailedRemarks = 'my update'; - mockUpdateCompensation.mockResolvedValue(mockCompensation); + mockCompensationUpdate.detailedRemarks = 'my update'; + mockUpdateCompensation.mockResolvedValue(mockCompensationUpdate); let updatedCompensationModel = new CompensationRequisitionFormModel( mockCompensation.id, From dcf05940c70cb3b97fc39fbfb0d799a6f7f66011 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Wed, 21 Jun 2023 14:54:52 -0700 Subject: [PATCH 3/9] - linting --- .../update/UpdateCompensationRequisitionContainer.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx index fc0e912462..cc577a8e36 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/compensation/update/UpdateCompensationRequisitionContainer.test.tsx @@ -138,7 +138,8 @@ const onCancel = jest.fn(); describe('UpdateCompensationRequisition Container component', () => { const setup = async ( - renderOptions: RenderOptions & { props?: Partial } ) => { + renderOptions: RenderOptions & { props?: Partial }, + ) => { const component = render( Date: Mon, 26 Jun 2023 11:51:27 -0700 Subject: [PATCH 4/9] PSP-5715 : Sec3/Sec6 add forms to acquisition file --- .../src/components/common/TabView.tsx | 3 - .../frontend/src/components/common/styles.ts | 2 +- .../tabs/AcquisitionFileTabs.test.tsx | 49 +++++++++++++++- .../acquisition/tabs/AcquisitionFileTabs.tsx | 22 ++++++- .../AcquisitionFileTabs.test.tsx.snap | 6 +- .../expropiation/ExpropiationTabContainer.tsx | 28 +++++++++ .../ExpropiationTabContainerView.test.tsx | 58 +++++++++++++++++++ .../ExpropiationTabContainerView.tsx | 35 +++++++++++ .../mapSideBar/shared/detail/FileTabs.tsx | 1 + .../src/models/api/AcquisitionFile.ts | 6 ++ 10 files changed, 199 insertions(+), 11 deletions(-) create mode 100644 source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainer.tsx create mode 100644 source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx create mode 100644 source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx diff --git a/source/frontend/src/components/common/TabView.tsx b/source/frontend/src/components/common/TabView.tsx index af9218627e..4d206d7e1f 100644 --- a/source/frontend/src/components/common/TabView.tsx +++ b/source/frontend/src/components/common/TabView.tsx @@ -15,9 +15,6 @@ const TabView: React.FunctionComponent< }; const StyledTabWrapper = styled.div` - .nav-tabs { - height: 2.4rem; - } .tab-content { .tab-pane { position: relative; diff --git a/source/frontend/src/components/common/styles.ts b/source/frontend/src/components/common/styles.ts index 24f047a89f..5134a500e5 100644 --- a/source/frontend/src/components/common/styles.ts +++ b/source/frontend/src/components/common/styles.ts @@ -86,7 +86,7 @@ export const Tabs = styled(BsTabs)` font-size: 1.4rem; border-color: transparent; .nav-tabs { - height: 2.4rem; + height: auto; } .nav-item { min-width: 5rem; diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx index 6442fd2025..a559481731 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx @@ -2,7 +2,7 @@ import { act } from 'react-test-renderer'; import Claims from '@/constants/claims'; import { mockAcquisitionFileResponse } from '@/mocks/acquisitionFiles.mock'; -import { render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; +import { queryByText, render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; import { FileTabType } from '../../shared/detail/FileTabs'; import AcquisitionFileTabs, { IAcquisitionFileTabsProps } from './AcquisitionFileTabs'; @@ -78,4 +78,51 @@ describe('AcquisitionFileTabs component', () => { expect(getByText('Documents')).toHaveClass('active'); }); }); + + it('hides the expropiation tab when the Acquisition file type is "Consensual Agreement"', () => { + const { queryByText } = setup({ + acquisitionFile: mockAcquisitionFileResponse(), + defaultTab: FileTabType.FILE_DETAILS, + setContainerState, + }); + + const expropiationButton = queryByText('Expropiation'); + expect(expropiationButton).not.toBeInTheDocument(); + }); + + it('shows the expropiation tab when the Acquisition file type is "Section 3"', () => { + const mockAcquisitionFile = mockAcquisitionFileResponse(); + mockAcquisitionFile.acquisitionTypeCode = { + id: 'SECTN3', + description: 'Section 3 Agreement', + isDisabled: false, + }; + + const { queryByText } = setup({ + acquisitionFile: mockAcquisitionFile, + defaultTab: FileTabType.FILE_DETAILS, + setContainerState, + }); + + const editButton = queryByText('Expropiation'); + expect(editButton).toBeInTheDocument(); + }); + + it('shows the expropiation tab when the Acquisition file type is "Section 6"', () => { + const mockAcquisitionFile = mockAcquisitionFileResponse(); + mockAcquisitionFile.acquisitionTypeCode = { + id: 'SECTN6', + description: 'Section 6 Expropriation', + isDisabled: false, + }; + + const { queryByText } = setup({ + acquisitionFile: mockAcquisitionFile, + defaultTab: FileTabType.FILE_DETAILS, + setContainerState, + }); + + const editButton = queryByText('Expropiation'); + expect(editButton).toBeInTheDocument(); + }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx index e556203150..145dbdda97 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx @@ -7,7 +7,7 @@ import { NoteTypes } from '@/constants/noteTypes'; import NoteListView from '@/features/notes/list/NoteListView'; import ActivityListView from '@/features/properties/map/activity/list/ActivityListView'; import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; -import { Api_AcquisitionFile } from '@/models/api/AcquisitionFile'; +import { Api_AcquisitionFile, EnumAcquisitionFileType } from '@/models/api/AcquisitionFile'; import { FileTabs, FileTabType, TabFileView } from '../../shared/detail/FileTabs'; import { AcquisitionContainerState } from '../AcquisitionContainer'; @@ -18,6 +18,8 @@ import { AcquisitionChecklistView } from './checklist/detail/AcquisitionChecklis import CompensationListContainer from './compensation/list/CompensationListContainer'; import CompensationListView from './compensation/list/CompensationListView'; import AcquisitionDocumentsTab from './documents/AcquisitionDocumentsTab'; +import ExpropiationTabContainer from './expropiation/ExpropiationTabContainer'; +import ExpropiationTabcontainerView from './expropiation/ExpropiationTabContainerView'; import AcquisitionSummaryView from './fileDetails/detail/AcquisitionSummaryView'; import StakeHolderContainer from './stakeholders/detail/StakeHolderContainer'; import StakeHolderView from './stakeholders/detail/StakeHolderView'; @@ -155,6 +157,24 @@ export const AcquisitionFileTabs: React.FC = ({ }); } + if ( + acquisitionFile?.id && + (acquisitionFile.acquisitionTypeCode?.id === EnumAcquisitionFileType.SECTN3 || + acquisitionFile.acquisitionTypeCode?.id === EnumAcquisitionFileType.SECTN6) + ) { + tabViews.push({ + content: ( + + ), + key: FileTabType.EXPROPIATION, + name: 'Expropiation', + }); + } + const onSetActiveTab = (tab: FileTabType) => { let previousTab = activeTab; setActiveTab(tab); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/__snapshots__/AcquisitionFileTabs.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/__snapshots__/AcquisitionFileTabs.test.tsx.snap index edf39014a9..748b6c41a7 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/__snapshots__/AcquisitionFileTabs.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/__snapshots__/AcquisitionFileTabs.test.tsx.snap @@ -176,7 +176,7 @@ exports[`AcquisitionFileTabs component matches snapshot 1`] = ` } .c1 .nav-tabs { - height: 2.4rem; + height: auto; } .c1 .nav-item { @@ -223,10 +223,6 @@ exports[`AcquisitionFileTabs component matches snapshot 1`] = ` height: 100%; } -.c0 .nav-tabs { - height: 2.4rem; -} - .c0 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainer.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainer.tsx new file mode 100644 index 0000000000..9dd317d214 --- /dev/null +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainer.tsx @@ -0,0 +1,28 @@ +import { useContext } from 'react'; + +import { SideBarContext } from '@/features/mapSideBar/context/sidebarContext'; + +import { IExpropiationTabcontainerViewProps } from './ExpropiationTabContainerView'; + +export interface IExpropiationTabContainer { + acquisitionFileId: number; + acquisitionFileTypeCode: string; + View: React.FunctionComponent>; +} + +export const ExpropiationTabContainer: React.FunctionComponent< + React.PropsWithChildren +> = ({ View, acquisitionFileTypeCode }) => { + const { file, fileLoading } = useContext(SideBarContext); + if (!!file && file?.id === undefined && fileLoading === false) { + throw new Error('Unable to determine id of current file.'); + } + + return !!file?.id ? ( + <> + + + ) : null; +}; + +export default ExpropiationTabContainer; diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx new file mode 100644 index 0000000000..fa2a4e94f5 --- /dev/null +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx @@ -0,0 +1,58 @@ +import { EnumAcquisitionFileType } from '@/models/api/AcquisitionFile'; +import { render, RenderOptions } from '@/utils/test-utils'; + +import ExpropiationTabcontainerView, { + IExpropiationTabcontainerViewProps, +} from './ExpropiationTabContainerView'; + +describe('Expropiatin Tab Container View', () => { + const setup = async ( + renderOptions: RenderOptions & { props?: Partial }, + ) => { + const utils = render( + , + { + ...renderOptions, + }, + ); + + return { + ...utils, + }; + }; + + afterEach(() => { + jest.clearAllMocks(); + }); + + it('displays a loading spinner when loading', async () => { + const { getByTestId } = await setup({ props: { loading: true } }); + const spinner = getByTestId('filter-backdrop-loading'); + expect(spinner).toBeVisible(); + }); + + it('shows the sections for Acquisition file type "Section 6"', async () => { + const { queryByTestId } = await setup({}); + expect(queryByTestId('form-1-section')).toBeInTheDocument(); + expect(queryByTestId('form-5-section')).toBeInTheDocument(); + expect(queryByTestId('form-8-section')).toBeInTheDocument(); + expect(queryByTestId('form-9-section')).toBeInTheDocument(); + }); + + it('shows the sections for Acquisition file type "Section 3"', async () => { + const { queryByTestId } = await setup({ + props: { acquisitionFileTypeCode: EnumAcquisitionFileType.SECTN3 }, + }); + + expect(queryByTestId('form-1-section')).not.toBeInTheDocument(); + expect(queryByTestId('form-5-section')).not.toBeInTheDocument(); + expect(queryByTestId('form-8-section')).toBeInTheDocument(); + expect(queryByTestId('form-9-section')).not.toBeInTheDocument(); + }); +}); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx new file mode 100644 index 0000000000..086386cd21 --- /dev/null +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx @@ -0,0 +1,35 @@ +import LoadingBackdrop from '@/components/common/LoadingBackdrop'; +import { Section } from '@/components/common/Section/Section'; +import { EnumAcquisitionFileType } from '@/models/api/AcquisitionFile'; + +export interface IExpropiationTabcontainerViewProps { + loading: boolean; + acquisitionFileTypeCode: string; +} + +export const ExpropiationTabcontainerView: React.FunctionComponent< + IExpropiationTabcontainerViewProps +> = ({ loading, acquisitionFileTypeCode }) => { + // TODO : Load created Forms + + return ( + <> + + {acquisitionFileTypeCode === EnumAcquisitionFileType.SECTN6 && ( +
+ )} + + {acquisitionFileTypeCode === EnumAcquisitionFileType.SECTN6 && ( +
+ )} + +
+ + {acquisitionFileTypeCode === EnumAcquisitionFileType.SECTN6 && ( +
+ )} + + ); +}; + +export default ExpropiationTabcontainerView; diff --git a/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx b/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx index ec9f312bfa..fe56ee3776 100644 --- a/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx +++ b/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx @@ -26,6 +26,7 @@ export enum FileTabType { AGREEMENTS = 'agreements', COMPENSATIONS = 'compensations', STAKEHOLDERS = 'stakeholders', + EXPROPIATION = 'expropiation', } /** * Tab wrapper, provides styling and nests form components within their corresponding tabs. diff --git a/source/frontend/src/models/api/AcquisitionFile.ts b/source/frontend/src/models/api/AcquisitionFile.ts index 3b74984610..e792e5bb87 100644 --- a/source/frontend/src/models/api/AcquisitionFile.ts +++ b/source/frontend/src/models/api/AcquisitionFile.ts @@ -11,6 +11,12 @@ import { Api_Person } from './Person'; import { Api_Product, Api_Project } from './Project'; import { Api_PropertyFile } from './PropertyFile'; +export enum EnumAcquisitionFileType { + CONSEN = 'CONSEN', + SECTN3 = 'SECTN3', + SECTN6 = 'SECTN6', +} + export interface Api_AcquisitionFile extends Api_ConcurrentVersion, Api_AuditFields, Api_File { id?: number; fileNo?: number; From e2620d707ffeff5ec83add0813c3105f6bdf8788 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Mon, 26 Jun 2023 11:53:22 -0700 Subject: [PATCH 5/9] - linting --- .../mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx index a559481731..c1ce1355fb 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx @@ -2,7 +2,7 @@ import { act } from 'react-test-renderer'; import Claims from '@/constants/claims'; import { mockAcquisitionFileResponse } from '@/mocks/acquisitionFiles.mock'; -import { queryByText, render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; +import { render, RenderOptions, userEvent, waitFor } from '@/utils/test-utils'; import { FileTabType } from '../../shared/detail/FileTabs'; import AcquisitionFileTabs, { IAcquisitionFileTabsProps } from './AcquisitionFileTabs'; From c923a80a7610187071e69283d55d5548ac396623 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Mon, 26 Jun 2023 14:21:54 -0700 Subject: [PATCH 6/9] - style update --- source/frontend/src/components/common/styles.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/source/frontend/src/components/common/styles.ts b/source/frontend/src/components/common/styles.ts index 5134a500e5..3c6f4c2957 100644 --- a/source/frontend/src/components/common/styles.ts +++ b/source/frontend/src/components/common/styles.ts @@ -93,6 +93,7 @@ export const Tabs = styled(BsTabs)` padding: 0.1rem 0.6rem; &:hover { + color: ${props => props.theme.css.secondaryVariantColor}; border-color: transparent; } &.active { From 7e57089a1309f95350ae30dee4f1b63728853166 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Mon, 26 Jun 2023 14:43:48 -0700 Subject: [PATCH 7/9] - linting --- source/backend/api/Services/CompensationRequisitionService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/source/backend/api/Services/CompensationRequisitionService.cs b/source/backend/api/Services/CompensationRequisitionService.cs index c6ffab3ac9..b55e4b3347 100644 --- a/source/backend/api/Services/CompensationRequisitionService.cs +++ b/source/backend/api/Services/CompensationRequisitionService.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; -using DocumentFormat.OpenXml.Office2010.Excel; using Microsoft.Extensions.Logging; using Pims.Core.Extensions; using Pims.Dal.Entities; From 7e96745261d4ce75b917aaaac1bbde9c45778bf0 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Mon, 26 Jun 2023 14:58:43 -0700 Subject: [PATCH 8/9] - tests updates --- .../MapSelectorContainer.test.tsx.snap | 6 +----- .../__snapshots__/AddLeaseContainer.test.tsx.snap | 6 +----- .../UpdateLeaseContainer.test.tsx.snap | 6 +----- .../__snapshots__/AcquisitionView.test.tsx.snap | 6 +----- .../AcquisitionPropertiesSubForm.test.tsx.snap | 6 +----- .../AddAcquisitionContainer.test.tsx.snap | 6 +----- .../__snapshots__/AddAcquisitionForm.test.tsx.snap | 6 +----- .../acquisition/tabs/AcquisitionFileTabs.test.tsx | 14 +++++++------- .../acquisition/tabs/AcquisitionFileTabs.tsx | 14 +++++++------- .../ExpropiationTabContainerView.test.tsx | 6 +++--- .../ExpropriationTabContainer.tsx} | 12 ++++++------ .../ExpropriationTabContainerView.tsx} | 8 ++++---- .../ProjectTabsContainer.test.tsx.snap | 6 +----- .../__snapshots__/ResearchContainer.test.tsx.snap | 6 +----- .../AddResearchContainer.test.tsx.snap | 6 +----- .../__snapshots__/AddResearchForm.test.tsx.snap | 6 +----- .../__snapshots__/ResearchProperties.test.tsx.snap | 6 +----- .../ResearchTabsContainer.test.tsx.snap | 6 +----- .../features/mapSideBar/shared/detail/FileTabs.tsx | 2 +- .../__snapshots__/UpdateProperties.test.tsx.snap | 6 +----- 20 files changed, 42 insertions(+), 98 deletions(-) rename source/frontend/src/features/mapSideBar/acquisition/tabs/{expropiation => expropriation}/ExpropiationTabContainerView.test.tsx (91%) rename source/frontend/src/features/mapSideBar/acquisition/tabs/{expropiation/ExpropiationTabContainer.tsx => expropriation/ExpropriationTabContainer.tsx} (59%) rename source/frontend/src/features/mapSideBar/acquisition/tabs/{expropiation/ExpropiationTabContainerView.tsx => expropriation/ExpropriationTabContainerView.tsx} (83%) diff --git a/source/frontend/src/components/propertySelector/__snapshots__/MapSelectorContainer.test.tsx.snap b/source/frontend/src/components/propertySelector/__snapshots__/MapSelectorContainer.test.tsx.snap index dc51ae4d50..a000bcb02d 100644 --- a/source/frontend/src/components/propertySelector/__snapshots__/MapSelectorContainer.test.tsx.snap +++ b/source/frontend/src/components/propertySelector/__snapshots__/MapSelectorContainer.test.tsx.snap @@ -169,7 +169,7 @@ exports[`MapSelectorContainer component renders as expected when provided no pro } .c2 .nav-tabs { - height: 2.4rem; + height: auto; } .c2 .nav-item { @@ -243,10 +243,6 @@ exports[`MapSelectorContainer component renders as expected when provided no pro height: 100%; } -.c0 .nav-tabs { - height: 2.4rem; -} - .c0 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/leases/add/__snapshots__/AddLeaseContainer.test.tsx.snap b/source/frontend/src/features/leases/add/__snapshots__/AddLeaseContainer.test.tsx.snap index 9bc9e71620..ac5ad7bca3 100644 --- a/source/frontend/src/features/leases/add/__snapshots__/AddLeaseContainer.test.tsx.snap +++ b/source/frontend/src/features/leases/add/__snapshots__/AddLeaseContainer.test.tsx.snap @@ -280,7 +280,7 @@ exports[`AddLeaseContainer component renders as expected 1`] = ` } .c11 .nav-tabs { - height: 2.4rem; + height: auto; } .c11 .nav-item { @@ -379,10 +379,6 @@ exports[`AddLeaseContainer component renders as expected 1`] = ` height: 100%; } -.c9 .nav-tabs { - height: 2.4rem; -} - .c9 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/UpdateLeaseContainer.test.tsx.snap b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/UpdateLeaseContainer.test.tsx.snap index f69425276e..993891d01d 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/UpdateLeaseContainer.test.tsx.snap +++ b/source/frontend/src/features/leases/detail/LeasePages/details/__snapshots__/UpdateLeaseContainer.test.tsx.snap @@ -251,7 +251,7 @@ exports[`Update lease container component renders as expected 1`] = ` } .c9 .nav-tabs { - height: 2.4rem; + height: auto; } .c9 .nav-item { @@ -347,10 +347,6 @@ exports[`Update lease container component renders as expected 1`] = ` height: 100%; } -.c7 .nav-tabs { - height: 2.4rem; -} - .c7 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap index 6580973f14..c7f96df33e 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap @@ -272,7 +272,7 @@ exports[`AcquisitionView component renders as expected 1`] = ` } .c12 .nav-tabs { - height: 2.4rem; + height: auto; } .c12 .nav-item { @@ -319,10 +319,6 @@ exports[`AcquisitionView component renders as expected 1`] = ` height: 100%; } -.c11 .nav-tabs { - height: 2.4rem; -} - .c11 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AcquisitionPropertiesSubForm.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AcquisitionPropertiesSubForm.test.tsx.snap index 7a8b2c28f7..5a4565a1c8 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AcquisitionPropertiesSubForm.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AcquisitionPropertiesSubForm.test.tsx.snap @@ -174,7 +174,7 @@ exports[`AcquisitionProperties component renders as expected 1`] = ` } .c2 .nav-tabs { - height: 2.4rem; + height: auto; } .c2 .nav-item { @@ -248,10 +248,6 @@ exports[`AcquisitionProperties component renders as expected 1`] = ` height: 100%; } -.c0 .nav-tabs { - height: 2.4rem; -} - .c0 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionContainer.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionContainer.test.tsx.snap index 5168f0621f..7d68a9ff1e 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionContainer.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionContainer.test.tsx.snap @@ -250,7 +250,7 @@ exports[`AddAcquisitionContainer component renders as expected 1`] = ` } .c12 .nav-tabs { - height: 2.4rem; + height: auto; } .c12 .nav-item { @@ -375,10 +375,6 @@ exports[`AddAcquisitionContainer component renders as expected 1`] = ` height: 100%; } -.c10 .nav-tabs { - height: 2.4rem; -} - .c10 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionForm.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionForm.test.tsx.snap index 0f1b019f6d..71e7c2be59 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionForm.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/add/__snapshots__/AddAcquisitionForm.test.tsx.snap @@ -181,7 +181,7 @@ exports[`AddAcquisitionForm component renders as expected 1`] = ` } .c9 .nav-tabs { - height: 2.4rem; + height: auto; } .c9 .nav-item { @@ -292,10 +292,6 @@ exports[`AddAcquisitionForm component renders as expected 1`] = ` height: 100%; } -.c7 .nav-tabs { - height: 2.4rem; -} - .c7 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx index c1ce1355fb..7ec371469f 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.test.tsx @@ -79,18 +79,18 @@ describe('AcquisitionFileTabs component', () => { }); }); - it('hides the expropiation tab when the Acquisition file type is "Consensual Agreement"', () => { + it('hides the expropriation tab when the Acquisition file type is "Consensual Agreement"', () => { const { queryByText } = setup({ acquisitionFile: mockAcquisitionFileResponse(), defaultTab: FileTabType.FILE_DETAILS, setContainerState, }); - const expropiationButton = queryByText('Expropiation'); - expect(expropiationButton).not.toBeInTheDocument(); + const expropriationButton = queryByText('Expropriation'); + expect(expropriationButton).not.toBeInTheDocument(); }); - it('shows the expropiation tab when the Acquisition file type is "Section 3"', () => { + it('shows the expropriation tab when the Acquisition file type is "Section 3"', () => { const mockAcquisitionFile = mockAcquisitionFileResponse(); mockAcquisitionFile.acquisitionTypeCode = { id: 'SECTN3', @@ -104,11 +104,11 @@ describe('AcquisitionFileTabs component', () => { setContainerState, }); - const editButton = queryByText('Expropiation'); + const editButton = queryByText('Expropriation'); expect(editButton).toBeInTheDocument(); }); - it('shows the expropiation tab when the Acquisition file type is "Section 6"', () => { + it('shows the expropriation tab when the Acquisition file type is "Section 6"', () => { const mockAcquisitionFile = mockAcquisitionFileResponse(); mockAcquisitionFile.acquisitionTypeCode = { id: 'SECTN6', @@ -122,7 +122,7 @@ describe('AcquisitionFileTabs component', () => { setContainerState, }); - const editButton = queryByText('Expropiation'); + const editButton = queryByText('Expropriation'); expect(editButton).toBeInTheDocument(); }); }); diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx index 145dbdda97..5371365304 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/AcquisitionFileTabs.tsx @@ -18,8 +18,8 @@ import { AcquisitionChecklistView } from './checklist/detail/AcquisitionChecklis import CompensationListContainer from './compensation/list/CompensationListContainer'; import CompensationListView from './compensation/list/CompensationListView'; import AcquisitionDocumentsTab from './documents/AcquisitionDocumentsTab'; -import ExpropiationTabContainer from './expropiation/ExpropiationTabContainer'; -import ExpropiationTabcontainerView from './expropiation/ExpropiationTabContainerView'; +import ExpropriationTabContainer from './expropriation/ExpropriationTabContainer'; +import ExpropriationTabcontainerView from './expropriation/ExpropriationTabContainerView'; import AcquisitionSummaryView from './fileDetails/detail/AcquisitionSummaryView'; import StakeHolderContainer from './stakeholders/detail/StakeHolderContainer'; import StakeHolderView from './stakeholders/detail/StakeHolderView'; @@ -164,14 +164,14 @@ export const AcquisitionFileTabs: React.FC = ({ ) { tabViews.push({ content: ( - + View={ExpropriationTabcontainerView} + > ), - key: FileTabType.EXPROPIATION, - name: 'Expropiation', + key: FileTabType.EXPROPRIATION, + name: 'Expropriation', }); } diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropiationTabContainerView.test.tsx similarity index 91% rename from source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx rename to source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropiationTabContainerView.test.tsx index fa2a4e94f5..cd9ecd4006 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.test.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropiationTabContainerView.test.tsx @@ -2,12 +2,12 @@ import { EnumAcquisitionFileType } from '@/models/api/AcquisitionFile'; import { render, RenderOptions } from '@/utils/test-utils'; import ExpropiationTabcontainerView, { - IExpropiationTabcontainerViewProps, -} from './ExpropiationTabContainerView'; + IExpropriationTabcontainerViewProps, +} from './ExpropriationTabContainerView'; describe('Expropiatin Tab Container View', () => { const setup = async ( - renderOptions: RenderOptions & { props?: Partial }, + renderOptions: RenderOptions & { props?: Partial }, ) => { const utils = render( >; + View: React.FunctionComponent>; } -export const ExpropiationTabContainer: React.FunctionComponent< - React.PropsWithChildren +export const ExpropriationTabContainer: React.FunctionComponent< + React.PropsWithChildren > = ({ View, acquisitionFileTypeCode }) => { const { file, fileLoading } = useContext(SideBarContext); if (!!file && file?.id === undefined && fileLoading === false) { @@ -25,4 +25,4 @@ export const ExpropiationTabContainer: React.FunctionComponent< ) : null; }; -export default ExpropiationTabContainer; +export default ExpropriationTabContainer; diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropriationTabContainerView.tsx similarity index 83% rename from source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx rename to source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropriationTabContainerView.tsx index 086386cd21..b924bc221d 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropiation/ExpropiationTabContainerView.tsx +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropriationTabContainerView.tsx @@ -2,13 +2,13 @@ import LoadingBackdrop from '@/components/common/LoadingBackdrop'; import { Section } from '@/components/common/Section/Section'; import { EnumAcquisitionFileType } from '@/models/api/AcquisitionFile'; -export interface IExpropiationTabcontainerViewProps { +export interface IExpropriationTabcontainerViewProps { loading: boolean; acquisitionFileTypeCode: string; } -export const ExpropiationTabcontainerView: React.FunctionComponent< - IExpropiationTabcontainerViewProps +export const ExpropriationTabcontainerView: React.FunctionComponent< + IExpropriationTabcontainerViewProps > = ({ loading, acquisitionFileTypeCode }) => { // TODO : Load created Forms @@ -32,4 +32,4 @@ export const ExpropiationTabcontainerView: React.FunctionComponent< ); }; -export default ExpropiationTabcontainerView; +export default ExpropriationTabcontainerView; diff --git a/source/frontend/src/features/mapSideBar/project/tabs/__snapshots__/ProjectTabsContainer.test.tsx.snap b/source/frontend/src/features/mapSideBar/project/tabs/__snapshots__/ProjectTabsContainer.test.tsx.snap index 6600ca8b72..1c354e1145 100644 --- a/source/frontend/src/features/mapSideBar/project/tabs/__snapshots__/ProjectTabsContainer.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/project/tabs/__snapshots__/ProjectTabsContainer.test.tsx.snap @@ -195,7 +195,7 @@ exports[`Project Tabs component matches snapshot 1`] = ` } .c1 .nav-tabs { - height: 2.4rem; + height: auto; } .c1 .nav-item { @@ -240,10 +240,6 @@ exports[`Project Tabs component matches snapshot 1`] = ` height: 100%; } -.c0 .nav-tabs { - height: 2.4rem; -} - .c0 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/research/__snapshots__/ResearchContainer.test.tsx.snap b/source/frontend/src/features/mapSideBar/research/__snapshots__/ResearchContainer.test.tsx.snap index e149a0b2b2..a5ed5916c5 100644 --- a/source/frontend/src/features/mapSideBar/research/__snapshots__/ResearchContainer.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/research/__snapshots__/ResearchContainer.test.tsx.snap @@ -8,7 +8,7 @@ exports[`ResearchContainer component renders as expected 1`] = ` } .c18 .nav-tabs { - height: 2.4rem; + height: auto; } .c18 .nav-item { @@ -115,10 +115,6 @@ exports[`ResearchContainer component renders as expected 1`] = ` height: 100%; } -.c17 .nav-tabs { - height: 2.4rem; -} - .c17 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchContainer.test.tsx.snap b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchContainer.test.tsx.snap index 3afcc8bbba..591e3e2f0f 100644 --- a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchContainer.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchContainer.test.tsx.snap @@ -250,7 +250,7 @@ exports[`AddResearchContainer component renders as expected 1`] = ` } .c15 .nav-tabs { - height: 2.4rem; + height: auto; } .c15 .nav-item { @@ -382,10 +382,6 @@ exports[`AddResearchContainer component renders as expected 1`] = ` height: 100%; } -.c13 .nav-tabs { - height: 2.4rem; -} - .c13 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchForm.test.tsx.snap b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchForm.test.tsx.snap index 7f1cdeb8aa..97a3e75799 100644 --- a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchForm.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/AddResearchForm.test.tsx.snap @@ -169,7 +169,7 @@ exports[`AddResearchForm component renders as expected 1`] = ` } .c12 .nav-tabs { - height: 2.4rem; + height: auto; } .c12 .nav-item { @@ -287,10 +287,6 @@ exports[`AddResearchForm component renders as expected 1`] = ` height: 100%; } -.c10 .nav-tabs { - height: 2.4rem; -} - .c10 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/ResearchProperties.test.tsx.snap b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/ResearchProperties.test.tsx.snap index e65c2f1303..8c3b34e0b9 100644 --- a/source/frontend/src/features/mapSideBar/research/add/__snapshots__/ResearchProperties.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/research/add/__snapshots__/ResearchProperties.test.tsx.snap @@ -221,7 +221,7 @@ exports[`ResearchProperties component renders as expected when provided no prope } .c4 .nav-tabs { - height: 2.4rem; + height: auto; } .c4 .nav-item { @@ -301,10 +301,6 @@ exports[`ResearchProperties component renders as expected when provided no prope height: 100%; } -.c2 .nav-tabs { - height: 2.4rem; -} - .c2 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/research/tabs/__snapshots__/ResearchTabsContainer.test.tsx.snap b/source/frontend/src/features/mapSideBar/research/tabs/__snapshots__/ResearchTabsContainer.test.tsx.snap index 9e7a40b0ac..f6c83dd520 100644 --- a/source/frontend/src/features/mapSideBar/research/tabs/__snapshots__/ResearchTabsContainer.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/research/tabs/__snapshots__/ResearchTabsContainer.test.tsx.snap @@ -203,7 +203,7 @@ exports[`ResearchFileTabs component matches snapshot 1`] = ` } .c1 .nav-tabs { - height: 2.4rem; + height: auto; } .c1 .nav-item { @@ -240,10 +240,6 @@ exports[`ResearchFileTabs component matches snapshot 1`] = ` height: 100%; } -.c0 .nav-tabs { - height: 2.4rem; -} - .c0 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); diff --git a/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx b/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx index fe56ee3776..7e53b90fae 100644 --- a/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx +++ b/source/frontend/src/features/mapSideBar/shared/detail/FileTabs.tsx @@ -26,7 +26,7 @@ export enum FileTabType { AGREEMENTS = 'agreements', COMPENSATIONS = 'compensations', STAKEHOLDERS = 'stakeholders', - EXPROPIATION = 'expropiation', + EXPROPRIATION = 'expropriation', } /** * Tab wrapper, provides styling and nests form components within their corresponding tabs. diff --git a/source/frontend/src/features/mapSideBar/shared/update/properties/__snapshots__/UpdateProperties.test.tsx.snap b/source/frontend/src/features/mapSideBar/shared/update/properties/__snapshots__/UpdateProperties.test.tsx.snap index 3873582131..9667550662 100644 --- a/source/frontend/src/features/mapSideBar/shared/update/properties/__snapshots__/UpdateProperties.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/shared/update/properties/__snapshots__/UpdateProperties.test.tsx.snap @@ -216,7 +216,7 @@ exports[`UpdateProperties component renders as expected 1`] = ` } .c6 .nav-tabs { - height: 2.4rem; + height: auto; } .c6 .nav-item { @@ -305,10 +305,6 @@ exports[`UpdateProperties component renders as expected 1`] = ` height: 100%; } -.c4 .nav-tabs { - height: 2.4rem; -} - .c4 .tab-content { border-radius: 0 0.4rem 0.4rem 0.4rem; height: calc(100% - 2.4rem); From 34445a7ceca598fd7c7b6ef4632cc60ecdace0a2 Mon Sep 17 00:00:00 2001 From: Eduardo Herrera Date: Mon, 26 Jun 2023 15:17:26 -0700 Subject: [PATCH 9/9] - fix name --- ...tainerView.test.tsx => ExpropriationTabContainerView.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/{ExpropiationTabContainerView.test.tsx => ExpropriationTabContainerView.test.tsx} (100%) diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropiationTabContainerView.test.tsx b/source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropriationTabContainerView.test.tsx similarity index 100% rename from source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropiationTabContainerView.test.tsx rename to source/frontend/src/features/mapSideBar/acquisition/tabs/expropriation/ExpropriationTabContainerView.test.tsx