File tree Expand file tree Collapse file tree
packages/fxa-settings/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { Meta } from '@storybook/react';
77import { withLocalization } from 'fxa-react/lib/storybooks' ;
88import PageRecoveryPhoneRemove from '.' ;
99import { LocationProvider } from '@reach/router' ;
10- import { mockAppContext } from '../../../models/mocks' ;
10+ import { mockAppContext , MOCK_ACCOUNT } from '../../../models/mocks' ;
1111import { Account , AppContext } from '../../../models' ;
1212
1313export default {
@@ -16,12 +16,20 @@ export default {
1616 decorators : [ withLocalization ] ,
1717} as Meta ;
1818
19+ const account = {
20+ ...MOCK_ACCOUNT ,
21+ recoveryPhone : {
22+ exists : true ,
23+ phoneNumber : '123-456-7890' ,
24+ available : true ,
25+ } ,
26+ removeRecoveryPhone : ( ) => true ,
27+ } as unknown as Account ;
28+
1929export const Default = ( ) => (
2030 < AppContext . Provider
2131 value = { mockAppContext ( {
22- account : {
23- removeRecoveryPhone : ( ) => { } ,
24- } as unknown as Account ,
32+ account,
2533 } ) }
2634 >
2735 < LocationProvider >
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ jest.mock('@reach/router', () => ({
4141} ) ) ;
4242
4343const account = {
44+ refresh : jest . fn ( ) ,
4445 removeRecoveryPhone : jest . fn ( ) . mockResolvedValue ( { } ) ,
4546 recoveryPhone : { phoneNumber : MOCK_FULL_PHONE_NUMBER } ,
4647} as unknown as Account ;
Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ const PageRecoveryPhoneRemove = (props: RouteComponentProps) => {
5454 const clickRemoveRecoveryPhone = useCallback ( async ( ) => {
5555 try {
5656 await account . removeRecoveryPhone ( ) ;
57-
57+ // get the latest status of recovery phone info and availability
58+ // ensure correct data is shown on the settings page
59+ // and that service availability is correctly checked against current location
60+ await account . refresh ( 'recoveryPhone' ) ;
5861 alertSuccessAndGoHome ( ) ;
5962 } catch ( e ) {
6063 const localizedError = getLocalizedErrorMessage ( ftlMsgResolver , e ) ;
Original file line number Diff line number Diff line change @@ -1392,22 +1392,6 @@ export class Account implements AccountData {
13921392 const result = await this . withLoadingStatus (
13931393 this . authClient . recoveryPhoneDelete ( sessionToken ( ) ! )
13941394 ) ;
1395-
1396- const cache = this . apolloClient . cache ;
1397- cache . modify ( {
1398- id : cache . identify ( { __typename : 'Account' } ) ,
1399- fields : {
1400- recoveryPhone ( ) {
1401- return {
1402- exists : false ,
1403- phoneNumber : null ,
1404- nationalFormat : null ,
1405- available : true ,
1406- } ;
1407- } ,
1408- } ,
1409- } ) ;
1410-
14111395 return result ;
14121396 }
14131397
You can’t perform that action at this time.
0 commit comments