From 32ee93a4a49f19c45004e8ce46994195704d7056 Mon Sep 17 00:00:00 2001 From: Alejandro Sanchez Date: Mon, 18 Nov 2024 21:12:59 -0800 Subject: [PATCH] PSP-9452: Split map search for PID PIN (#4480) * Lint fixes, remove dead code * Split map search for PID PIN * Test updates * Update backend filter models * Update EF queries * Test updates * Support adding DB views to PIMS testing DB context * Test updates * Code cleanup * PR feedback * Add proxy microservice to "make infra" command --- Makefile | 2 +- .../Property/Models/PropertyFilterModel.cs | 20 +- .../Extensions/PropertyViewExtensions.cs | 31 +- source/backend/dal/Models/PropertyFilter.cs | 23 +- .../dal/Repositories/PropertyRepository.cs | 12 +- source/backend/tests/core/DatabaseHelper.cs | 2 +- .../tests/core/Entities/PropertyHelper.cs | 11 + source/backend/tests/core/PimsTestContext.cs | 45 ++ .../Property/SearchControllerTest.cs | 2 +- .../Reports/PropertyControllerTest.cs | 2 +- .../unit/dal/Entities/PropertyFilterTest.cs | 9 +- .../PropertyActivityRepositoryTest.cs | 12 - .../Repositories/PropertyRepositoryTest.cs | 45 +- .../common/List/SelectInput.test.tsx | 18 +- .../__snapshots__/SelectInput.test.tsx.snap | 17 +- .../common/mapFSM/MapStateMachineContext.tsx | 12 +- .../propertyPicker/LeasePropertySelector.tsx | 5 +- .../properties/filter/IPropertyFilter.ts | 11 +- .../properties/filter/PropertyFilter.test.tsx | 382 +++++++++----- .../properties/filter/PropertyFilter.tsx | 24 +- .../filter/PropertySearchToggle.tsx | 2 + .../PropertyFilter.test.tsx.snap | 489 +++++++++++++++++- .../properties/list/PropertyListView.test.tsx | 44 +- .../PropertyListView.test.tsx.snap | 21 +- 24 files changed, 964 insertions(+), 277 deletions(-) create mode 100644 source/backend/tests/core/PimsTestContext.cs diff --git a/Makefile b/Makefile index 4edef774a5..2d7e52b738 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ refresh: | down build up ## Recreates local docker environment .PHONY: infra infra: ## Starts infrastructure containers (e.g. database, geoserver). Useful for local debugging @echo "$(P) Starting up infrastructure containers..." - @"$(MAKE)" start n="database geoserver grafana prometheus" + @"$(MAKE)" start n="database geoserver grafana prometheus proxy" start: ## Starts the local containers (n=service name) @echo "$(P) Starting client and server containers..." diff --git a/source/backend/api/Areas/Property/Models/PropertyFilterModel.cs b/source/backend/api/Areas/Property/Models/PropertyFilterModel.cs index c9370813cf..33989f9c0e 100644 --- a/source/backend/api/Areas/Property/Models/PropertyFilterModel.cs +++ b/source/backend/api/Areas/Property/Models/PropertyFilterModel.cs @@ -19,9 +19,14 @@ public class PropertyFilterModel : PageFilter public string Address { get; set; } /// - /// get/set - The pin or pid property identifier. + /// get/set - The pid property identifier. /// - public string PinOrPid { get; set; } + public string Pid { get; set; } + + /// + /// get/set - The pin property identifier. + /// + public string Pin { get; set; } /// /// get/set - The property plan number. @@ -87,7 +92,8 @@ public PropertyFilterModel(Dictionary - /// Convert to a ParcelFilter. + /// Convert to a PropertyFilter. /// /// public static explicit operator PropertyFilter(PropertyFilterModel model) @@ -109,7 +115,8 @@ public static explicit operator PropertyFilter(PropertyFilterModel model) Quantity = model.Quantity, Sort = model.Sort, - PinOrPid = model.PinOrPid, + Pid = model.Pid, + Pin = model.Pin, Address = model.Address, PlanNumber = model.PlanNumber, Historical = model.Historical, @@ -126,7 +133,8 @@ public static explicit operator PropertyFilter(PropertyFilterModel model) public override bool IsValid() { return base.IsValid() - || !string.IsNullOrWhiteSpace(PinOrPid) + || !string.IsNullOrWhiteSpace(Pid) + || !string.IsNullOrWhiteSpace(Pin) || !string.IsNullOrWhiteSpace(Historical) || !string.IsNullOrWhiteSpace(Address); } diff --git a/source/backend/dal/Helpers/Extensions/PropertyViewExtensions.cs b/source/backend/dal/Helpers/Extensions/PropertyViewExtensions.cs index ca0b520fba..542ca5f1af 100644 --- a/source/backend/dal/Helpers/Extensions/PropertyViewExtensions.cs +++ b/source/backend/dal/Helpers/Extensions/PropertyViewExtensions.cs @@ -1,4 +1,3 @@ - using System; using System.Linq; using System.Security.Claims; @@ -7,8 +6,6 @@ using Microsoft.EntityFrameworkCore; using Pims.Core.Extensions; using Pims.Dal.Entities; -using Pims.Core.Security; -using Entity = Pims.Dal.Entities; namespace Pims.Dal.Helpers.Extensions { @@ -25,10 +22,10 @@ public static class PropertyViewExtensions /// /// /// - public static IQueryable GeneratePropertyQuery(this PimsContext context, ClaimsPrincipal user, Entity.Models.PropertyFilter filter) + public static IQueryable GeneratePropertyQuery(this PimsContext context, ClaimsPrincipal user, Entities.Models.PropertyFilter filter) { - filter.ThrowIfNull(nameof(filter)); - filter.ThrowIfNull(nameof(user)); + ArgumentNullException.ThrowIfNull(filter, nameof(filter)); + ArgumentNullException.ThrowIfNull(user, nameof(user)); var query = context.PimsPropertyVws .AsNoTracking(); @@ -36,7 +33,7 @@ public static class PropertyViewExtensions var predicate = GenerateCommonPropertyQuery(context, user, filter); query = query.Where(predicate); - if (filter.Sort?.Any() == true) + if (filter.Sort is not null && filter.Sort.Length > 0) { query = query.OrderByProperty(true, filter.Sort); } @@ -54,22 +51,24 @@ public static class PropertyViewExtensions /// /// /// - private static ExpressionStarter GenerateCommonPropertyQuery(PimsContext context, ClaimsPrincipal user, Entity.Models.PropertyFilter filter) + private static ExpressionStarter GenerateCommonPropertyQuery(PimsContext context, ClaimsPrincipal user, Entities.Models.PropertyFilter filter) { - filter.ThrowIfNull(nameof(filter)); - filter.ThrowIfNull(nameof(user)); - - // Check if user has the ability to view sensitive properties. - var viewSensitive = user.HasPermission(Permissions.SensitiveView); + ArgumentNullException.ThrowIfNull(filter, nameof(filter)); + ArgumentNullException.ThrowIfNull(user, nameof(user)); var predicateBuilder = PredicateBuilder.New(p => true); - if (!string.IsNullOrWhiteSpace(filter.PinOrPid)) + if (!string.IsNullOrWhiteSpace(filter.Pid)) { // note - 2 part search required. all matches found by removing leading 0's, then matches filtered in subsequent step. This is because EF core does not support an lpad method. Regex nonInteger = new Regex("[^\\d]"); - var formattedPidPin = Convert.ToInt32(nonInteger.Replace(filter.PinOrPid, string.Empty)).ToString(); - predicateBuilder = predicateBuilder.And(p => EF.Functions.Like(p.Pid.ToString(), $"%{formattedPidPin}%") || EF.Functions.Like(p.Pin.ToString(), $"%{formattedPidPin}%")); + var formattedPid = Convert.ToInt32(nonInteger.Replace(filter.Pid, string.Empty)).ToString(); + predicateBuilder = predicateBuilder.And(p => EF.Functions.Like(p.Pid.ToString(), $"%{formattedPid}%")); + } + + if (!string.IsNullOrWhiteSpace(filter.Pin)) + { + predicateBuilder = predicateBuilder.And(p => EF.Functions.Like(p.Pin.ToString(), $"%{filter.Pin}%")); } if (!string.IsNullOrWhiteSpace(filter.Address)) { diff --git a/source/backend/dal/Models/PropertyFilter.cs b/source/backend/dal/Models/PropertyFilter.cs index fef39dafe8..57b7dd38e3 100644 --- a/source/backend/dal/Models/PropertyFilter.cs +++ b/source/backend/dal/Models/PropertyFilter.cs @@ -12,9 +12,14 @@ public class PropertyFilter : PageFilter #region Properties /// - /// get/set - The pin or pid property. + /// get/set - The pid property identifier. /// - public string PinOrPid { get; set; } + public string Pid { get; set; } + + /// + /// get/set - The pin property identifier. + /// + public string Pin { get; set; } /// /// get/set - The property address. @@ -58,10 +63,11 @@ public PropertyFilter(Dictionary(query, StringComparer.OrdinalIgnoreCase); - this.Address = filter.GetStringValue(nameof(this.Address)); - this.PinOrPid = filter.GetStringValue(nameof(this.PinOrPid)); - this.PlanNumber = filter.GetStringValue(nameof(this.PlanNumber)); - this.Ownership = filter.GetStringArrayValue(nameof(this.Ownership)); + Address = filter.GetStringValue(nameof(Address)); + Pid = filter.GetStringValue(nameof(Pid)); + Pin = filter.GetStringValue(nameof(Pin)); + PlanNumber = filter.GetStringValue(nameof(PlanNumber)); + Ownership = filter.GetStringArrayValue(nameof(Ownership)); } #endregion @@ -74,8 +80,9 @@ public PropertyFilter(Dictionary public Paged GetPage(PropertyFilter filter) { - this.User.ThrowIfNotAuthorized(Permissions.PropertyView); + User.ThrowIfNotAuthorized(Permissions.PropertyView); filter.ThrowIfNull(nameof(filter)); if (!filter.IsValid()) { @@ -64,17 +64,17 @@ public Paged GetPage(PropertyFilter filter) } var skip = (filter.Page - 1) * filter.Quantity; - var query = Context.GeneratePropertyQuery(this.User, filter); + var query = Context.GeneratePropertyQuery(User, filter); var items = query .Skip(skip) .Take(filter.Quantity) .ToArray(); - if (!string.IsNullOrWhiteSpace(filter.PinOrPid)) + if (!string.IsNullOrWhiteSpace(filter.Pid)) { Regex nonInteger = new Regex("[^\\d]"); - var formattedPidPin = nonInteger.Replace(filter.PinOrPid, string.Empty); - items = items.Where(i => i.Pid.ToString().PadLeft(9, '0').Contains(formattedPidPin) || i.Pin.ToString().Contains(formattedPidPin)).ToArray(); + var formattedPid = nonInteger.Replace(filter.Pid, string.Empty); + items = items.Where(i => i.Pid.ToString().PadLeft(9, '0').Contains(formattedPid)).ToArray(); } return new Paged(items, filter.Page, filter.Quantity, query.Count()); diff --git a/source/backend/tests/core/DatabaseHelper.cs b/source/backend/tests/core/DatabaseHelper.cs index 461b95dc83..728807a3a7 100644 --- a/source/backend/tests/core/DatabaseHelper.cs +++ b/source/backend/tests/core/DatabaseHelper.cs @@ -93,7 +93,7 @@ public static PimsContext CreatePimsContext(this TestHelper helper, string dbNam var serializerOptions = new Mock>(); helper.AddSingleton(serializerOptions); - var context = new PimsContext(options, contextAccessor.Object, serializerOptions.Object); + PimsContext context = new PimsTestContext(options, contextAccessor.Object, serializerOptions.Object); if (ensureDeleted) { diff --git a/source/backend/tests/core/Entities/PropertyHelper.cs b/source/backend/tests/core/Entities/PropertyHelper.cs index 3812b73ca0..e563bb637a 100644 --- a/source/backend/tests/core/Entities/PropertyHelper.cs +++ b/source/backend/tests/core/Entities/PropertyHelper.cs @@ -70,6 +70,7 @@ public static PimsPropertyVw CreatePropertyView(int pid, int? pin = null, PimsPr var property = new PimsPropertyVw() { PropertyId = pid, + Pid = pid, Pin = pin, IsRetired = false, PropertyTypeCode = type.PropertyTypeCode, @@ -126,9 +127,19 @@ public static PimsProperty CreateProperty(this PimsContext context, int pid, int public static PimsPropertyVw CreatePropertyView(this PimsContext context, int pid, int? pin = null, PimsPropertyType type = null, PimsAddress address = null, PimsPropertyTenureType tenure = null, PimsAreaUnitType areaUnit = null, PimsDataSourceType dataSource = null, PimsPropertyStatusType status = null, Geometry location = null, bool isRetired = false) { type ??= context.PimsPropertyTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property type."); + tenure ??= context.PimsPropertyTenureTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property tenure type."); + status ??= context.PimsPropertyStatusTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property status type."); + dataSource ??= context.PimsDataSourceTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property data source type."); + areaUnit ??= context.PimsAreaUnitTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find a property area unit type."); address ??= context.CreateAddress(pid, "12342 Test Street"); var property = CreatePropertyView(pid, pin, type, address); + property.Location = location; property.IsRetired = isRetired; + property.PropertyStatusTypeCode = status.PropertyStatusTypeCode; + property.PropertyDataSourceTypeCode = dataSource.DataSourceTypeCode; + property.PropertyTenureTypeCode = tenure.PropertyTenureTypeCode; + property.PropertyAreaUnitTypeCode = areaUnit.AreaUnitTypeCode; + context.PimsPropertyVws.Add(property); return property; } diff --git a/source/backend/tests/core/PimsTestContext.cs b/source/backend/tests/core/PimsTestContext.cs new file mode 100644 index 0000000000..4a9d21da30 --- /dev/null +++ b/source/backend/tests/core/PimsTestContext.cs @@ -0,0 +1,45 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using Pims.Dal; +using Pims.Dal.Entities; + +namespace Pims.Core.Test +{ + /// + /// PimsTestContext class, provides a data context to manage the datasource for the PIMS application (specific to UNIT TESTS). + /// + public class PimsTestContext : PimsContext + { + /// + /// Initializes a new instance of the class. + /// + public PimsTestContext() + : base() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The options. + /// Provides access to the current IHttpContextAccessor.HttpContext, if one is available. + /// The serializer options. + public PimsTestContext(DbContextOptions options, IHttpContextAccessor httpContextAccessor = null, IOptions serializerOptions = null) + : base(options, httpContextAccessor, serializerOptions) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + // This is needed so unit tests for DB Views work with in-memory DB + modelBuilder.Entity(entity => + { + entity.HasKey(x => x.PropertyId); + }); + } + } +} diff --git a/source/backend/tests/unit/api/Controllers/Property/SearchControllerTest.cs b/source/backend/tests/unit/api/Controllers/Property/SearchControllerTest.cs index f011110833..f85650d351 100644 --- a/source/backend/tests/unit/api/Controllers/Property/SearchControllerTest.cs +++ b/source/backend/tests/unit/api/Controllers/Property/SearchControllerTest.cs @@ -29,7 +29,7 @@ public class SearchControllerTest { new object [] { new PropertyFilterModel() }, new object [] { new PropertyFilterModel() { Address = "Address" } }, - new object [] { new PropertyFilterModel() { PinOrPid = "999999" } }, + new object [] { new PropertyFilterModel() { Pid = "999999" } }, }; public readonly static IEnumerable PropertyQueryFilters = new List() diff --git a/source/backend/tests/unit/api/Controllers/Reports/PropertyControllerTest.cs b/source/backend/tests/unit/api/Controllers/Reports/PropertyControllerTest.cs index 90f45a2f75..40bd88b24e 100644 --- a/source/backend/tests/unit/api/Controllers/Reports/PropertyControllerTest.cs +++ b/source/backend/tests/unit/api/Controllers/Reports/PropertyControllerTest.cs @@ -30,7 +30,7 @@ public class PropertyControllerTest { new object [] { new PropertyFilterModel() }, new object [] { new PropertyFilterModel() { Address = "Address" } }, - new object [] { new PropertyFilterModel() { PinOrPid = "999999" } }, + new object [] { new PropertyFilterModel() { Pid = "999999" } }, }; public static IEnumerable PropertyQueryFilters = new List() diff --git a/source/backend/tests/unit/dal/Entities/PropertyFilterTest.cs b/source/backend/tests/unit/dal/Entities/PropertyFilterTest.cs index 9fda60bffe..2cae0cda8b 100644 --- a/source/backend/tests/unit/dal/Entities/PropertyFilterTest.cs +++ b/source/backend/tests/unit/dal/Entities/PropertyFilterTest.cs @@ -23,14 +23,15 @@ public void PropertyFilter_Default_Constructor() // Assert filter.Page.Should().Be(1); filter.Quantity.Should().Be(10); - filter.PinOrPid.Should().BeNull(); + filter.Pid.Should().BeNull(); + filter.Pin.Should().BeNull(); } [Fact] public void PropertyFilter_Constructor_03() { // Arrange - var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery("?page=2&quantity=3&pinOrPid=323423&sort=one,two"); + var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery("?page=2&quantity=3&pid=323423&sort=one,two"); // Act var filter = new PropertyFilter(query); @@ -38,7 +39,7 @@ public void PropertyFilter_Constructor_03() // Assert filter.Page.Should().Be(2); filter.Quantity.Should().Be(3); - filter.PinOrPid.Should().Be("323423"); + filter.Pid.Should().Be("323423"); filter.Sort.Should().BeEquivalentTo(new[] { "one", "two" }); } @@ -47,7 +48,7 @@ public void PropertyFilter_Constructor_03() public void PropertyFilter_IsValid() { // Arrange - var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery("?pinOrPid=323423"); + var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery("?pid=323423"); var filter = new PropertyFilter(query); // Act diff --git a/source/backend/tests/unit/dal/Repositories/PropertyActivityRepositoryTest.cs b/source/backend/tests/unit/dal/Repositories/PropertyActivityRepositoryTest.cs index 9a8760dccf..796aa7fd14 100644 --- a/source/backend/tests/unit/dal/Repositories/PropertyActivityRepositoryTest.cs +++ b/source/backend/tests/unit/dal/Repositories/PropertyActivityRepositoryTest.cs @@ -18,18 +18,6 @@ public class PropertyActivityRepositoryTest { private TestHelper _helper; - #region Data - public static IEnumerable AllPropertyFilters => - new List - { - new object[] { new PropertyFilter() { PinOrPid = "111-111-111" }, 1 }, - new object[] { new PropertyFilter() { PinOrPid = "111" }, 2 }, - new object[] { new PropertyFilter() { Address = "12342 Test Street" }, 5 }, - new object[] { new PropertyFilter() { Page = 1, Quantity = 10 }, 6 }, - new object[] { new PropertyFilter(), 6 }, - }; - #endregion - public PropertyActivityRepositoryTest() { _helper = new TestHelper(); diff --git a/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs b/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs index 7d02c216c0..1718cf2ad0 100644 --- a/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs +++ b/source/backend/tests/unit/dal/Repositories/PropertyRepositoryTest.cs @@ -13,7 +13,6 @@ using Pims.Dal.Repositories; using Pims.Core.Security; using Xunit; -using Entity = Pims.Dal.Entities; namespace Pims.Dal.Test.Repositories { @@ -29,19 +28,18 @@ public class PropertyRepositoryTest public static IEnumerable AllPropertyFilters => new List { - new object[] { new PropertyFilter() { PinOrPid = "111-111-111" , Ownership = new List()}, 1 }, - new object[] { new PropertyFilter() { PinOrPid = "111" , Ownership = new List()}, 2 }, - new object[] { new PropertyFilter() { Address = "12342 Test Street" , Ownership = new List()}, 8 }, + new object[] { new PropertyFilter() { Pid = "111-111-111", Ownership = new List()}, 1 }, + new object[] { new PropertyFilter() { Pin = "99999", Ownership = new List()}, 1 }, + new object[] { new PropertyFilter() { Address = "12342 Test Street" , Ownership = new List()}, 6 }, new object[] { new PropertyFilter() { PlanNumber = "SP-89TTXY", Ownership = new List()}, 1 }, - new object[] { new PropertyFilter() { Page = 1, Quantity = 10 , Ownership = new List() }, 8 }, - new object[] { new PropertyFilter(), 8 }, - new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory" }}, 4 }, + new object[] { new PropertyFilter() { Page = 1, Quantity = 10 , Ownership = new List() }, 6 }, + new object[] { new PropertyFilter(), 6 }, + new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory" }}, 3 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isPropertyOfInterest" }}, 2 }, - new object[] { new PropertyFilter(){ Ownership = new List(){"isDisposed"}}, 1 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isRetired"}}, 2 }, new object[] { new PropertyFilter(){ Ownership = new List(){"isOtherInterest"}}, 1 }, - new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory", "isPropertyOfInterest"}}, 6 }, + new object[] { new PropertyFilter(){ Ownership = new List(){"isCoreInventory", "isPropertyOfInterest"}}, 5 }, }; #endregion @@ -92,8 +90,6 @@ public void GetPage_Properties_NotAuthorized() act.Should().Throw(); } - /* - // TODO: Figure out how to add DB views to the context [Theory] [MemberData(nameof(AllPropertyFilters))] public void GetPage_Properties(PropertyFilter filter, int expectedCount) @@ -104,19 +100,19 @@ public void GetPage_Properties(PropertyFilter filter, int expectedCount) using var init = helper.InitializeDatabase(user); - PimsPropertyLocationVw testProperty = null; + PimsPropertyVw testProperty = null; testProperty = init.CreatePropertyView(2); testProperty.IsOwned = true; - testProperty = init.CreatePropertyView(3, pin: 111); + testProperty = init.CreatePropertyView(3, pin: 99999); testProperty.IsOwned = false; + testProperty.HasActiveAcquisitionFile = true; testProperty = init.CreatePropertyView(4, address: init.PimsAddresses.FirstOrDefault()); testProperty.IsOwned = false; - - testProperty = init.CreatePropertyView(5, classification: init.PimsPropertyClassificationTypes.FirstOrDefault(c => c.PropertyClassificationTypeCode == "Core Operational")); - testProperty.IsOwned = false; + testProperty.HasActiveAcquisitionFile = true; + testProperty.IsOtherInterest = true; testProperty = init.CreatePropertyView(6, location: new NetTopologySuite.Geometries.Point(-123.720810, 48.529338)); testProperty.IsOwned = true; @@ -129,6 +125,7 @@ public void GetPage_Properties(PropertyFilter filter, int expectedCount) testProperty = init.CreatePropertyView(33333); testProperty.SurveyPlanNumber = "SP-89TTXY"; + testProperty.IsDisposed = true; testProperty = init.CreatePropertyView(44444); testProperty.IsRetired = true; @@ -142,11 +139,11 @@ public void GetPage_Properties(PropertyFilter filter, int expectedCount) var result = repository.GetPage(filter); // Assert - Assert.NotNull(result); - Assert.IsAssignableFrom>(result); - Assert.Equal(expectedCount, result.Total); + result.Should().NotBeNull(); + result.Should().BeAssignableTo>(); + result.Total.Should().Be(expectedCount); } - */ + #endregion #region Get @@ -687,7 +684,7 @@ public void Update_Property_Success_Not_Retired(string propertyDescription, int var property = EntityHelper.CreateProperty(1, isRetired: isRetired); _helper.AddAndSaveChanges(property); - var newValues = new Entity.PimsProperty(); + var newValues = new PimsProperty(); property.CopyValues(newValues); newValues.Pid = pid; @@ -706,7 +703,7 @@ public void Update_Property_Retired_Violation() var property = EntityHelper.CreateProperty(1, isRetired: true); _helper.AddAndSaveChanges(property); - var newValues = new Entity.PimsProperty(); + var newValues = new PimsProperty(); property.CopyValues(newValues); newValues.Pid = 200; @@ -867,7 +864,7 @@ public void Update_PropertyManagement_Success() var property = EntityHelper.CreateProperty(1); _helper.AddAndSaveChanges(property); - var newValues = new Entity.PimsProperty(); + var newValues = new PimsProperty(); property.CopyValues(newValues); newValues.AdditionalDetails = "test"; newValues.IsTaxesPayable = true; @@ -890,7 +887,7 @@ public void Update_PropertyManagement_ShouldUpdateManagementFieldsOnly() var property = EntityHelper.CreateProperty(1); _helper.AddAndSaveChanges(property); - var newValues = new Entity.PimsProperty(); + var newValues = new PimsProperty(); property.CopyValues(newValues); newValues.AdditionalDetails = "test"; newValues.IsTaxesPayable = true; diff --git a/source/frontend/src/components/common/List/SelectInput.test.tsx b/source/frontend/src/components/common/List/SelectInput.test.tsx index 222beba5ad..de70ed7b31 100644 --- a/source/frontend/src/components/common/List/SelectInput.test.tsx +++ b/source/frontend/src/components/common/List/SelectInput.test.tsx @@ -1,7 +1,7 @@ -import { render } from '@testing-library/react'; import { FormikContextType, useFormikContext } from 'formik'; import { IPropertyFilter } from '@/features/properties/filter/IPropertyFilter'; +import { render } from '@/utils/test-utils'; import { SelectInput } from './SelectInput'; @@ -16,15 +16,17 @@ describe('SelectInput tests', () => { const { asFragment } = render( field="searchBy" - defaultKey="pinOrPid" + defaultKey="pid" selectOptions={[ - { label: 'PID/PIN', key: 'pinOrPid', placeholder: 'Enter a PID or PIN' }, + { label: 'PID', key: 'pid', placeholder: 'Enter a PID' }, + { label: 'PIN', key: 'pin', placeholder: 'Enter a PIN' }, { label: 'Address', key: 'address', placeholder: 'Enter an address' }, ]} className="idir-input-group" @@ -37,15 +39,17 @@ describe('SelectInput tests', () => { const { container } = render( field="searchBy" - defaultKey="pinOrPid" + defaultKey="pid" selectOptions={[ - { label: 'PID/PIN', key: 'pinOrPid', placeholder: 'Enter a PID or PIN' }, + { label: 'PID', key: 'pid', placeholder: 'Enter a PID' }, + { label: 'PIN', key: 'pin', placeholder: 'Enter a PIN' }, { label: 'Address', key: 'address', placeholder: 'Enter an address' }, ]} className="idir-input-group" diff --git a/source/frontend/src/components/common/List/__snapshots__/SelectInput.test.tsx.snap b/source/frontend/src/components/common/List/__snapshots__/SelectInput.test.tsx.snap index 22b778cf8e..803e4326c9 100644 --- a/source/frontend/src/components/common/List/__snapshots__/SelectInput.test.tsx.snap +++ b/source/frontend/src/components/common/List/__snapshots__/SelectInput.test.tsx.snap @@ -2,6 +2,10 @@ exports[`SelectInput tests > renders correctly... 1`] = ` +
+
.c0 { padding-right: 0; } @@ -39,10 +43,17 @@ exports[`SelectInput tests > renders correctly... 1`] = ` > +