Skip to content

Conversation

@jiexi
Copy link
Contributor

@jiexi jiexi commented Jun 11, 2024

Explanation

Cleans up / fixes some SelectedNetworkController specs

References

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2626

Changelog

No consumer facing changes

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@jiexi jiexi marked this pull request as ready for review June 11, 2024 22:39
@jiexi jiexi requested review from a team, adonesky1 and shanejonas June 11, 2024 22:39
shanejonas
shanejonas previously approved these changes Jun 18, 2024
Comment on lines 297 to 299
describe('networkController:stateChange', () => {
describe('when useRequestQueuePreference is false', () => {
describe('when a networkClient is deleted from the network controller state', () => {
Copy link
Contributor

@adonesky1 adonesky1 Jun 18, 2024

Choose a reason for hiding this comment

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

I did this originally, but while you're in here doing cleanup: I've received feedback elsewhere that having this many nested describes can be confusing. I think in this case the last one could be removed since it wraps only one test and you could rephrase the it block to it('does not update state when a networkClient is deleted from the network controller state')

Comment on lines 712 to 714
describe('PermissionController:stateChange', () => {
describe('on permission add', () => {
describe('when useRequestQueuePreference is true', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same point as above about nesting multiple describe blocks when the innermost one only wraps one test. I introduced similar patterns. I'm not personally too troubled about it but wonder what others feels about this @shanejonas @mcmire @Gudahtt ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with being cautious about nesting describe blocks too much. After 3 or 4 is where I start to get confused as well (looking back, I made this mistake while writing NetworkController tests and I would love to clean those up at some point).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

specs have been flattened where possible

b51a7ef


describe('Constructor checks for domains in permissions', () => {
describe('when useRequestQueuePreference is true', () => {
it('should set networkClientId for domains not already in state', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this test still valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

…roller.test.ts

Co-authored-by: Alex Donesky <adonesky@gmail.com>
jiexi and others added 6 commits June 18, 2024 10:29
…roller.test.ts

Co-authored-by: Alex Donesky <adonesky@gmail.com>
…roller.test.ts

Co-authored-by: Alex Donesky <adonesky@gmail.com>
…roller.test.ts

Co-authored-by: Alex Donesky <adonesky@gmail.com>
…roller.test.ts

Co-authored-by: Alex Donesky <adonesky@gmail.com>
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this much needed cleanup @jiexi!

@jiexi jiexi merged commit bcf4960 into main Jun 19, 2024
@jiexi jiexi deleted the jl/mmp-2626/audit-useRequestQueue branch June 19, 2024 17:32
mcmire pushed a commit that referenced this pull request Jun 20, 2024
Cleans up / fixes some `SelectedNetworkController` specs

Fixes: MetaMask/MetaMask-planning#2626

No consumer facing changes

- [x] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate

---------

Co-authored-by: Alex Donesky <adonesky@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants