Merge pull request #719 from cbcoutinho/fix/contacts-create-dropped-fields-716
fix(contacts): persist all documented fields on create (fixes #716)
This commit is contained in:
@@ -24,6 +24,9 @@ async def test_mcp_contacts_workflow(
|
||||
"fn": f"MCP Contact {unique_suffix}",
|
||||
"email": f"mcp.contact.{unique_suffix}@example.com",
|
||||
"tel": "1234567890",
|
||||
# Regression for issue #716 — these were silently dropped before
|
||||
"organization": "MCP Test Corp",
|
||||
"note": f"Created by test {unique_suffix}",
|
||||
}
|
||||
|
||||
try:
|
||||
@@ -51,9 +54,31 @@ async def test_mcp_contacts_workflow(
|
||||
)
|
||||
assert create_c_result.isError is False
|
||||
|
||||
# 4. Verify contact creation
|
||||
# 4. Verify contact creation (and that all fields — #716 — actually persisted)
|
||||
contacts = await nc_client.contacts.list_contacts(addressbook=addressbook_name)
|
||||
assert any(c["vcard_id"] == contact_uid for c in contacts)
|
||||
created = next((c for c in contacts if c["vcard_id"] == contact_uid), None)
|
||||
assert created is not None
|
||||
raw_vcard = created.get("addressdata", "")
|
||||
assert "ORG:MCP Test Corp" in raw_vcard
|
||||
assert f"NOTE:Created by test {unique_suffix}" in raw_vcard
|
||||
|
||||
# 4b. Update with a URL — regression guard for PR #719 review:
|
||||
# _merge_vcard_properties previously had no URL handler, silently dropping it.
|
||||
update_result = await nc_mcp_client.call_tool(
|
||||
"nc_contacts_update_contact",
|
||||
{
|
||||
"addressbook": addressbook_name,
|
||||
"uid": contact_uid,
|
||||
"contact_data": {"url": "https://mcp-test.example.com"},
|
||||
},
|
||||
)
|
||||
assert update_result.isError is False
|
||||
contacts = await nc_client.contacts.list_contacts(addressbook=addressbook_name)
|
||||
updated = next(c for c in contacts if c["vcard_id"] == contact_uid)
|
||||
updated_vcard = updated.get("addressdata", "")
|
||||
assert "mcp-test.example.com" in updated_vcard
|
||||
# Prior properties must not have been clobbered by the merge.
|
||||
assert "ORG:MCP Test Corp" in updated_vcard
|
||||
|
||||
# 5. Delete contact via MCP
|
||||
logger.info("Deleting contact %s via MCP", contact_uid)
|
||||
|
||||
Reference in New Issue
Block a user