refactor(color-strip): rename static -> single + frontend follow-through

The "static" source kind always rendered a SINGLE color and the name
confused new code paths. Rename the module + kind to "single". Storage
keeps backward-compatible serialisation. Frontend color-strip cards /
gradient / index / test modules and the affected tests follow the new
name.
This commit is contained in:
2026-05-23 00:49:00 +03:00
parent 737fd72b73
commit 826e680f37
10 changed files with 74 additions and 67 deletions
+15 -15
View File
@@ -7,23 +7,23 @@ Tests creating, listing, updating, cloning, and deleting color strip sources.
class TestColorStripSourceLifecycle:
"""A user manages color strip sources for LED effects."""
def test_static_and_gradient_crud(self, client):
# 1. Create a static color strip source
def test_single_color_and_gradient_crud(self, client):
# 1. Create a single-color strip source
resp = client.post(
"/api/v1/color-strip-sources",
json={
"name": "Red Static",
"source_type": "static",
"name": "Red Single",
"source_type": "single_color",
"color": [255, 0, 0],
"led_count": 60,
"tags": ["e2e", "static"],
"tags": ["e2e", "single_color"],
},
)
assert resp.status_code == 201, f"Create static failed: {resp.text}"
assert resp.status_code == 201, f"Create single_color failed: {resp.text}"
static = resp.json()
static_id = static["id"]
assert static["name"] == "Red Static"
assert static["source_type"] == "static"
assert static["name"] == "Red Single"
assert static["source_type"] == "single_color"
assert static["color"] == [255, 0, 0]
# 2. Create a gradient color strip source
@@ -58,7 +58,7 @@ class TestColorStripSourceLifecycle:
# 4. Update the static source -- change color
resp = client.put(
f"/api/v1/color-strip-sources/{static_id}",
json={"source_type": "static", "color": [0, 255, 0]},
json={"source_type": "single_color", "color": [0, 255, 0]},
)
assert resp.status_code == 200
assert resp.json()["color"] == [0, 255, 0]
@@ -72,8 +72,8 @@ class TestColorStripSourceLifecycle:
resp = client.post(
"/api/v1/color-strip-sources",
json={
"name": "Cloned Static",
"source_type": "static",
"name": "Cloned Single",
"source_type": "single_color",
"color": [0, 255, 0],
"led_count": 60,
},
@@ -81,7 +81,7 @@ class TestColorStripSourceLifecycle:
assert resp.status_code == 201
clone_id = resp.json()["id"]
assert clone_id != static_id
assert resp.json()["name"] == "Cloned Static"
assert resp.json()["name"] == "Cloned Single"
# 7. Delete all three
for sid in [static_id, gradient_id, clone_id]:
@@ -99,7 +99,7 @@ class TestColorStripSourceLifecycle:
"/api/v1/color-strip-sources",
json={
"name": "Original Name",
"source_type": "static",
"source_type": "single_color",
"color": [100, 100, 100],
"led_count": 10,
},
@@ -108,7 +108,7 @@ class TestColorStripSourceLifecycle:
resp = client.put(
f"/api/v1/color-strip-sources/{source_id}",
json={"source_type": "static", "name": "New Name"},
json={"source_type": "single_color", "name": "New Name"},
)
assert resp.status_code == 200
assert resp.json()["name"] == "New Name"
@@ -125,7 +125,7 @@ class TestColorStripSourceLifecycle:
"""Cannot create two sources with the same name."""
payload = {
"name": "Unique Name",
"source_type": "static",
"source_type": "single_color",
"color": [0, 0, 0],
"led_count": 10,
}
+2 -2
View File
@@ -22,8 +22,8 @@ def store(tmp_db):
def _create_static(store: ColorStripStore, name: str) -> str:
"""Create a static color strip source, return its ID."""
source = store.create_source(name=name, source_type="static", colors=[[255, 0, 0]])
"""Create a single-color strip source, return its ID."""
source = store.create_source(name=name, source_type="single_color", colors=[[255, 0, 0]])
return source.id