-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle backend errors * use FailureModal in BackendErrorModal
- Loading branch information
Showing
8 changed files
with
124 additions
and
24 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 |
---|---|---|
|
@@ -34,6 +34,8 @@ type Args = { | |
isRPCNodeConnected: boolean | ||
hasRegisteredEmail: boolean | ||
hasBeenAskedForEmail: boolean | ||
subscribeEmailError: boolean | ||
confirmEmailError: boolean | ||
onBuyMembership: jest.Mock | ||
onTransfer: jest.Mock | ||
onSubscribeEmail: jest.Mock | ||
|
@@ -82,6 +84,8 @@ export default { | |
isRPCNodeConnected: true, | ||
hasRegisteredEmail: true, | ||
hasBeenAskedForEmail: true, | ||
subscribeEmailError: false, | ||
confirmEmailError: false, | ||
}, | ||
|
||
parameters: { | ||
|
@@ -141,12 +145,14 @@ export default { | |
{ | ||
mutation: RegisterBackendMemberDocument, | ||
onSend: (...sendArgs: any[]) => args.onSubscribeEmail(...sendArgs), | ||
data: { signup: '' }, | ||
data: !args.subscribeEmailError ? { signup: '' } : undefined, | ||
error: args.subscribeEmailError ? new Error('error') : undefined, | ||
}, | ||
{ | ||
mutation: ConfirmBackendEmailDocument, | ||
onSend: (...sendArgs: any[]) => args.onConfirmEmail(...sendArgs), | ||
data: { confirmEmail: '' }, | ||
data: !args.confirmEmailError ? { confirmEmail: '' } : undefined, | ||
error: args.confirmEmailError ? new Error('error') : undefined, | ||
}, | ||
], | ||
}, | ||
|
@@ -574,10 +580,34 @@ export const EmailSubscriptionModalSubscribe: Story = { | |
}, | ||
} | ||
|
||
export const EmailSubscriptionModalSubscribeError: Story = { | ||
args: { | ||
isLoggedIn: true, | ||
hasMemberships: true, | ||
hasAccounts: true, | ||
hasFunds: true, | ||
hasWallet: true, | ||
isRPCNodeConnected: true, | ||
hasRegisteredEmail: false, | ||
hasBeenAskedForEmail: false, | ||
subscribeEmailError: true, | ||
}, | ||
play: async ({ canvasElement }) => { | ||
const modal = withinModal(canvasElement) | ||
const button = modal.getByText(/^Sign and Authorize Email/i) | ||
expect(button.closest('button')).toBeDisabled() | ||
const testEmail = '[email protected]' | ||
await userEvent.type(modal.getByPlaceholderText('Add email for notifications here'), testEmail) | ||
await waitFor(() => expect(button.closest('button')).toBeEnabled()) | ||
await userEvent.click(button) | ||
await waitFor(() => expect(modal.getAllByText(/Unexpected error/i))) | ||
}, | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Test Email Confirmation Modal | ||
// ---------------------------------------------------------------------------- | ||
export const EmailConfirmationModal: Story = { | ||
export const EmailConfirmationSuccess: Story = { | ||
parameters: { router: { href: `/?${EMAIL_VERIFICATION_TOKEN_SEARCH_PARAM}=${MOCK_VERIFICATION_TOKEN}` } }, | ||
play: async ({ canvasElement, args: { onConfirmEmail } }) => { | ||
const modal = withinModal(canvasElement) | ||
|
@@ -589,3 +619,17 @@ export const EmailConfirmationModal: Story = { | |
expect(modal.getByText(/Your email has been confirmed/)) | ||
}, | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Email Confirmation Error | ||
// ---------------------------------------------------------------------------- | ||
export const EmailConfirmationError: Story = { | ||
args: { | ||
confirmEmailError: true, | ||
}, | ||
parameters: { router: { href: `/?${EMAIL_VERIFICATION_TOKEN_SEARCH_PARAM}=${MOCK_VERIFICATION_TOKEN}` } }, | ||
play: async ({ canvasElement }) => { | ||
const modal = withinModal(canvasElement) | ||
await waitFor(() => expect(modal.getAllByText(/Unexpected error/i))) | ||
}, | ||
} |
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
15 changes: 15 additions & 0 deletions
15
packages/ui/src/memberships/modals/BackendErrorModal/BackendErrorModal.tsx
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,15 @@ | ||
import React, { FC } from 'react' | ||
|
||
import { FailureModal } from '@/common/components/FailureModal' | ||
|
||
type BackendErrorModalProps = { | ||
onClose: () => void | ||
} | ||
|
||
export const BackendErrorModal: FC<BackendErrorModalProps> = ({ onClose }) => { | ||
return ( | ||
<FailureModal onClose={onClose}> | ||
There's been an unexpected error when communicating with notifications service. Please try again later. | ||
</FailureModal> | ||
) | ||
} |
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 @@ | ||
export * from './BackendErrorModal' |
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