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

feat(imports): Add minimal stubs useAuth and useAuthState imports #611

Closed
wants to merge 9 commits into from

Conversation

peterbud
Copy link

When nuxt-auth module is disabled (isEnabled=false) all #auth imports were failing. For mocking and testing this presented a situation which was impossible to handle properly. This commit adds a stub for these imports on the client side in case the nuxt-auth module is disabled, opening a way to mock the modules properly without worrying the missing imports.

Contributes to #454 #552 #596.

Checklist:

  • issue number linked above after pound (#)
    • replace "Closes " with "Contributes to" or other if this PR does not close the issue
  • manually checked my feature / checking not applicable
  • testing not applicable
  • attached screenshots / screenshot not applicable

WHne nuxt-auth module is disabled all #auth imports were failing. For mocking and testing this presented a situation which was impossible to handle properly. This commit adds a stub for these imports on the client side when the module is disabled, opening a way to mock the modules properly.
@zoey-kaiser
Copy link
Member

Hi @peterbud 👋

Thank you for your contribution! I think this is a really nice change, especially for testing suits! Do you think we may want to go one additional step and allow mocking of the composables? This way you could integrate e2e tests in a nicer way!

@peterbud
Copy link
Author

I think mocking would be possible, but I'm not sure what additional step you mean. Could you pls clarify?

@zoey-kaiser
Copy link
Member

I think mocking would be possible, but I'm not sure what additional step you mean. Could you pls clarify?

I wrote a lengthy comment on how we handle mocking stubs inside of our internal applications here: #596 (comment)

I also quickly touched on what would need to be done, to properly add mocking into our module.

@peterbud
Copy link
Author

Thanks for the great summary at the other issue. I think that mocking setup would be best covered by adding it to the playground/example. In this PR I don't see it feasible to add a mocking infrastructure, as this PR is focusing on ensuring that there is some stubs to import when the module is not enabled.

@zoey-kaiser
Copy link
Member

Hi @peterbud 👋

Thanks for the great summary at the other issue. I think that mocking setup would be best covered by adding it to the playground/example. In this PR I don't see it feasible to add a mocking infrastructure, as this PR is focusing on ensuring that there is some stubs to import when the module is not enabled.

Sounds good!

I wanted to let you know that I will upstream this PR to another colleague. Code wise I approve the changes, however I wanted to check with him, if this is how he would handle the isEnabled property. I expect him to get around in the next 2 weeks. Thank you for you patience!

@zoey-kaiser zoey-kaiser added p4 Important Issue enhancement An improvement that needs to be added labels Feb 23, 2024
@phoenix-ru
Copy link
Collaborator

@peterbud Could you please fix TS errors (simply add type modifier to imports)

@peterbud
Copy link
Author

peterbud commented Mar 4, 2024

Done

from: resolve('./runtime/composables/stub/useAuthState')
}
])
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you need to do a

if (!options.isEnabled) {
  return
}

before step 6?

Otherwise you end up adding runtime plugins and middleware, is this intended?

Copy link
Author

Choose a reason for hiding this comment

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

Look at line 157 pls.

@peterbud peterbud closed this Apr 7, 2024
@phoenix-ru
Copy link
Collaborator

@peterbud Could you please elaborate why this PR was closed?

@peterbud
Copy link
Author

Due to lack of progress. For 4 months there was no traction with this PR. I understand if maintainers are busy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added p4 Important Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

could not resolve import when module isEnabled = false
3 participants