Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev
Submodule dev updated from ad6f67 to fa3e22
8 changes: 4 additions & 4 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ Stable hooks are provided via `data-testid` attributes on key elements:
- Header/nav/main in `scidk/ui/templates/base.html`:
- `data-testid="header"` - Main header element
- `data-testid="nav"` - Navigation container
- `data-testid="nav-home"` - Home link
- `data-testid="nav-home"` - Home/Settings link (landing page)
- `data-testid="nav-files"` - Files link
- `data-testid="nav-maps"` - Maps link
- `data-testid="nav-chats"` - Chats link
- `data-testid="nav-settings"` - Settings link
- `data-testid="main"` - Main content area
- Home page in `scidk/ui/templates/index.html`:
- `data-testid="home-recent-scans"` - Recent scans section
- Settings page (landing page) in `scidk/ui/templates/index.html`:
- Settings sections with various configuration options
- Files page in `scidk/ui/templates/datasets.html`:
- `data-testid="files-root"` - Root container
- `data-testid="files-title"` - Page title
Expand Down Expand Up @@ -272,7 +272,7 @@ New API contracts added under `tests/contracts/test_api_contracts.py`:

New Playwright specs:
- `e2e/browse.spec.ts`: navigates to Files and verifies stable hooks, no console errors
- `e2e/scan.spec.ts`: posts `/api/scan` for a temp directory and verifies the Home page lists it
- `e2e/scan.spec.ts`: posts `/api/scan` for a temp directory and verifies scan completion

### How to Run New Tests

Expand Down
56 changes: 56 additions & 0 deletions scidk/services/label_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,59 @@ def update_label_instance(self, name: str, instance_id: str, property_name: str,
'status': 'error',
'error': str(e)
}

def overwrite_label_instance(self, name: str, instance_id: str, properties: Dict[str, Any]) -> Dict[str, Any]:
"""
Overwrite all properties of a label instance in Neo4j.
This removes any properties not in the provided dictionary.

Args:
name: Label name
instance_id: Neo4j element ID
properties: Complete set of properties to set (removes all others)

Returns:
Dict with status and updated instance
"""
label_def = self.get_label(name)
if not label_def:
raise ValueError(f"Label '{name}' not found")

try:
from .neo4j_client import get_neo4j_client
neo4j_client = get_neo4j_client()

if not neo4j_client:
raise Exception("Neo4j client not configured")

# Use SET n = {properties} to overwrite all properties
# This removes any properties not in the provided dict
query = f"""
MATCH (n:{name})
WHERE elementId(n) = $instance_id
SET n = $properties
RETURN elementId(n) as id, properties(n) as properties
"""

results = neo4j_client.execute_write(query, {
'instance_id': instance_id,
'properties': properties
})

if not results:
raise Exception(f"Instance with ID '{instance_id}' not found")

instance = {
'id': results[0].get('id'),
'properties': results[0].get('properties', {})
}

return {
'status': 'success',
'instance': instance
}
except Exception as e:
return {
'status': 'error',
'error': str(e)
}
Loading