ci: integrate backend vitest tests into woodpecker pipeline #1

Merged
chahine merged 8 commits from vitest-pipeline-integration into main 2026-06-18 08:36:14 +00:00
Showing only changes of commit 057c6533af - Show all commits

View File

@ -59,7 +59,7 @@ describe("estimateAudioSeconds", () => {
// ─── getRemainingVoiceQuota ─────────────────────────────────────────────────── // ─── getRemainingVoiceQuota ───────────────────────────────────────────────────
describe("getRemainingVoiceQuota — free plan (60s)", () => { describe("getRemainingVoiceQuota — pro plan (300s)", () => {
it("returns 30s remaining after 30s consumed (same day)", async () => { it("returns 30s remaining after 30s consumed (same day)", async () => {
const todayMidnight = new Date(); const todayMidnight = new Date();
todayMidnight.setUTCHours(0, 0, 0, 0); todayMidnight.setUTCHours(0, 0, 0, 0);
@ -69,8 +69,8 @@ describe("getRemainingVoiceQuota — free plan (60s)", () => {
voiceQuotaResetAt: todayMidnight, // reset is today → no rollover voiceQuotaResetAt: todayMidnight, // reset is today → no rollover
}); });
const remaining = await getRemainingVoiceQuota("user-1", "free"); const remaining = await getRemainingVoiceQuota("user-1", "pro");
expect(remaining).toBe(30); // 60 - 30 expect(remaining).toBe(270); // 300 - 30
expect(mocks.profile.update).not.toHaveBeenCalled(); expect(mocks.profile.update).not.toHaveBeenCalled();
}); });
@ -79,11 +79,11 @@ describe("getRemainingVoiceQuota — free plan (60s)", () => {
todayMidnight.setUTCHours(0, 0, 0, 0); todayMidnight.setUTCHours(0, 0, 0, 0);
mocks.profile.findUnique.mockResolvedValueOnce({ mocks.profile.findUnique.mockResolvedValueOnce({
voiceSecondsUsedToday: 60, voiceSecondsUsedToday: 300,
voiceQuotaResetAt: todayMidnight, voiceQuotaResetAt: todayMidnight,
}); });
const remaining = await getRemainingVoiceQuota("user-1", "free"); const remaining = await getRemainingVoiceQuota("user-1", "pro");
expect(remaining).toBe(0); expect(remaining).toBe(0);
}); });
@ -96,7 +96,7 @@ describe("getRemainingVoiceQuota — free plan (60s)", () => {
voiceQuotaResetAt: todayMidnight, voiceQuotaResetAt: todayMidnight,
}); });
const remaining = await getRemainingVoiceQuota("user-1", "free"); const remaining = await getRemainingVoiceQuota("user-1", "pro");
expect(remaining).toBe(0); expect(remaining).toBe(0);
}); });
}); });
@ -112,8 +112,8 @@ describe("getRemainingVoiceQuota — day rollover", () => {
voiceQuotaResetAt: yesterday, voiceQuotaResetAt: yesterday,
}); });
const remaining = await getRemainingVoiceQuota("user-1", "free"); const remaining = await getRemainingVoiceQuota("user-1", "pro");
expect(remaining).toBe(60); // full plan quota after reset expect(remaining).toBe(300); // full plan quota after reset
// Should have reset the counter // Should have reset the counter
expect(mocks.profile.update).toHaveBeenCalledWith( expect(mocks.profile.update).toHaveBeenCalledWith(