fix: report missing chart profile deletes

This commit is contained in:
732642856
2026-07-20 17:56:28 +08:00
parent 29b3c63a1c
commit 4441d0f089
2 changed files with 8 additions and 2 deletions
@@ -17,14 +17,17 @@ export async function DELETE(_request: Request, context: RouteContext) {
const { data: { user } } = await supabase.auth.getUser();
if (!user) return NextResponse.json({ error: "请先登录" }, { status: 401 });
const { error } = await supabase
const { count, error } = await supabase
.from("chart_profiles")
.delete()
.delete({ count: "exact" })
.eq("id", id)
.eq("user_id", user.id)
.eq("role", "other");
if (error) throw error;
if (count !== 1) {
return NextResponse.json({ error: "星盘不存在或无权删除" }, { status: 404 });
}
return NextResponse.json({ ok: true });
} catch (error) {
if (isSupabaseConfigurationError(error)) {
@@ -145,7 +145,10 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
):
assert token in route
assert 'upsert(record, { onConflict: "id" })' not in route
assert '.delete({ count: "exact" })' in delete_route
assert 'eq("role", "other")' in delete_route
assert "count !== 1" in delete_route
assert "星盘不存在或无权删除" in delete_route
for token in (
"fetchCloudChartLibrary",