-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web/react-native/ui): use translated strings and censorContactMet…
…hod for VerifyUser screen (#5034) * fix(vue): use translated strings for VerifyUser screen * Create cyan-taxis-explode.md * update test and snapshots * fix tests * undo test changes * Update usage of contactCensorInformation across angular, vue, react * update react-native usage of censorContactInformation * update changeset * More refactor of censorContactInformation -> censorContactMethod util * use radioField instead of checkboxField since they are radios * fix imports, use renamed censorContactMethod * update jest coverage :( * Update .changeset/cyan-taxis-explode.md * Update .changeset/cyan-taxis-explode.md * fix authenticator snapshot to show unverified attribute correctly * bring jest coverage back up with test for missing attribute value
- Loading branch information
Showing
12 changed files
with
198 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"@aws-amplify/ui": patch | ||
"@aws-amplify/ui-angular": patch | ||
"@aws-amplify/ui-react": patch | ||
"@aws-amplify/ui-react-native": patch | ||
"@aws-amplify/ui-vue": patch | ||
--- | ||
|
||
fix(web/react-native/ui): use translated strings for VerifyUser screen and use censorContactMethod util | ||
|
||
**ui/Angular/React/Vue/ReactNative:** adds a `censorContactMethod()` utility to the `ui` package and refactors the VerifyUser screen in Angular, React, Vue, and ReactNative packages to use this utility. | ||
|
||
**Vue:** Fixes an issue where translated strings were not being properly used for the VerifyUser screen. Additionally, removes duplicate "verify" id that was on multiple elements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { censorAllButFirstAndLast, censorPhoneNumber } from '..'; | ||
import { | ||
censorAllButFirstAndLast, | ||
censorContactMethod, | ||
censorEmail, | ||
censorPhoneNumber, | ||
} from '..'; | ||
|
||
describe('censorAllButFirstAndLast', () => { | ||
it('should only censor characters between the first and last indexes of a string', () => { | ||
|
@@ -53,3 +58,27 @@ describe('censorPhoneNumber', () => { | |
expect(phone6).toEqual('+12'); | ||
}); | ||
}); | ||
|
||
describe('censorEmail', () => { | ||
it('should return a censored email', () => { | ||
const censoredEmail = censorEmail('[email protected]'); | ||
expect(censoredEmail).toEqual('e*****[email protected]'); | ||
}); | ||
}); | ||
|
||
describe('censorContactMethod', () => { | ||
it('should return a censored phone number when passed type of Phone Number', () => { | ||
const censoredPhoneNumber = censorContactMethod( | ||
'Phone Number', | ||
'+11231234567' | ||
); | ||
expect(censoredPhoneNumber).toEqual('********4567'); | ||
}); | ||
it('should return a censored email when passed type of Email', () => { | ||
const censoredPhoneNumber = censorContactMethod( | ||
'Email', | ||
'[email protected]' | ||
); | ||
expect(censoredPhoneNumber).toEqual('e*****[email protected]'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1265,19 +1265,28 @@ exports[`authenticator renders verifyUser subcomponent 1`] = ` | |
> | ||
<label | ||
class="amplify-flex amplify-radio" | ||
data-amplify-label="" | ||
data-amplify-verify-label="" | ||
id="verify" | ||
> | ||
<span | ||
class="amplify-text amplify-radio__label" | ||
data-amplify-text="" | ||
> | ||
Email: t**[email protected] | ||
</span> | ||
<input | ||
aria-invalid="false" | ||
class="amplify-input amplify-field-group__control amplify-visually-hidden amplify-radio__input" | ||
data-amplify-input="" | ||
data-amplify-verify-input="" | ||
id="verify" | ||
name="unverifiedAttr" | ||
type="radio" | ||
value="email" | ||
|
@@ -1293,19 +1302,10 @@ exports[`authenticator renders verifyUser subcomponent 1`] = ` | |
</span> | ||
<span | ||
class="amplify-text amplify-radio__label" | ||
data-amplify-text="" | ||
> | ||
</span> | ||
</label> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,19 +44,28 @@ exports[`VerifyUser renders as expected 1`] = ` | |
> | ||
<label | ||
class="amplify-flex amplify-radio" | ||
data-amplify-label="" | ||
data-amplify-verify-label="" | ||
id="verify" | ||
> | ||
<span | ||
class="amplify-text amplify-radio__label" | ||
data-amplify-text="" | ||
> | ||
Email: t**[email protected] | ||
</span> | ||
<input | ||
aria-invalid="false" | ||
class="amplify-input amplify-field-group__control amplify-visually-hidden amplify-radio__input" | ||
data-amplify-input="" | ||
data-amplify-verify-input="" | ||
id="verify" | ||
name="unverifiedAttr" | ||
type="radio" | ||
value="email" | ||
|
@@ -72,19 +81,10 @@ exports[`VerifyUser renders as expected 1`] = ` | |
</span> | ||
<span | ||
class="amplify-text amplify-radio__label" | ||
data-amplify-text="" | ||
> | ||
</span> | ||
</label> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
AuthEvent, | ||
AuthInterpreter, | ||
AuthMachineState, | ||
UnverifiedUserAttributes, | ||
} from '@aws-amplify/ui'; | ||
|
||
import { components } from '../../../global-spec'; | ||
|
@@ -59,6 +60,10 @@ const setupState = { | |
matches: (state: string) => state === 'setup', | ||
} as unknown as AuthMachineState; | ||
|
||
const unverifiedUserAttributes: UnverifiedUserAttributes = { | ||
email: '[email protected]', | ||
}; | ||
|
||
const mockStateRef = ref(idleState) as unknown as Ref<AuthMachineState>; | ||
|
||
const sendSpy = jest.fn(); | ||
|
@@ -181,6 +186,7 @@ describe('authenticator', () => { | |
user, | ||
totpSecretCode: | ||
route === 'setupTotp' ? 'totp-mock-secret-code' : undefined, | ||
unverifiedUserAttributes, | ||
}) | ||
); | ||
|
||
|
Oops, something went wrong.