|
1 | 1 | import type { Page } from "@playwright/test"; |
2 | | -import { admin, AI_TIMEOUT, aiResponse, expect, providerCalls, startDebate, test } from "./fixtures"; |
| 2 | +import { admin, AI_TIMEOUT, aiResponse, chooseForMotion, expect, providerCalls, startDebate, test } from "./fixtures"; |
3 | 3 |
|
4 | 4 | // Feature map: features/usage-limits.md. |
5 | 5 | const motion = "This House would make public transport free at the point of use"; |
@@ -70,3 +70,29 @@ test("usage-weighted: Opus counts as 5 requests, a lighter model still runs, and |
70 | 70 | await monthly.getByRole("button", { name: "OK" }).click(); |
71 | 71 | await expect(monthly).toHaveCount(0); |
72 | 72 | }); |
| 73 | + |
| 74 | +test("usage-monthly-inline: Sparring shows the translated monthly-cap message, not the server's English reason", async ({ signedIn: page, user, evidence }) => { |
| 75 | + const userId = await user.userId(); |
| 76 | + const { error } = await admin.from("ai_requests").insert({ |
| 77 | + user_id: userId, feature: "sparring", provider: "openrouter", model: "anthropic/claude-opus-5.5", status: "success", cost_usd: 3, |
| 78 | + }); |
| 79 | + if (error) throw error; |
| 80 | + |
| 81 | + await page.goto("/app/sparring"); |
| 82 | + await page.getByLabel("Motion").fill(motion); |
| 83 | + await page.getByRole("combobox", { name: "Round format" }).click(); |
| 84 | + await page.getByRole("option", { name: /Lincoln-Douglas · 5 speeches/ }).click(); |
| 85 | + await page.getByRole("button", { name: "Start round" }).click(); |
| 86 | + await chooseForMotion(page, "create"); |
| 87 | + const draft = page.getByRole("textbox", { name: "Draft for Affirmative constructive" }); |
| 88 | + await expect(draft).toBeVisible({ timeout: AI_TIMEOUT }); |
| 89 | + await draft.fill("Universal access removes the direct price barrier to work, school, and civic life."); |
| 90 | + await page.getByRole("button", { name: "Submit speech" }).click(); |
| 91 | + |
| 92 | + // The client's catalog copy ("You've used ...") differs from the server reason ("You've reached ..."). |
| 93 | + await expect(page.getByText("You've used this month's AI allowance.", { exact: false })).toBeVisible({ timeout: AI_TIMEOUT }); |
| 94 | + await expect(page.getByText("You've reached this month's AI usage allowance", { exact: false })).toHaveCount(0); |
| 95 | + await evidence.shot("04-sparring-monthly-cap"); |
| 96 | + expect((await providerCalls()).filter((call) => call.feature === "sparring")).toEqual([]); |
| 97 | + await evidence.step("Sparring opponent turn refused by the monthly cap with the translated message; no provider call"); |
| 98 | +}); |
0 commit comments