fischer-agentkit/tests/unit/bitable
chiguyong 229dc0b2f3 feat(bitable): U6 R15a BitableTool 4 new actions + DELETE /views endpoint
Extend BitableTool from 6 to 10 actions (create_view, update_view,
update_field, delete_view) and add the DELETE /views/{view_id} backend
endpoint with 404-before-403 ownership, 409 last-view protection, and
X-Internal-Token passthrough (KTD11).

Backend:
- repository.py: add delete_view() — DELETE row by view_id, returns rowcount > 0
- service.py: add LastViewDeletionError domain exception + delete_view()
  with last-view guard (siblings <= 1 → raise → route maps to 409)
- routes/bitable.py: add DELETE /views/{view_id} (204 No Content),
  404-before-403 ownership pattern, 409 on LastViewDeletionError,
  X-Internal-Token passthrough via require_bitable_auth
- tools/bitable_tool.py: add 4 new actions (_create_view, _update_view,
  _update_field, _delete_view), register in BOTH handlers dict AND
  input_schema.action.enum (KTD10 — 10 actions each)

Frontend:
- api/bitable.ts: add deleteView(viewId): Promise<void>
- stores/bitable.ts: add deleteView action — removes from local state,
  switches to first remaining view if active was deleted, 409 warning
- ViewSwitcher.vue: add delete button (a-popconfirm "确认删除此视图?"),
  hidden when views.length <= 1 (preempt last-view 409)
- BitableFileDetailView.vue: handle @delete event from ViewSwitcher

Tests:
- test_routes.py: 6 new DELETE /views tests (204, 404 missing, 404
  non-owner, 409 last-view, internal-token passthrough, internal-token 404)
- test_bitable_tool.py: 13 new tests (action count = 10, handlers = 10,
  4 action happy paths, missing-field errors, 409 last-view, R3/R4
  config parity, X-Internal-Token passthrough on all 4 new actions)
- e2e/bitable-agent-parity.spec.ts: 10 scenarios (P1-P10) covering
  delete button visibility, popconfirm, 204/409/404 flows, tab removal,
  view switch after delete, create view adds tab

Verification:
- ruff check: all files pass
- pytest: 62 passed, 12 pre-existing failures (unchanged from e931fbe baseline)
- typecheck: pass (EXIT_CODE=0)
- build:frontend: pass (BUILD_EXIT=0)
- action count: ENUM=10, HANDLERS=10, delete_view in both
- no blue hex colors in ViewSwitcher.vue

Pre-existing test failures (12, unchanged from e931fbe):
test_create_table_success, test_create_field_success, test_list_fields,
test_create_records_batch, test_upsert_inserts_then_updates,
test_upsert_preserves_user_columns, test_create_view_success,
test_batch_upsert_1200_records, test_resume_from_partial_failure,
test_query_records, test_query_records_with_limit, test_collect_api

Constraints honored:
- No emojis, no `any` type, no blue hex colors, no pyproject.toml changes
- 404-before-403 for non-owned resources (Pattern 4)
- X-Internal-Token transparent passthrough (KTD11)
- KTD10: actions registered in both handlers dict AND enum
2026-07-03 23:13:46 +08:00
..
__init__.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
conftest.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_attachment.py feat(bitable): 多维表格文件层 + 默认字段 + 表内字段操作 + ce-code-review 修复 (Stage 1) 2026-06-29 04:07:45 +08:00
test_bitable_tool.py feat(bitable): U6 R15a BitableTool 4 new actions + DELETE /views endpoint 2026-07-03 23:13:46 +08:00
test_cli.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_conditional_formatting.py feat(bitable): U5 R4 grouping (max 3 fields) + conditional formatting (7 operators) 2026-07-03 22:33:18 +08:00
test_db.py feat(bitable): 多维表格文件层 + 默认字段 + 表内字段操作 + ce-code-review 修复 (Stage 1) 2026-06-29 04:07:45 +08:00
test_default_fields.py feat(bitable): 多维表格文件层 + 默认字段 + 表内字段操作 + ce-code-review 修复 (Stage 1) 2026-06-29 04:07:45 +08:00
test_file_crud.py refactor: remove all emoji from agentkit 2026-07-02 01:33:28 +08:00
test_formula_engine.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_formula_parser.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_grouping.py feat(bitable): U5 R4 grouping (max 3 fields) + conditional formatting (7 operators) 2026-07-03 22:33:18 +08:00
test_ingestion_excel.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_models.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_recalc.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00
test_routes.py feat(bitable): U6 R15a BitableTool 4 new actions + DELETE /views endpoint 2026-07-03 23:13:46 +08:00
test_service.py feat(bitable): add bitable companion service with full P0-P2 fixes 2026-06-25 01:09:59 +08:00