diff --git a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.js b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.js index ed06fd55b2ec..3c23c51b850c 100644 --- a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.js +++ b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.js @@ -246,6 +246,7 @@ export default function PrivacySettings() { { handleIPFSChange(e.target.value); }} diff --git a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js index f91f1409dd26..1c8d8e29c8c7 100644 --- a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js +++ b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js @@ -23,6 +23,7 @@ describe('Privacy Settings Onboarding View', () => { const setUsePhishDetectStub = jest.fn(); const setUseTokenDetectionStub = jest.fn(); const setUseCurrencyRateCheckStub = jest.fn(); + const setIpfsGatewayStub = jest.fn(); const completeOnboardingStub = jest .fn() .mockImplementation(() => Promise.resolve()); @@ -33,6 +34,7 @@ describe('Privacy Settings Onboarding View', () => { setUsePhishDetect: setUsePhishDetectStub, setUseTokenDetection: setUseTokenDetectionStub, setUseCurrencyRateCheck: setUseCurrencyRateCheckStub, + setIpfsGateway: setIpfsGatewayStub, completeOnboarding: completeOnboardingStub, setUseMultiAccountBalanceChecker: setUseMultiAccountBalanceCheckerStub, }); @@ -95,4 +97,70 @@ describe('Privacy Settings Onboarding View', () => { ); expect(setUseCurrencyRateCheckStub.mock.calls[1][0]).toStrictEqual(true); }); + + describe('IPFS', () => { + it('should handle proper IPFS input', () => { + const { queryByTestId, queryByText } = renderWithProvider( + , + store, + ); + + const ipfsInput = queryByTestId('ipfs-input'); + const ipfsEvent = { + target: { + value: 'ipfs.io', + }, + }; + + fireEvent.change(ipfsInput, ipfsEvent); + + const validIpfsUrl = queryByText('IPFS gateway URL is valid'); + expect(validIpfsUrl).toBeInTheDocument(); + + const submitButton = queryByText('Done'); + fireEvent.click(submitButton); + + expect(setIpfsGatewayStub).toHaveBeenCalled(); + }); + + it('should error with gateway.ipfs.io IPFS input', () => { + const { queryByTestId, queryByText } = renderWithProvider( + , + store, + ); + + const ipfsInput = queryByTestId('ipfs-input'); + const ipfsEvent = { + target: { + value: 'gateway.ipfs.io', + }, + }; + + fireEvent.change(ipfsInput, ipfsEvent); + + const invalidErrorMsg = queryByText('Please enter a valid URL'); + + expect(invalidErrorMsg).toBeInTheDocument(); + }); + + it('should error with improper IPFS input', () => { + const { queryByTestId, queryByText } = renderWithProvider( + , + store, + ); + + const ipfsInput = queryByTestId('ipfs-input'); + const ipfsEvent = { + target: { + value: ' ', + }, + }; + + fireEvent.change(ipfsInput, ipfsEvent); + + const invalidErrorMsg = queryByText('Please enter a valid URL'); + + expect(invalidErrorMsg).toBeInTheDocument(); + }); + }); });