Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Seedless Onboarding] Only continue to safe creation if login succeeds #2714

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/welcome/WelcomeLogin/WalletLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const WalletLogin = ({ onLogin }: { onLogin: () => void }) => {

const login = async () => {
const walletState = await connectWallet()
if (walletState) {

if (walletState && walletState.length > 0) {
onLogin()
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/components/welcome/WelcomeLogin/__tests__/WalletLogin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,27 @@ describe('WalletLogin', () => {
expect(mockOnLogin).toHaveBeenCalled()
})
})

it('should not invoke the callback if connection fails', async () => {
const mockOnLogin = jest.fn()
jest.spyOn(useConnectWallet, 'default').mockReturnValue(jest.fn().mockReturnValue([]))

const result = render(<WalletLogin onLogin={mockOnLogin} />)

await waitFor(() => {
expect(result.findByText('Connect wallet')).resolves.toBeDefined()
})

// We do not automatically invoke the callback as the user did not actively connect
expect(mockOnLogin).not.toHaveBeenCalled()

act(() => {
const button = result.getByRole('button')
button.click()
})

await waitFor(() => {
expect(mockOnLogin).not.toHaveBeenCalled()
})
})
})
Loading