Skip to content

Commit

Permalink
feat: deprecate MyInfo fields for V3 (step 3 - drop support) (#1073)
Browse files Browse the repository at this point in the history
* feat: filter deprecated fields from admin panel

* feat: deprecate fields from types

* feat: deprecate fields from resources

* fix: remove deprecated from field formatting

* test: fix jest tests

* ref: clean up frontend filtering

* ref: clean up remaining frontend references
  • Loading branch information
mantariksh authored Feb 11, 2021
1 parent 20e14f8 commit ae451b3
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 651 deletions.
47 changes: 4 additions & 43 deletions src/app/services/myinfo/__tests__/myinfo.test.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const MOCK_MYINFO_DATA = {
classification: 'C',
nbr: '97324992',
},
mailadd: {
regadd: {
country: 'US',
unit: '',
street: '5TH AVENUE',
Expand All @@ -39,14 +39,6 @@ export const MOCK_MYINFO_DATA = {
}

export const MOCK_MYINFO_FORMAT_DATA = {
homeno: {
code: '65',
prefix: '+',
lastupdated: '2017-11-20',
source: '2',
classification: 'C',
nbr: '66132665',
},
mobileno: {
code: '65',
prefix: '+',
Expand All @@ -67,30 +59,6 @@ export const MOCK_MYINFO_FORMAT_DATA = {
floor: '09',
building: '',
},
mailadd: {
country: 'US',
unit: '',
street: '5TH AVENUE',
lastupdated: '2016-03-11',
block: '725',
source: '2',
postal: 'NY 10022',
classification: 'C',
floor: '',
building: 'TRUMP TOWER',
},
billadd: {
country: 'SG',
street: 'SERANGOON AVE 3',
lastupdated: '2016-03-11',
block: '329',
source: '1',
postal: '550329',
classification: 'C',
floor: '09',
unit: '360',
building: '',
},
workpassexpirydate: {
lastupdated: '2018-03-02',
source: '1',
Expand All @@ -116,13 +84,7 @@ export const MOCK_FORM_FIELDS = [
{
fieldType: 'textfield',
isVisible: true,
myInfo: { attr: 'homeno' },
_id: new ObjectId().toHexString(),
},
{
fieldType: 'textfield',
isVisible: true,
myInfo: { attr: 'mailadd' },
myInfo: { attr: 'regadd' },
_id: new ObjectId().toHexString(),
},
// Some non-MyInfo fields
Expand All @@ -133,22 +95,21 @@ export const MOCK_FORM_FIELDS = [
export const MOCK_HASHES = {
name: 'name',
mobileno: 'mobileno',
mailadd: 'mailadd',
regadd: 'regadd',
}

// Based on MOCK_FORM_FIELDS and MOCK_HASHES, only expect these attributes to
// be matched based on hashes. mobileno does not match because its isVisible is false,
// and homeno does not match because it does not have a hash.
export const MOCK_HASHED_FIELD_IDS = new Set(
MOCK_FORM_FIELDS.filter(
(field) => field.myInfo && ['name', 'mailadd'].includes(field.myInfo?.attr),
(field) => field.myInfo && ['name', 'regadd'].includes(field.myInfo?.attr),
).map((field) => field._id),
)

const populatedValues = [
{ fieldValue: 'TAN XIAO HUI', disabled: true },
{ fieldValue: '+65 97324992', disabled: false },
{ fieldValue: '', disabled: false },
{
fieldValue: 'TRUMP TOWER, 725 5TH AVENUE, UNITED STATES NY 10022',
disabled: false,
Expand Down
69 changes: 4 additions & 65 deletions src/app/services/myinfo/__tests__/myinfo.util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ describe('myinfo.util', () => {
})

describe('Phone numbers', () => {
it('should correctly return formatted home phone numbers if valid', () => {
// Arrange
// code: '65',
// prefix: '+',
// nbr: '66132665',
const expected = '+65 66132665'

// Act
const actual = getMyInfoValue(
'homeno' as MyInfoAttribute.HomeNo,
(MOCK_MYINFO_FORMAT_DATA as unknown) as IPersonBasic,
)

// Assert
expect(actual).toEqual(expected)
})

it('should correctly return formatted mobile phone numbers if valid', () => {
// Arrange
// code: '65',
Expand Down Expand Up @@ -102,60 +85,16 @@ describe('myinfo.util', () => {
expect(actual).toEqual(expected)
})

it('should correctly return formatted mailing addresses', () => {
// Arrange
// country: 'US',
// unit: '',
// street: '5TH AVENUE',
// lastupdated: '2016-03-11',
// block: '725',
// source: '2',
// postal: 'NY 10022',
// classification: 'C',
// floor: '',
// building: 'TRUMP TOWER',
const expected = 'TRUMP TOWER, 725 5TH AVENUE, UNITED STATES NY 10022'

// Act
const actual = getMyInfoValue(
'mailadd' as MyInfoAttribute.MailingAddress,
(MOCK_MYINFO_FORMAT_DATA as unknown) as IPersonBasic,
)

// Assert
expect(actual).toEqual(expected)
})

it('should correctly return formatted billing addresses', () => {
// Arrange
// country: 'SG',
// street: 'SERANGOON AVE 3',
// block: '329',
// postal: '550329',
// floor: '09',
// unit: '360',
const expected = '329 SERANGOON AVE 3, #09-360, SINGAPORE 550329'

// Act
const actual = getMyInfoValue(
'billadd' as MyInfoAttribute.BillingAddress,
(MOCK_MYINFO_FORMAT_DATA as unknown) as IPersonBasic,
)

// Assert
expect(actual).toEqual(expected)
})

it('should return empty string if address missing one of [block, street, country, postal] keys', () => {
// Arrange
const mockBillAdd = cloneDeep(MOCK_MYINFO_FORMAT_DATA.billadd)
mockBillAdd.block = ''
const mockAddress = cloneDeep(MOCK_MYINFO_FORMAT_DATA.regadd)
mockAddress.block = ''

// Act
const actual = getMyInfoValue(
'billadd' as MyInfoAttribute.BillingAddress,
'regadd' as MyInfoAttribute.RegisteredAddress,
({
billAdd: mockBillAdd,
regAdd: mockAddress,
} as unknown) as IPersonBasic,
)

Expand Down
3 changes: 0 additions & 3 deletions src/app/services/myinfo/myinfo.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ export const getMyInfoValue = (
switch (myInfoAttr) {
// Phone numbers
case MyInfoAttribute.MobileNo:
case MyInfoAttribute.HomeNo:
return formatPhoneNumber(myInfoData[myInfoAttr])
case MyInfoAttribute.RegisteredAddress:
case MyInfoAttribute.BillingAddress:
case MyInfoAttribute.MailingAddress:
return formatAddress(myInfoData[myInfoAttr])
default:
// Categorical data lookup
Expand Down
6 changes: 0 additions & 6 deletions src/config/ndi-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ export const FIELD_MAPPING = {
'housingtype',
'hdbtype',
'marital',
'edulevel',
'countryofmarriage',
'workpassstatus',
'householdincome',
'schoolname',
'occupation',
],
textfield: [
Expand All @@ -27,20 +25,16 @@ export const FIELD_MAPPING = {
'hanyupinyinaliasname',
'passportnumber',
'regadd',
'mailadd',
'billadd',
'employment',
'vehno',
'marriagecertno',
],
mobile: ['mobileno'],
homeno: ['homeno'],
date: [
'dob',
'passportexpirydate',
'marriagedate',
'divorcedate',
'workpassexpirydate',
],
number: ['gradyear'],
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ function fieldDirective(FormFields) {
function _getMyInfoPlaceholder(myInfoAttr, readOnly) {
if (readOnly) {
return ''
} else if (myInfoAttr === 'homeno') {
return '+65 6XXXXXXX'
} else if (myInfoAttr === 'mobileno') {
return '+65 9XXXXXXX'
}
Expand Down
6 changes: 0 additions & 6 deletions src/public/modules/forms/base/resources/icon-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const iconTypeMap = {
housingtype: 'bx bx-home-alt',
hdbtype: 'bx bx-home',
marital: 'bx bx-diamond',
edulevel: 'bx bx-book-bookmark',
countryofmarriage: 'bx bx-globe-alt',
workpassstatus: 'bx bx-task',
// householdincome: "",
Expand All @@ -40,9 +39,6 @@ const iconTypeMap = {
// secondaryrace: "",
passportnumber: 'bx bx-world',
regadd: 'bx bx-building',
mailadd: 'bx bx-newsletter',
billadd: 'bx bx-wallet',
schoolname: 'bx bx-book-open',
occupation: 'bx bx-briefcase',
employment: 'bx bx-contact',
vehno: 'bx bx-car',
Expand All @@ -51,10 +47,8 @@ const iconTypeMap = {
marriagedate: 'bx bx-calendar-check',
divorcedate: 'bx bx-calendar-x',
workpassexpirydate: 'bx bx-calendar-alt',
homeno: 'bx bx-phone',
mobileno: 'bx bx-mobile-alt',
marriagecertno: 'bx bx-award',
gradyear: 'bx bx-calendar',
}

module.exports = {
Expand Down
10 changes: 0 additions & 10 deletions src/public/modules/forms/services/form-fields.client.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,13 @@ function FormFields() {
case 'passportnumber':
return 'E1234567X'
case 'regadd':
case 'mailadd':
case 'billadd':
return '411 CHUA CHU KANG AVE 3, #12-3, SINGAPORE 238823'
case 'mobileno':
return '+65 98765432'
case 'homeno':
return '+65 65123456'
case 'edulevel':
return 'PRIMARY'
case 'schoolname':
return 'TECK WHYE PRIMARY SCHOOL'
case 'occupation':
return 'MANAGING DIRECTOR/CHIEF EXECUTIVE OFFICER'
case 'employment':
return 'PCK PTE LTD'
case 'gradyear':
return 1977
case 'marital':
return 'MARRIED'
case 'dob':
Expand Down
Loading

0 comments on commit ae451b3

Please sign in to comment.