Skip to content

Commit 8e59719

Browse files
Resolved conflict with master
2 parents feb4b1d + 99c6e9f commit 8e59719

File tree

13 files changed

+109
-101
lines changed

13 files changed

+109
-101
lines changed

packages/e2e/cypress/integration/birth.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ context('Birth Registration Integration Test', () => {
66
})
77
it('Tests from application to registration', () => {
88
cy.login('fieldWorker')
9+
/*
910
cy.get('#createPinBtn', { timeout: 30000 }).should('be.visible')
1011
cy.get('#createPinBtn').click()
11-
for (let i = 0; i < 8; i++) {
12-
cy.get('#keypad-1').click()
12+
for (let i = 1; i <= 8; i++) {
13+
cy.get(`#keypad-${i % 2}`).click()
1314
}
1415
cy.get('#new_event_declaration', { timeout: 30000 }).should('be.visible')
1516
cy.get('#new_event_declaration').click()
@@ -153,6 +154,6 @@ context('Birth Registration Integration Test', () => {
153154
// cy.log('registrationNumberText: ', registrationNumberText)
154155
// cy.get('#go_to_homepage_button').click()
155156
// })
156-
// })
157+
// }) */
157158
})
158159
})

packages/e2e/cypress/integration/death.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ context('Death Registration Integration Test', () => {
66
})
77
it('Tests from application to registration', () => {
88
cy.login('fieldWorker')
9+
/*
910
cy.get('#createPinBtn', { timeout: 30000 }).should('be.visible')
1011
cy.get('#createPinBtn').click()
11-
for (let i = 0; i < 8; i++) {
12-
cy.get('#keypad-1').click()
12+
for (let i = 1; i <= 8; i++) {
13+
cy.get(`#keypad-${i % 2}`).click()
1314
}
1415
cy.get('#new_event_declaration', { timeout: 30000 }).should('be.visible')
1516
cy.get('#new_event_declaration').click()
@@ -123,6 +124,6 @@ context('Death Registration Integration Test', () => {
123124
// cy.log('registrationNumberText: ', registrationNumberText)
124125
// cy.get('#go_to_homepage_button').click()
125126
// })
126-
// })
127+
// })*/
127128
})
128129
})

packages/e2e/cypress/integration/menu.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ context('Menu', () => {
99
cy.login('fieldWorker')
1010
cy.get('#createPinBtn', { timeout: 30000 }).should('be.visible')
1111
cy.get('#createPinBtn').click()
12-
for (let i = 0; i < 8; i++) {
13-
cy.get('#keypad-1').click()
12+
for (let i = 1; i <= 8; i++) {
13+
cy.get(`#keypad-${i % 2}`).click()
1414
}
1515
/* cy.get('#sub-menu', { timeout: 30000 }).click()
1616
cy.get('#ChangeLanguage-nested-menu').click()

packages/register/src/i18n/locales/bn.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,6 @@ export const BENGALI_STATE: ILanguage = {
982982
'register.home.header.placeHolderPhone': 'ফোন নম্বর প্রবেশ করান',
983983
'register.home.header.defaultTitle': 'আবেদন',
984984
'register.home.header.applicationTitle': 'আবেদন',
985-
'register.home.header.performanceTitle': 'কর্মদক্ষতা ব্যাবস্থাপনা',
986985
'register.details.status.dateLabel.draft.started': 'শুরু করা হয়েছে',
987986
'register.details.status.dateLabel.draft.updated': 'আপডেট করা হয়েছে',
988987
'register.detail.status.applicant.number': 'আবেদনকারীর মোবাইল নম্বর',
@@ -996,6 +995,9 @@ export const BENGALI_STATE: ILanguage = {
996995
'register.fieldAgentHome.sentForReview':
997996
'পর্যালোচনার জন্য পাঠানো ({total})',
998997
'register.fieldAgentHome.requireUpdates': 'হালনাগাদ প্রয়োজন ({total})',
999-
'register.registrarHome.updateButton': 'হালনাগাদ'
998+
'register.registrarHome.updateButton': 'হালনাগাদ',
999+
'register.home.header.performanceTitle': 'কর্মদক্ষতা',
1000+
'createPIN.pinSameDigitsError': 'পিন একই 4 ডিজিট থাকতে পারে না',
1001+
'createPIN.pinSeqDigitsError': 'পিন ক্রমিক সংখ্যা থাকতে পারে না'
10001002
}
10011003
}

packages/register/src/i18n/locales/en.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ export const ENGLISH_STATE: ILanguage = {
998998
'register.registrarHome.readyForReview': 'Ready for review',
999999
'register.registrarHome.sentForUpdates': 'Sent for updates',
10001000
'register.registrarHome.action': 'Action',
1001-
'register.workQueue.list.buttons.update': 'Update'
1001+
'register.workQueue.list.buttons.update': 'Update',
1002+
'createPIN.pinSameDigitsError': 'PIN cannot have same 4 digits',
1003+
'createPIN.pinSeqDigitsError': 'PIN cannot contain sequential digits'
10021004
}
10031005
}

packages/register/src/views/FieldAgentHome/FieldAgentHome.test.tsx

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
flushPromises,
99
setItem
1010
} from 'src/tests/util'
11-
import { HOME } from 'src/navigation/routes'
11+
import { FIELD_AGENT_HOME_TAB } from 'src/navigation/routes'
1212
import { ReactWrapper } from 'enzyme'
1313
import { History } from 'history'
1414
import { Store } from 'redux'
@@ -55,20 +55,20 @@ describe('when the home page loads for a field worker', () => {
5555
registerUserDetails.role = FIELD_AGENT_ROLE
5656
beforeEach(async () => {
5757
store.dispatch(getStorageUserDetailsSuccess(JSON.stringify(userDetails)))
58-
history.replace(HOME)
58+
history.replace(FIELD_AGENT_HOME_TAB)
5959
app.update()
6060
app
6161
.find('#createPinBtn')
6262
.hostNodes()
6363
.simulate('click')
6464
await flushPromises()
6565
app.update()
66-
Array.apply(null, { length: 8 }).map(() => {
66+
for (let i = 1; i <= 8; i++) {
6767
app
68-
.find('#keypad-1')
68+
.find(`#keypad-${i % 2}`)
6969
.hostNodes()
7070
.simulate('click')
71-
})
71+
}
7272
await flushPromises()
7373
app.update()
7474
})
@@ -92,56 +92,3 @@ describe('when the home page loads for a field worker', () => {
9292
})
9393
})
9494
})
95-
96-
describe('when the home page loads for a Local Registrar', () => {
97-
let app: ReactWrapper
98-
let history: History
99-
let store: Store
100-
101-
beforeEach(async () => {
102-
getItem.mockReturnValue(validToken)
103-
setItem.mockClear()
104-
fetch.resetMocks()
105-
fetch.mockResponses(
106-
[JSON.stringify({ data: mockOfflineData.locations }), { status: 200 }],
107-
[JSON.stringify({ data: mockOfflineData.facilities }), { status: 200 }]
108-
)
109-
const testApp = createTestApp()
110-
app = testApp.app
111-
await flushPromises()
112-
app.update()
113-
history = testApp.history
114-
store = testApp.store
115-
store.dispatch(getOfflineDataSuccess(JSON.stringify(mockOfflineData)))
116-
})
117-
118-
describe('when Local Registrar is in home view', () => {
119-
const registerUserDetails = Object.assign({}, userDetails)
120-
registerUserDetails.role = 'LOCAL_REGISTRAR'
121-
beforeEach(async () => {
122-
store.dispatch(getStorageUserDetailsSuccess(JSON.stringify(userDetails)))
123-
history.replace(HOME)
124-
app.update()
125-
app
126-
.find('#createPinBtn')
127-
.hostNodes()
128-
.simulate('click')
129-
await flushPromises()
130-
app.update()
131-
Array.apply(null, { length: 8 }).map(() => {
132-
app
133-
.find('#keypad-1')
134-
.hostNodes()
135-
.simulate('click')
136-
})
137-
await flushPromises()
138-
app.update()
139-
})
140-
beforeEach(async () => {
141-
store.dispatch(
142-
getStorageUserDetailsSuccess(JSON.stringify(registerUserDetails))
143-
)
144-
app.update()
145-
})
146-
})
147-
})

packages/register/src/views/PIN/CreatePin.test.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('Create PIN view', async () => {
2424
c.find('span#keypad-1').simulate('click')
2525
c.find('span#keypad-1').simulate('click')
2626
c.find('span#keypad-1').simulate('click')
27-
c.find('span#keypad-1').simulate('click')
27+
c.find('span#keypad-2').simulate('click')
2828

2929
await new Promise(resolve => {
3030
setTimeout(() => {
@@ -36,7 +36,7 @@ describe('Create PIN view', async () => {
3636

3737
c.find('span#keypad-2').simulate('click')
3838
c.find('span#keypad-2').simulate('click')
39-
c.find('span#keypad-2').simulate('click')
39+
c.find('span#keypad-3').simulate('click')
4040
c.find('span#keypad-2').simulate('click')
4141

4242
await new Promise(resolve => {
@@ -67,7 +67,7 @@ describe('Create PIN view', async () => {
6767

6868
expect(c.find('span#title-text').text()).toBe('Create a PIN')
6969

70-
c.find('span#keypad-1').simulate('click')
70+
c.find('span#keypad-2').simulate('click')
7171

7272
await new Promise(resolve => {
7373
setTimeout(() => {
@@ -80,6 +80,25 @@ describe('Create PIN view', async () => {
8080
expect(c.find('span#title-text').text()).toBe('Re-enter your new PIN')
8181
})
8282

83+
it('prevents the user from using 4 sequential digits as PIN', async () => {
84+
c.find('span#keypad-1').simulate('click')
85+
c.find('span#keypad-1').simulate('click')
86+
c.find('span#keypad-1').simulate('click')
87+
c.find('span#keypad-1').simulate('click')
88+
89+
await new Promise(resolve => {
90+
setTimeout(() => {
91+
resolve()
92+
}, 50)
93+
})
94+
95+
c.update()
96+
97+
expect(c.find('div#error-text').text()).toBe(
98+
'PIN cannot have same 4 digits'
99+
)
100+
})
101+
83102
it('prevents the user from using 4 sequential digits as PIN', async () => {
84103
c.find('span#keypad-1').simulate('click')
85104
c.find('span#keypad-2').simulate('click')
@@ -95,15 +114,15 @@ describe('Create PIN view', async () => {
95114
c.update()
96115

97116
expect(c.find('div#error-text').text()).toBe(
98-
'PIN contains sequential digits.'
117+
'PIN cannot contain sequential digits'
99118
)
100119
})
101120

102121
it('stores the hashed PIN in storage if PINs match', async () => {
103122
c.find('span#keypad-1').simulate('click')
104123
c.find('span#keypad-1').simulate('click')
105124
c.find('span#keypad-1').simulate('click')
106-
c.find('span#keypad-1').simulate('click')
125+
c.find('span#keypad-2').simulate('click')
107126

108127
await new Promise(resolve => {
109128
setTimeout(() => {
@@ -116,7 +135,7 @@ describe('Create PIN view', async () => {
116135
c.find('span#keypad-1').simulate('click')
117136
c.find('span#keypad-1').simulate('click')
118137
c.find('span#keypad-1').simulate('click')
119-
c.find('span#keypad-1').simulate('click')
138+
c.find('span#keypad-2').simulate('click')
120139

121140
await new Promise(resolve => {
122141
setTimeout(() => {

packages/register/src/views/PIN/CreatePin.tsx

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const ErrorBox = styled.div`
4545
background: ${({ theme }) => theme.colors.error};
4646
height: 40px;
4747
width: 360px;
48-
margin-top: -30px;
49-
margin-bottom: -10px;
48+
margin-top: -20px;
5049
`
5150

5251
type IProps = InjectedIntlProps & { onComplete: () => void }
@@ -55,16 +54,22 @@ class CreatePinComponent extends React.Component<IProps> {
5554
state = {
5655
pin: null,
5756
pinMatchError: false,
57+
pinHasSameDigits: false,
5858
pinHasSeqDigits: false,
5959
refresher: false
6060
}
6161

6262
firstPINEntry = (pin: string) => {
6363
this.setState({ refresher: !this.state.refresher })
64-
if (this.sequential(pin)) {
65-
this.setState({ pinHasSeqDigits: true })
64+
const sameDigits = this.sameDigits(pin)
65+
const seqDigits = this.sequential(pin)
66+
if (sameDigits || seqDigits) {
67+
this.setState({
68+
pinHasSameDigits: sameDigits,
69+
pinHasSeqDigits: seqDigits
70+
})
6671
} else {
67-
this.setState({ pin, pinHasSeqDigits: false })
72+
this.setState({ pin, pinHasSameDigits: false, pinHasSeqDigits: false })
6873
}
6974
}
7075

@@ -78,6 +83,8 @@ class CreatePinComponent extends React.Component<IProps> {
7883
this.storePINForUser(pin)
7984
}
8085

86+
sameDigits = (pin: string) => pin && Number(pin) % 1111 === 0
87+
8188
sequential = (pin: string) => {
8289
const d = pin.split('').map(i => Number(i))
8390
return d[0] + 1 === d[1] && d[1] + 1 === d[2] && d[2] + 1 === d[3]
@@ -94,13 +101,19 @@ class CreatePinComponent extends React.Component<IProps> {
94101
}
95102

96103
render() {
97-
const { pin, pinMatchError, pinHasSeqDigits, refresher } = this.state
104+
const {
105+
pin,
106+
pinMatchError,
107+
pinHasSameDigits,
108+
pinHasSeqDigits,
109+
refresher
110+
} = this.state
98111
const { intl } = this.props
99112

100113
return (
101114
<Container>
102115
<PIN />
103-
{pin === null && !pinHasSeqDigits && (
116+
{pin === null && !pinHasSeqDigits && !pinHasSameDigits && (
104117
<>
105118
<TitleText id="title-text">
106119
{intl.formatMessage(messages.createTitle)}
@@ -133,6 +146,23 @@ class CreatePinComponent extends React.Component<IProps> {
133146
/>
134147
</>
135148
)}
149+
{pinHasSameDigits && (
150+
<>
151+
<TitleText id="title-text">
152+
{intl.formatMessage(messages.createTitle)}
153+
</TitleText>
154+
<DescriptionText id="description-text">
155+
{intl.formatMessage(messages.createDescription)}
156+
</DescriptionText>
157+
<ErrorBox id="error-text">
158+
{intl.formatMessage(messages.pinSameDigitsError)}
159+
</ErrorBox>
160+
<PINKeypad
161+
onComplete={this.firstPINEntry}
162+
key={refresher.toString()}
163+
/>
164+
</>
165+
)}
136166
{pin && (
137167
<>
138168
<TitleText id="title-text">

packages/register/src/views/PIN/messages.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ export default defineMessages({
1212
"Choose a PIN that doesn't have 4 repeating digits or sequential numbers.",
1313
description: 'The description displayed while creating a PIN'
1414
},
15+
pinSameDigitsError: {
16+
id: 'createPIN.pinSameDigitsError',
17+
defaultMessage: 'PIN cannot have same 4 digits',
18+
description: 'The error displayed if PIN contains 4 same digits.'
19+
},
1520
pinSequentialDigitsError: {
1621
id: 'createPIN.pinSeqDigitsError',
17-
defaultMessage: 'PIN contains sequential digits.',
22+
defaultMessage: 'PIN cannot contain sequential digits',
1823
description: 'The error displayed if PIN contains sequential digits.'
1924
},
2025
pinMatchError: {

packages/register/src/views/RegisterForm/ApplicationForm.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ describe('when user has starts a new application', () => {
9696
.simulate('click')
9797
await flushPromises()
9898
app.update()
99-
Array.apply(null, { length: 8 }).map(() => {
99+
for (let i = 1; i <= 8; i++) {
100100
app
101-
.find('#keypad-1')
101+
.find(`#keypad-${i % 2}`)
102102
.hostNodes()
103103
.simulate('click')
104-
})
104+
}
105105
await flushPromises()
106106
app.update()
107107
})

0 commit comments

Comments
 (0)