fix: create correct defaults for packageContainerSettingsWithOverrides#1728
fix: create correct defaults for packageContainerSettingsWithOverrides#1728ianshade wants to merge 1 commit into
Conversation
WalkthroughA new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
meteor/server/migration/steps/X_X_X/__tests__/ContainerIdsToObjectWithOverridesMigrationStep.test.ts (1)
49-75: Consider adding a test for partially-present / empty legacy arrays.The two cases covered (both fields present and non-empty; both fields absent) exercise the endpoints of the new conditional logic in
ContainerIdsToObjectWithOverridesMigrationStep.migrate(), but they don't cover the "mixed" branches that theif (…length > 0)guards introduce:
- Only one of
previewContainerIds/thumbnailContainerIdsis present.- One of them is present but is an empty array
[](should be treated the same as missing — no override emitted).These branches are exactly the ones that distinguish the new implementation from the previous buggy one, so a small extra test would lock the fix in.
🧪 Example additional test
test('migration handles one old field empty and one populated', async () => { await setupMockStudio({ _id: protectString('studio2'), // `@ts-expect-error` previewContainerIds: [], thumbnailContainerIds: ['thumb1'], packageContainerSettingsWithOverrides: undefined as any, }) const step = new ContainerIdsToObjectWithOverridesMigrationStep() await step.migrate() const studio = await Studios.findOneAsync(protectString('studio2')) expect(studio?.packageContainerSettingsWithOverrides).toMatchObject({ defaults: { previewContainerIds: [], thumbnailContainerIds: [], }, overrides: [ { op: 'set', path: 'thumbnailContainerIds', value: ['thumb1'] }, ], }) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@meteor/server/migration/steps/X_X_X/__tests__/ContainerIdsToObjectWithOverridesMigrationStep.test.ts` around lines 49 - 75, Add a unit test covering the mixed legacy-array cases so the migration's conditional branches are exercised: create a new test in ContainerIdsToObjectWithOverridesMigrationStep.test.ts that uses setupMockStudio to seed a studio with one legacy field empty (e.g. previewContainerIds: []) and the other populated (e.g. thumbnailContainerIds: ['thumb1']), run new ContainerIdsToObjectWithOverridesMigrationStep().migrate(), then assert the resulting studio.packageContainerSettingsWithOverrides has defaults with empty arrays and an overrides array containing only the non-empty field (an op:'set' for thumbnailContainerIds). Ensure you also call validate() before/after if desired to mirror existing tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@meteor/server/migration/steps/X_X_X/__tests__/ContainerIdsToObjectWithOverridesMigrationStep.test.ts`:
- Around line 49-75: Add a unit test covering the mixed legacy-array cases so
the migration's conditional branches are exercised: create a new test in
ContainerIdsToObjectWithOverridesMigrationStep.test.ts that uses setupMockStudio
to seed a studio with one legacy field empty (e.g. previewContainerIds: []) and
the other populated (e.g. thumbnailContainerIds: ['thumb1']), run new
ContainerIdsToObjectWithOverridesMigrationStep().migrate(), then assert the
resulting studio.packageContainerSettingsWithOverrides has defaults with empty
arrays and an overrides array containing only the non-empty field (an op:'set'
for thumbnailContainerIds). Ensure you also call validate() before/after if
desired to mirror existing tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5c064b1f-7310-4ef7-bcae-ff2f95bbe3fa
📒 Files selected for processing (3)
meteor/server/migration/steps/X_X_X/ContainerIdsToObjectWithOverridesMigrationStep.tsmeteor/server/migration/steps/X_X_X/__tests__/ContainerIdsToObjectWithOverridesMigrationStep.test.tspackages/corelib/src/settings/objectWithOverrides.ts
About the Contributor
This pull request is posted on behalf of TV 2 Norge.
Type of Contribution
This is a:
Bug fix
Current Behavior
Migration might create an incorrect packageContainerSettingsWithOverrides object, which causes Package Manager and its settings section in Sofie to crash
New Behavior
Object created by the migration is type-correct
Testing
Affected areas
Migrations, Package Manager
Time Frame
Other Information
Status