Skip to content

[test]: verify needsSaved propagates from independent collection to p…#8258

Open
rijulpoudel wants to merge 7 commits into
mainfrom
issue-8241-2
Open

[test]: verify needsSaved propagates from independent collection to p…#8258
rijulpoudel wants to merge 7 commits into
mainfrom
issue-8241-2

Conversation

@rijulpoudel

@rijulpoudel rijulpoudel commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8241

Summary by CodeRabbit

  • Tests
    • Added coverage for independent resource change propagation in one-to-many relationships.
    • Verified that adding an independent child marks the parent as needing save while the new child remains unchanged.
    • Confirmed the parent returns to a saved state after saving.
    • Added checks that edits to independent child fields—and related dependent sub-record changes—also propagate to the parent and persist correctly after save.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added tests in resourceApi.test.ts for independent CollectionObject subviews under Accession, covering needsSaved propagation from child edits to the parent and persistence after saving.

Changes

Independent Collection needsSaved Propagation Test

Layer / File(s) Summary
needsSaved propagation test
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts
Sets up stubbed endpoints, creates an Accession with an independent CollectionObject collection, and verifies adding a child marks the parent needsSaved and clears after save.
save with independent subviews
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts
Adds helper-backed tests for editing an independent child field and a dependent sub-record, then confirms the parent is marked dirty and save preserves the in-memory edits.

Possibly related issues

  • specify/specify7#8250: Covers independent resource sub-record change propagation and save behavior, matching the new sub-record test coverage.
  • specify/specify7#8249: Covers independent resource field-change propagation and persistence after save, matching the new child-field test coverage.
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Automatic Tests ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Testing Instructions ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: tests for needsSaved propagation from an independent collection to its parent.
Linked Issues check ✅ Passed The added tests verify that independent collection changes propagate needsSaved to the parent, matching issue #8241.
Out of Scope Changes check ✅ Passed The changes are limited to test coverage for the linked needsSaved propagation behavior and do not introduce unrelated scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8241-2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts (1)

501-509: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider a companion assertion for remove() propagation.

Coverage here is add-only. A symmetric case (removing an item from the independent collection also triggers parent needsSaved) would round out regression coverage for #8241 with minimal extra setup, reusing the same fixtures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts`
around lines 501 - 509, Add a symmetric regression check in resourceApi.test.ts
alongside the existing independentCollection add coverage: reuse the same
fixtures to verify that calling remove() on an independent collection also
propagates saverequired so parentResource.needsSaved becomes true while the
removed resource itself is not marked needsSaved. Use the existing
independentCollection, parentResource, and Resource setup to keep the new
assertion minimal and consistent with the current add/remove behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts`:
- Around line 501-509: Add a symmetric regression check in resourceApi.test.ts
alongside the existing independentCollection add coverage: reuse the same
fixtures to verify that calling remove() on an independent collection also
propagates saverequired so parentResource.needsSaved becomes true while the
removed resource itself is not marked needsSaved. Use the existing
independentCollection, parentResource, and Resource setup to keep the new
assertion minimal and consistent with the current add/remove behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e18c4f2-2381-45b5-87c7-27afc8e5ef4f

📥 Commits

Reviewing files that changed from the base of the PR and between d31ec21 and c9eab50.

📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts

@rijulpoudel rijulpoudel requested a review from CarolineDenis July 6, 2026 16:24
rijulpoudel and others added 4 commits July 8, 2026 13:04
[test]: verify independent resource field changes propagate needsSave…
verify independent subview sub-record changes propagate needsSaved an…

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts (1)

517-589: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Tests look solid — well-structured and cover the issue #8241 objectives.

The setupParentWithIndependentCollection helper nicely reduces duplication, and both test cases verify propagation and persistence as intended.

One minor optional note: the as any casts for storeIndependent (lines 537, and also 496 in the first suite) are well-documented, but if storeIndependent is used more broadly in tests, adding it to the public TypeScript types would eliminate the need for these casts long-term.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts`
around lines 517 - 589, The tests are relying on `as any` casts to call
`storeIndependent`, which hides a typing gap in the public API. Update the
TypeScript types for `storeIndependent` (and any related resource/collection
interfaces used in `setupParentWithIndependentCollection` and the earlier suite)
so the method is available without casts, then remove the `as any` usages in
these tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts`:
- Around line 517-589: The tests are relying on `as any` casts to call
`storeIndependent`, which hides a typing gap in the public API. Update the
TypeScript types for `storeIndependent` (and any related resource/collection
interfaces used in `setupParentWithIndependentCollection` and the earlier suite)
so the method is available without casts, then remove the `as any` usages in
these tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2df6d622-48e6-471c-9e6b-91cde013db35

📥 Commits

Reviewing files that changed from the base of the PR and between c9eab50 and 0631bb0.

📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/DataModel/__tests__/resourceApi.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

[tests]: verify needsSaved propagates from independent collection to parent

2 participants