fix(tests): narrow redeemed profile

Assert that the profile lookup returned a row before reading premium status so Deno strict type checking can execute the Supabase integration suite.
This commit is contained in:
jjbrunton committed 2026-08-27 22:30:39 +01:00
1 parent d43ae1ef05
commit d869592a8b
1 file changed
+14 -7
+14 -7
View File
@@ -1,6 +1,11 @@
import { assertEquals, assertExists } from "std/testing/asserts.ts";
import { assertEquals } from "std/testing/asserts.ts"; import {
import { createTestUser, createRedemptionCode, cleanup, adminClient, SUPABASE_URL } from "./utils.ts"; adminClient,
cleanup,
createRedemptionCode,
createTestUser,
SUPABASE_URL,
} from "./utils.ts";
const FUNCTION_URL = `${SUPABASE_URL}/functions/v1/redeem-code`; const FUNCTION_URL = `${SUPABASE_URL}/functions/v1/redeem-code`;
@@ -24,8 +29,8 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify({
email, email,
code: codeData.code code: codeData.code,
}) }),
}); });
const data = await res.json(); const data = await res.json();
@@ -39,10 +44,12 @@ Deno.test("redeem-code: successfully redeems code for user", async () => {
.eq("id", user.id) .eq("id", user.id)
.single(); .single();
assertExists(profile);
assertEquals(profile.is_premium, true); assertEquals(profile.is_premium, true);
} finally { } finally {
await cleanup(userIds); await cleanup(userIds);
if (codeId) await adminClient.from("redemption_codes").delete().eq("id", codeId); if (codeId) {
await adminClient.from("redemption_codes").delete().eq("id", codeId);
}
} }
}); });