-
-
Notifications
You must be signed in to change notification settings - Fork 118
[tests] Make add-org tests robust #880 #1019
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
base: master
Are you sure you want to change the base?
[tests] Make add-org tests robust #880 #1019
Conversation
📝 WalkthroughWalkthroughThe PR modifies config/add-org.js to run interactive/script logic only when executed directly by adding a Sequence Diagram(s)(omitted) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)config/__tests__/add-org.test.js (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@config/add-org.js`:
- Around line 257-268: The module currently executes CLI logic unconditionally
by calling createConfigurationWithoutPrompts/createConfigurationWithPrompts
based on process.argv when the file is imported; wrap that argv-handling block
in a require.main === module guard so the CLI only runs when the file is
executed directly, allowing tests to import exported symbols
(createConfiguration, createConfigurationWithPrompts,
createConfigurationWithoutPrompts, prompts) without triggering prompts or
process.argv handling.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
client/components/login/__snapshots__/login.test.js.snapis excluded by!**/*.snapclient/components/password-reset/__snapshots__/password-reset.test.js.snapis excluded by!**/*.snapclient/components/registration/__snapshots__/registration.test.js.snapis excluded by!**/*.snapclient/components/status/__snapshots__/status.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
client/components/status/status.test.jsclient/test-translation.jsonconfig/__tests__/add-org.test.jsconfig/add-org.jsi18n/en.poscripts/generate-test-translations.js
🧰 Additional context used
🧬 Code graph analysis (1)
config/__tests__/add-org.test.js (1)
config/add-org.js (3)
require(4-4)require(6-6)fs(1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Tests and Coverage
🔇 Additional comments (6)
client/test-translation.json (1)
12-591: LGTM — updated translation map looks consistent.The expanded key set and msgstr values match the updated translations structure.
i18n/en.po (1)
460-478: LGTM — grammar fixes read well.client/components/status/status.test.js (1)
1501-1510: LGTM — expectation now matches the user-facing message.config/__tests__/add-org.test.js (2)
5-58: LGTM — stronger --noprompt coverage with disk assertion and timeout.
72-86: LGTM — duplicate-slug case now validates created file and uses a timeout.scripts/generate-test-translations.js (1)
1-83: This parser is appropriate for the en.po file format.The en.po file contains only simple
msgid/msgstrpairs and does not includemsgid_plural,msgstr[n], ormsgctxtentries. The parser correctly handles the actual file structure and will not drop any data.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
d5068f2 to
17a4803
Compare
0da9585 to
e958a9f
Compare
nemesifier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you mixing commits from #1018 ?
Previously, the tests only checked the exit status of the command, which passed even when createConfiguration() was commented out. Now the tests verify that: 1. The organization config file is actually created 2. The file contains the correct data (name, slug, etc.) 3. This ensures tests will fail if createConfiguration() is accidentally removed or commented out, protecting against regression. Fixes openwisp#880
e958a9f to
d24ef35
Compare
|
@nemesifier sorry both fixed now . #1019 - Cleaned up, only #880 changes (2 files).#1018 - Separate PR for #902 translations. Please review both when free.Thanks |
nemesifier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what's the point of this PR. I don't see new tests being added. The diff doesn't show significant changes, I am really puzzled.
| expect(result.stderr).toMatch(/already exists/); | ||
| }); | ||
|
|
||
| it("runs interactively and creates config (smoke test)", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nemesifier Sorry for the confusion . i didn't new tests - i added assertions to existing tests. Specifically, in the " prevents duplicate organization slugs" test, i added expect(fs.existsSync(testOrgConfig)).toBe(true); after the first creation succeeds.this verifies createConfiguration actually created the file before testing the duplicate check. the smoke test wasn't removed - i accidentally messed up the file while cleaning git history earlier , but it's back now. the point is to catch cases where createConfiguration might be commented out or broken (issue #880).Before, tests only checked exit codes, not whether files were acually created. Learning git workflows as i go - thanks for bearing with me .
Added fs.existsSync assertion in duplicate slug test to verify createConfiguration actually creates files. Fixes openwisp#880
d24ef35 to
0114212
Compare
|
@nemesifier : review |
Checklist
Description
Issue #880 reported that tests passed even when
createConfiguration(response)was commented out, meaning the tests weren't actually verifying the core functionality.Changes Made
Enhanced assertions in
config/__tests__/add-org.test.jsto verify:fs.existsSync)Added detailed comments explaining the verification logic
Verification
Tested by temporarily commenting out
createConfiguration(response)inadd-org.js:Uncommented the line back and all tests pass.
Fixes #880