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

Fix Tests since MWA is no longer autoselected #1021

Open
wants to merge 3 commits into
base: revert-1012
Choose a base branch
from

Conversation

alex-fung
Copy link
Contributor

No description provided.

Copy link
Collaborator

@jordaaash jordaaash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see how these changes "fix" the tests, but they do so in a way that breaks the intent of what we wanted to test in the first place, and also don't test the new behavior that we want to have with the changes this targets.

it('should not clear the stored wallet name', () => {
expect(localStorage.removeItem).not.toHaveBeenCalled();
it('should clear the stored wallet name', () => {
expect(localStorage.removeItem).toHaveBeenCalled();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I think the original intent of the test is correct -- the wallet disconnecting should NOT deselect the wallet or remove it from LocalStorage, because then autoconnect will be broken on reload.

Copy link
Contributor Author

@alex-fung alex-fung Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this true? AFAICT when using wallet adapter, autoconnect is not supposed to reload the last used wallet if disconnect was called

renderTest({});
expect(ref.current?.getWalletContextState().wallet?.adapter.name).toBe(SolanaMobileWalletAdapterWalletName);
expect(ref.current?.getWalletContextState().wallet?.adapter.name).toBe(undefined);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead tests need to be changed/added such that

  • If MWA (custom or default) is the only adapter, it should be selected by default.
  • If it's not the only adapter, no adapter should be selected by default.

I think this satisfies the intent of the new code this is targeting.

Comment on lines +329 to +336
beforeEach(async () => {
errorThrown = new WalletError('o no');
onError = jest.fn();
renderTest({ onError });
await act(async () => {
ref.current?.getWalletContextState().select(SolanaMobileWalletAdapterWalletName);
await Promise.resolve(); // Flush all promises in effects after calling `select()`.
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't make sense to me. MWA shouldn't be deselected after each test, given the comment following this one)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey sorry, not sure I totally follow – I don't think there's any selecting involved, the test is just to make sure that when the adapter emits an error, it expects onError to be called. or was the point of the test something different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants