AlphaWallet / alpha-wallet-ios

An advanced Ethereum/EVM mobile wallet
https://www.alphawallet.com
MIT License
584 stars 360 forks source link

Proposal to refactor Config for User Interface Testing #3726

Open eviltofu opened 2 years ago

eviltofu commented 2 years ago

Config needs to be able to

  1. Have it's own namespace for uiTesting (perhaps by adding ui-testing in front of the UserDefault keys.
  2. Create several sets of fixed Wallets for uiTesting.
  3. Passed from one coordinator to another instead of just creating it on the coordinator's init method.
hboon commented 2 years ago
  1. Passed from one coordinator to another instead of just creating it on the coordinator's init method

Definitely. We have removed many of these. But appears to have come back. Maybe a PR to get rid of these first? Might involve a number of files.

hboon commented 2 years ago
  1. Have it's own namespace for uiTesting (perhaps by adding ui-testing in front of the UserDefault keys.

Since Config mostly reads from UserDefaults [^1], maybe it's easier to just add a initializer init(defaults: UserDefaults), change Config to use it and pass in a different UserDefaults instance for tests?

[^1]: we should probably see if we can fix any values that aren't.

hboon commented 2 years ago

Actually, we are already halfway there: https://github.com/AlphaWallet/alpha-wallet-ios/blob/c98072d2771fe4f3d277c2e7e9a07916470a3663/AlphaWalletTests/Factories/Config.swift#L7

hboon commented 2 years ago

Maybe it's the static functions in Config which are the problem

hboon commented 2 years ago

@eviltofu do you have enough feedback from me?