Skip to content

Conversation

@jost-s
Copy link
Contributor

@jost-s jost-s commented Feb 5, 2026

Adds sweettest tests when scaffolding link types.

part of #533

Summary by CodeRabbit

  • Tests

    • Added a comprehensive test suite covering link-type template scaffolding across multiple reference types, directions, and deletion scenarios.
    • Added automated coordinator zome integration tests to validate link creation, retrieval, and deletion flows.
    • Removed an obsolete vector-linked self-reference test.
  • Chores

    • Simplified the web app test script to run the Happ build step for faster test runs.

@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Walkthrough

Removes one entry-type test, adds a large link-type test module and a coordinator zome Handlebars test template, tweaks link-type scaffold no_spec filtering logic, and updates the web-app package.json test script to run build:happ.

Changes

Cohort / File(s) Summary
Entry-Type Tests
src/templates/entry_type/tests/common.rs
Deletes the vector_action_hash_linked_from_self_reference test block (24 lines removed).
Link-Type Template Logic
src/templates/link_type.rs
Adds a test-only module and modifies scaffold_link_type_templates no_spec filtering to retain both "tests" and "dnas" entries (adjusted condition).
Link-Type Tests
src/templates/link_type/tests.rs
Adds a comprehensive test module (~833 lines) exercising scaffolded link-type template generation across many Referenceable combinations and options (deletable, bidirectional).
Coordinator Zome Test Template
templates/generic/link-type/dnas/.../tests/... .hbs
Adds a Handlebars template (≈171 lines) for generated coordinator zome tests covering link creation, verification, optional deletion, and bidirectional behavior across hash types.
Web App Package
templates/generic/web-app/package.json.hbs
Changes the test script to invoke build:happ instead of the previous build:zomes + pack/test sequence.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • mattyg
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: removing/refactoring a test case and adding comprehensive new Rust tests for link-type functionality across multiple scenarios.
Docstring Coverage ✅ Passed Docstring coverage is 88.57% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/add-rust-test-for-links

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/templates/link_type.rs`:
- Around line 80-83: The retain predicate in the no_spec branch is wrong: using
k != "tests" || k != "dnas" is always true so nothing is removed. Change the
predicate to exclude both "tests" and "dnas" (e.g. k != "tests" && k != "dnas"
or !(k == "tests" || k == "dnas")) inside the closure passed to
link_type_template.dir_content_mut().map(|v| { v.retain(...); v }) so that
entries with keys "tests" or "dnas" are actually filtered out when no_spec is
true.

In `@src/templates/link_type/tests.rs`:
- Around line 113-118: The test is looking for generated test filenames using
kebab-case "-to-" (in the PathBuf format string inside the assertion that checks
scaffolded_template.file_tree via file_exists), but the template emits
snake_case "_to_" names; update the assertion(s) that build the expected path
(the string formatting using from_role and to_role_plural that currently
contains "-to-") to use "_to_" (snake_case) or normalize both sides
consistently; specifically change the path segment
"tests/{from_role}-to-{to_role_plural}.rs" to match the template's
"tests/{from_role}_to_{to_role_plural}.rs" for the assertions that reference
pluralize, to_role_plural, file_exists and scaffolded_template.file_tree.

@jost-s jost-s force-pushed the refactor/add-rust-test-for-links branch from 36a5742 to 37f7f2a Compare February 5, 2026 15:12
@jost-s jost-s force-pushed the refactor/add-rust-test-for-links branch from 37f7f2a to dba41e2 Compare February 5, 2026 15:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/templates/link_type/tests.rs`:
- Around line 131-159: The generated tests hardcode a hyphenated zome identifier
which produces invalid Rust; update the test_header function to use a
snake_cased zome name and update the Handlebars template usage of
coordinator_zome_manifest.name to apply the snake_case helper. Specifically, in
the Rust generator function test_header replace the hardcoded "test-zome"
occurrences with the snake-cased zome identifier used by the template, and in
the Handlebars template change any use of {{coordinator_zome_manifest.name}}
(and any places passed to zome(...)) to {{snake_case
coordinator_zome_manifest.name}} so the Rust module identifier is valid. Ensure
both the use ...:: and cells[...].zome("...") references use the same snake_case
name.

In
`@templates/generic/link-type/dnas/`{{dna_role_name}}/zomes/coordinator/{{coordinator_zome_manifest.name}}/tests/{{`#if`
to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural
to_referenceable.name)}}.rs{{¡if}}.hbs:
- Around line 1-8: The use statement currently imports the coordinator zome with
{{coordinator_zome_manifest.name}} which can produce invalid Rust identifiers if
the zome name contains hyphens; update the template so the crate/module
identifier is snake_case by changing the import to use the snake_cased
coordinator zome name (i.e., replace {{coordinator_zome_manifest.name}} with
{{snake_case coordinator_zome_manifest.name}}) in the line that reads use
{{coordinator_zome_manifest.name}}::{{snake_case
from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}::*;
so the generated Rust crate path is a valid snake_case identifier.
🧹 Nitpick comments (1)
templates/generic/link-type/dnas/{{dna_role_name}}/zomes/coordinator/{{coordinator_zome_manifest.name}}/tests/{{`#if` to_referenceable}}{{snake_case from_referenceable.name}}_to_{{snake_case (plural to_referenceable.name)}}.rs{{¡if}}.hbs (1)

41-44: Remove empty {{else}} block.

The empty else block on lines 43-44 serves no purpose and can be removed for cleaner template code.

♻️ Suggested cleanup
   {{`#if` (ne to_referenceable.hash_type "ExternalHash")}}
     let target_record = create_{{snake_case to_referenceable.name}}(&alice_conductor, &alice_zome).await;
-  {{else}}
   {{/if}}

@cocogitto-bot
Copy link

cocogitto-bot bot commented Feb 5, 2026

✔️ 8c0da1e...dba41e2 - Conventional commits check succeeded.

@jost-s jost-s requested review from a team February 5, 2026 16:06
Copy link
Member

@ThetaSinner ThetaSinner left a comment

Choose a reason for hiding this comment

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

Really liking the testing here

@jost-s jost-s merged commit 2d76c11 into main Feb 6, 2026
13 checks passed
@jost-s jost-s deleted the refactor/add-rust-test-for-links branch February 6, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants