StoicBuilder
Later missionMission 29: Green is not the same as testedYou can practise it now. It counts once you reach mission 29, after “Tests that charge nobody”.Back to HQ

DrillsGreen tests, no refunds

Green tests, no refunds

VIII the PalaestraHarbor, built with CursorSteadyAbout 6 minPro

What happened

When a team cancels mid-month, Harbor refunds the days after the cancellation day. Last week Cursor changed the billing code to use the payment provider’s status names, and every test stayed green. Since then, no team that cancelled has had a refund, and the refund test has passed on every run, including the one for that change.

Kestrel Studio, a Harbor customerWe cancelled our Team plan on 21 November. Your terms say we get the unused days back. Nothing has arrived, and support says the system shows no refund due.
What you seeServer log
Dec 02 09:14:03 refund-job inv_3107 Kestrel Studio, cancelled Nov 21: no refund due Dec 02 09:14:03 refund-job inv_3112 Fernhill Ltd, cancelled Nov 24: no refund due Dec 03 16:40:51 refund-job inv_3140 Okafor Design, cancelled Nov 28: no refund due

The MagisterRun it first and read what comes back. Then change the code if you like: your edits go to the review too.

Run executes this test file against today’s refund.js. The checks also try your tests against a correct refund.js and one that refunds a day too many.

// billing/refund.test.js
// Bench loads refundFor from billing/refund.js before this file runs.
// test and expect work like Vitest's.

const invoice = {
  id: "inv_3107",
  status: "paid",
  chargeId: "ch_DEMO_8812",
  amount: 3000, // Team, November, in cents
  daysInMonth: 30,
};

test("refunds the unused days when a team cancels mid-month", () => {
  const refund = refundFor(invoice, 21);
  if (refund) {
    expect(refund.amount).toBe(900);
  }
});

The code runs in your browser against stand-in data. Nothing is sent anywhere.

Your answer

Reviewed by AI against what a good fix needs. About 10 seconds.

Sign in to get your answer reviewed

It's free. Anything you've typed here stays in this browser and is waiting when you come back.

Sign in with email