fix: report missing chart profile deletes
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user