|
71 | 71 | TABLE_RESOURCE_ADAPTER, |
72 | 72 | WORKSPACE_RESOURCE_ADAPTERS, |
73 | 73 | ) |
| 74 | +from tracecat.workspace_sync.adapters.base import ResourceDependencyRefs |
74 | 75 | from tracecat.workspace_sync.enums import SyncResourceType, VcsProvider |
75 | 76 | from tracecat.workspace_sync.importer import WorkspaceResourceImportService |
76 | 77 | from tracecat.workspace_sync.resources import workflow_references |
@@ -1039,6 +1040,45 @@ async def test_skill_projection_rejects_ambiguous_legacy_slugs( |
1039 | 1040 | } |
1040 | 1041 |
|
1041 | 1042 |
|
| 1043 | +@pytest.mark.anyio |
| 1044 | +async def test_id_seeded_skill_projection_deduplicates_effective_slugs( |
| 1045 | + session: AsyncSession, |
| 1046 | + svc_role: Role, |
| 1047 | +) -> None: |
| 1048 | + """ID-seeded partial export deduplicates expand-window effective slugs.""" |
| 1049 | + workspace_id = svc_role.workspace_id |
| 1050 | + assert workspace_id is not None |
| 1051 | + exact_owner = Skill( |
| 1052 | + workspace_id=workspace_id, |
| 1053 | + slug="foo", |
| 1054 | + name="Exact owner", |
| 1055 | + description="Canonical description", |
| 1056 | + ) |
| 1057 | + legacy = Skill( |
| 1058 | + workspace_id=workspace_id, |
| 1059 | + slug=None, |
| 1060 | + name="foo", |
| 1061 | + description="Legacy description", |
| 1062 | + ) |
| 1063 | + session.add_all([exact_owner, legacy]) |
| 1064 | + await session.flush() |
| 1065 | + |
| 1066 | + projection = await SKILL_RESOURCE_ADAPTER.project_dependency_refs( |
| 1067 | + WorkspaceSyncService(session=session, role=svc_role), |
| 1068 | + ResourceDependencyRefs(local_ids={exact_owner.id, legacy.id}), |
| 1069 | + ) |
| 1070 | + |
| 1071 | + matching_specs = [ |
| 1072 | + spec |
| 1073 | + for spec in projection.specs.values() |
| 1074 | + if isinstance(spec, SkillResourceSpec) and spec.slug == "foo" |
| 1075 | + ] |
| 1076 | + assert len(matching_specs) == 1 |
| 1077 | + assert matching_specs[0].name == "Exact owner" |
| 1078 | + assert matching_specs[0].description == "Canonical description" |
| 1079 | + assert [resource.local_id for resource in projection.resources] == [exact_owner.id] |
| 1080 | + |
| 1081 | + |
1042 | 1082 | async def _add_preset_version_skill_binding( |
1043 | 1083 | session: AsyncSession, |
1044 | 1084 | *, |
|
0 commit comments