Refine overview cards and ignore macOS files
This commit is contained in:
@@ -103,6 +103,40 @@ def test_boxes_page_returns_200(client):
|
||||
assert "箱子" in response.text
|
||||
|
||||
|
||||
def test_boxes_overview_card_shows_note_and_item_count_without_room_or_status(client, db_session):
|
||||
box = Box(
|
||||
name="Kitchen Box",
|
||||
note="易碎餐具和杯子",
|
||||
room="Kitchen",
|
||||
status="packed",
|
||||
)
|
||||
box.items.append(Item(name="Plate", is_container=False))
|
||||
db_session.add(box)
|
||||
db_session.commit()
|
||||
|
||||
response = client.get("/boxes")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Kitchen Box" in response.text
|
||||
assert "物品数:1" in response.text
|
||||
assert "易碎餐具和杯子" in response.text
|
||||
assert "房间:" not in response.text
|
||||
assert "状态:" not in response.text
|
||||
|
||||
|
||||
def test_boxes_overview_renders_cleanly_when_note_is_empty(client, db_session):
|
||||
box = Box(name="No Note Box", note=None, room="Office", status="open")
|
||||
db_session.add(box)
|
||||
db_session.commit()
|
||||
|
||||
response = client.get("/boxes")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "No Note Box" in response.text
|
||||
assert "房间:" not in response.text
|
||||
assert "状态:" not in response.text
|
||||
|
||||
|
||||
def test_can_create_box(client, db_session):
|
||||
response = create_box(client, name="Kitchen Box")
|
||||
|
||||
@@ -177,6 +211,21 @@ def test_box_detail_returns_200_when_box_exists(client, db_session):
|
||||
assert "Visible Box" in response.text
|
||||
|
||||
|
||||
def test_box_detail_item_cards_show_notes_without_note_placeholder_text(client, db_session):
|
||||
box = Box(name="Overview Box")
|
||||
box.items.append(Item(name="Accessory Pouch", note="充电器和转换头", is_container=True, quantity=2))
|
||||
db_session.add(box)
|
||||
db_session.commit()
|
||||
|
||||
response = client.get(f"/boxes/{box.id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Accessory Pouch" in response.text
|
||||
assert "数量:2" in response.text
|
||||
assert "充电器和转换头" in response.text
|
||||
assert "有备注" not in response.text
|
||||
|
||||
|
||||
def test_can_create_regular_item_under_box(client, db_session):
|
||||
box = Box(name="Main Box")
|
||||
db_session.add(box)
|
||||
|
||||
Reference in New Issue
Block a user