Conversation
### Description\nImplement unit tests for init auth feature.\n\n### Scenarios Tested\n- Email provider selection\n- Google provider selection and prompts\n- Actuate generating config
There was a problem hiding this comment.
Code Review
This pull request introduces a new test suite for the auth initialization feature, covering provider selection logic and configuration actuation. The review feedback focuses on improving code quality and test stability: specifically, it recommends avoiding unknown type casts to comply with the style guide, using explicit null handling for optional properties, increasing test coverage for the anonymous provider, and providing a dummy project directory when initializing the Config object to prevent environment-dependent side effects.
| describe("askQuestions", () => { | ||
| it("should handle email provider selection", async () => { | ||
| checkboxStub.resolves(["email"]); | ||
| const setup = { config: {} } as unknown as Setup; |
There was a problem hiding this comment.
The repository style guide (Line 38) prohibits using any or unknown as an escape hatch. Instead of double-casting to unknown, consider providing the minimum required properties for the Setup interface (such as rcfile and instructions) or using a more specific type if appropriate. This pattern is repeated in several places in this file (lines 40, 59, and 69).
References
- Never use any or unknown as an escape hatch. Define proper interfaces/types or use type guards. (link)
| expect(setup.featureInfo.auth.providers.emailPassword).to.be.true; | ||
| expect(setup.featureInfo.auth.providers.anonymous).to.be.undefined; |
There was a problem hiding this comment.
The repository style guide (Line 39) requires handling undefined/null explicitly. Since featureInfo is an optional property on the Setup interface, it should be accessed using a non-null assertion or optional chaining to satisfy strict null checks. This also applies to the assertions on lines 44-49 and 64.
| expect(setup.featureInfo.auth.providers.emailPassword).to.be.true; | |
| expect(setup.featureInfo.auth.providers.anonymous).to.be.undefined; | |
| expect(setup.featureInfo!.auth.providers.emailPassword).to.be.true; | |
| expect(setup.featureInfo!.auth.providers.anonymous).to.be.undefined; |
References
- Use strict null checks and handle undefined/null explicitly. (link)
| expect(setup.featureInfo.auth.providers.googleSignIn.supportEmail).to.equal( | ||
| "support@app.com", | ||
| ); | ||
| }); |
| auth: { providers: { emailPassword: true } }, | ||
| }, | ||
| } as unknown as Setup; | ||
| const config = new Config({}, {}); |
There was a problem hiding this comment.
Initializing Config without a projectDir in the options will trigger detectProjectRoot, which may have side effects or fail depending on the environment where tests are executed. It is recommended to provide a dummy projectDir to ensure test stability. This also applies to line 70.
| const config = new Config({}, {}); | |
| const config = new Config({}, { projectDir: "." }); |
Description\nImplement unit tests for init auth feature.\n\n### Scenarios Tested\n- Email provider selection\n- Google provider selection and prompts\n- Actuate generating config