diff --git a/docs/design/forepay.pen b/docs/design/forepay.pen index e685ad9..2d0a55d 100644 --- a/docs/design/forepay.pen +++ b/docs/design/forepay.pen @@ -22858,6 +22858,250 @@ "fontWeight": "normal" } ] + }, + { + "type": "frame", + "id": "jrEiT", + "name": "No AdSense revenue", + "width": 460, + "layout": "vertical", + "gap": 14, + "children": [ + { + "type": "frame", + "id": "P60TZR", + "name": "Preview", + "width": "fill_container", + "height": 520, + "fill": "$canvas", + "cornerRadius": "$radius-tile", + "layout": "vertical", + "gap": 12, + "padding": 24, + "justifyContent": "center", + "alignItems": "center", + "children": [ + { + "type": "frame", + "id": "wrgY2", + "name": "Panel", + "width": 400, + "fill": "$surface", + "cornerRadius": "$radius-card", + "layout": "vertical", + "gap": 14, + "padding": 24, + "children": [ + { + "type": "frame", + "id": "rmbo9", + "name": "Illustration wrap", + "width": "fill_container", + "justifyContent": "center", + "children": [ + { + "id": "u8zle8", + "type": "ref", + "ref": "mrLSL", + "name": "Illustration" + } + ] + }, + { + "type": "text", + "id": "i8o7B", + "name": "Title", + "fill": "$fg", + "content": "No AdSense revenue to prove", + "fontFamily": "$font-sans", + "fontSize": 19, + "fontWeight": "600", + "letterSpacing": -0.3 + }, + { + "type": "text", + "id": "GY5KL", + "name": "Body", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "We found no AdSense revenue in the last three complete months. If you earn with AdMob, go back and prove that instead. Nothing was charged.", + "lineHeight": 1.5, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + }, + { + "type": "frame", + "id": "wt6or", + "name": "Actions", + "width": "fill_container", + "gap": 10, + "children": [ + { + "id": "gLatR", + "type": "ref", + "ref": "kBlXW", + "name": "Secondary", + "width": "fill_container", + "descendants": { + "StVcP": { + "content": "Back" + } + } + } + ] + } + ] + } + ] + }, + { + "type": "text", + "id": "lyEFL", + "name": "Title", + "fill": "$fg", + "content": "No AdSense revenue", + "fontFamily": "$font-sans", + "fontSize": 16, + "fontWeight": "600" + }, + { + "type": "text", + "id": "ZVpOk", + "name": "Desc", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "No AdSense earnings in the three months, so nothing to prove. Back keeps AdSense chosen, to switch to AdMob.", + "lineHeight": 1.5, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + }, + { + "type": "frame", + "id": "c9ynR", + "name": "No AdMob revenue", + "width": 460, + "layout": "vertical", + "gap": 14, + "children": [ + { + "type": "frame", + "id": "Qst2N", + "name": "Preview", + "width": "fill_container", + "height": 520, + "fill": "$canvas", + "cornerRadius": "$radius-tile", + "layout": "vertical", + "gap": 12, + "padding": 24, + "justifyContent": "center", + "alignItems": "center", + "children": [ + { + "type": "frame", + "id": "v2TgOt", + "name": "Panel", + "width": 400, + "fill": "$surface", + "cornerRadius": "$radius-card", + "layout": "vertical", + "gap": 14, + "padding": 24, + "children": [ + { + "type": "frame", + "id": "xUHGe", + "name": "Illustration wrap", + "width": "fill_container", + "justifyContent": "center", + "children": [ + { + "id": "Wn3Zs", + "type": "ref", + "ref": "mrLSL", + "name": "Illustration" + } + ] + }, + { + "type": "text", + "id": "TPxHJ", + "name": "Title", + "fill": "$fg", + "content": "No AdMob revenue to prove", + "fontFamily": "$font-sans", + "fontSize": 19, + "fontWeight": "600", + "letterSpacing": -0.3 + }, + { + "type": "text", + "id": "BrFyL", + "name": "Body", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "We found no AdMob revenue in the last three complete months. If you earn with AdSense, go back and prove that instead. Nothing was charged.", + "lineHeight": 1.5, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + }, + { + "type": "frame", + "id": "oaWG4", + "name": "Actions", + "width": "fill_container", + "gap": 10, + "children": [ + { + "id": "BKaed", + "type": "ref", + "ref": "kBlXW", + "name": "Secondary", + "width": "fill_container", + "descendants": { + "StVcP": { + "content": "Back" + } + } + } + ] + } + ] + } + ] + }, + { + "type": "text", + "id": "XodQP", + "name": "Title", + "fill": "$fg", + "content": "No AdMob revenue", + "fontFamily": "$font-sans", + "fontSize": 16, + "fontWeight": "600" + }, + { + "type": "text", + "id": "Xaw77", + "name": "Desc", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "No AdMob earnings in the three months, so nothing to prove. Back keeps AdMob chosen, to switch to AdSense.", + "lineHeight": 1.5, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] } ] } @@ -24191,6 +24435,216 @@ } ] }, + { + "type": "frame", + "id": "NZ23L", + "name": "No AdSense revenue to prove", + "width": "fill_container", + "stroke": "$line", + "strokeWidth": { + "bottom": 1 + }, + "gap": 24, + "padding": [ + 14, + 0 + ], + "children": [ + { + "type": "frame", + "id": "Ry8xE", + "name": "When", + "width": 340, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "JIxfP", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "The AdSense account earned nothing in the three months", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + }, + { + "type": "frame", + "id": "G0vNf2", + "name": "Title", + "width": 420, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "w9y8jo", + "name": "Text", + "fill": "$fg", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "No AdSense revenue to prove", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "600" + } + ] + }, + { + "type": "frame", + "id": "IfzjU", + "name": "Body", + "width": "fill_container", + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "t05t6", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "We found no AdSense revenue in the last three complete months. If you earn with AdMob, go back and prove that instead. Nothing was charged.", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + }, + { + "type": "frame", + "id": "uF2FT", + "name": "Buttons", + "width": 360, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "XDJxs", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "Back", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + } + ] + }, + { + "type": "frame", + "id": "l3fCaq", + "name": "No AdMob revenue to prove", + "width": "fill_container", + "stroke": "$line", + "strokeWidth": { + "bottom": 1 + }, + "gap": 24, + "padding": [ + 14, + 0 + ], + "children": [ + { + "type": "frame", + "id": "X8x6XY", + "name": "When", + "width": 340, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "o0gWjt", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "The AdMob account earned nothing in the three months", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + }, + { + "type": "frame", + "id": "UMV80", + "name": "Title", + "width": 420, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "K1s4mT", + "name": "Text", + "fill": "$fg", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "No AdMob revenue to prove", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "600" + } + ] + }, + { + "type": "frame", + "id": "NaAw8", + "name": "Body", + "width": "fill_container", + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "sYHPH", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "We found no AdMob revenue in the last three complete months. If you earn with AdSense, go back and prove that instead. Nothing was charged.", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + }, + { + "type": "frame", + "id": "UEnai", + "name": "Buttons", + "width": 360, + "layout": "vertical", + "children": [ + { + "type": "text", + "id": "FuzA0", + "name": "Text", + "fill": "$fg-muted", + "textGrowth": "fixed-width", + "width": "fill_container", + "content": "Back", + "lineHeight": 1.45, + "fontFamily": "$font-sans", + "fontSize": 14, + "fontWeight": "normal" + } + ] + } + ] + }, { "type": "frame", "id": "mAJ5z", diff --git a/fe/src/lib/errors.test.ts b/fe/src/lib/errors.test.ts index b80f860..d583f09 100644 --- a/fe/src/lib/errors.test.ts +++ b/fe/src/lib/errors.test.ts @@ -135,6 +135,8 @@ describe("proveFailureCopy", () => { "noAdsense", "googleSignInAdmob", "noAdmob", + "noRevenue", + "noRevenueAdmob", "relayFailed", "relayBusy", "proofRunning", @@ -154,7 +156,7 @@ describe("proveFailureCopy", () => { it("says nothing was charged only when that is true", () => { expect(proveFailureCopy("refused").body).toMatch(/Nothing was charged/); // The relay's failures happen before anything reaches Stellar. - for (const k of ["googleSignIn", "noAdsense", "googleSignInAdmob", "noAdmob", "relayFailed", "proofRunning", "proofGone", "relayUnreachable"] as const) { + for (const k of ["googleSignIn", "noAdsense", "googleSignInAdmob", "noAdmob", "noRevenue", "noRevenueAdmob", "relayFailed", "proofRunning", "proofGone", "relayUnreachable"] as const) { expect(proveFailureCopy(k).body).toMatch(/Nothing was charged/); } for (const k of ["relayBusy", "googleUnavailable", "popupBlocked"] as const) { @@ -169,6 +171,17 @@ describe("proveFailureCopy", () => { expect(new Set(all).size).toBe(kinds.length); }); + it("points a creator with no revenue at the other source", () => { + expect(proveFailureCopy("noRevenue")).toEqual({ + title: "No AdSense revenue to prove", + body: "We found no AdSense revenue in the last three complete months. If you earn with AdMob, go back and prove that instead. Nothing was charged.", + }); + expect(proveFailureCopy("noRevenueAdmob")).toEqual({ + title: "No AdMob revenue to prove", + body: "We found no AdMob revenue in the last three complete months. If you earn with AdSense, go back and prove that instead. Nothing was charged.", + }); + }); + it("names the wallet that declined", () => { expect(proveFailureCopy("declined", "xBull").title).toBe("You declined in xBull"); }); diff --git a/fe/src/lib/errors.ts b/fe/src/lib/errors.ts index b496930..a297ddb 100644 --- a/fe/src/lib/errors.ts +++ b/fe/src/lib/errors.ts @@ -214,6 +214,7 @@ export function contractFailureCopy(code: number, sourceName = "AdSense"): Failu * - `googleSignIn`: Google refused the sign-in the relay was handed, for example an expired one. * - `noAdsense`: the Google account has no AdSense account, several, or one that is not approved (relay `account`). * - `googleSignInAdmob`, `noAdmob`: the same two for an AdMob proof (#97). + * - `noRevenue`, `noRevenueAdmob`: the account earned nothing in the three months (relay `empty`). * - `relayFailed`: the relay could not make the proof, on its side. Nothing was charged. * - `relayBusy`: the relay is proving for others and its queue is full. * - `proofRunning`: a proof for this wallet is already running, started from a tab that lost it. @@ -241,6 +242,8 @@ export type ProveFailure = | "noAdsense" | "googleSignInAdmob" | "noAdmob" + | "noRevenue" + | "noRevenueAdmob" | "relayFailed" | "relayBusy" | "proofRunning" @@ -345,6 +348,16 @@ export function proveFailureCopy(kind: ProveFailure, walletName = "Freighter"): title: "We could not use your AdMob account", body: "We could not find one AdMob account on this Google account. Sign in with the account that owns your AdMob, then try again. Nothing was charged.", }; + case "noRevenue": + return { + title: "No AdSense revenue to prove", + body: "We found no AdSense revenue in the last three complete months. If you earn with AdMob, go back and prove that instead. Nothing was charged.", + }; + case "noRevenueAdmob": + return { + title: "No AdMob revenue to prove", + body: "We found no AdMob revenue in the last three complete months. If you earn with AdSense, go back and prove that instead. Nothing was charged.", + }; case "relayFailed": return { title: "We could not finish your proof", diff --git a/fe/src/lib/reclaim/relay.test.ts b/fe/src/lib/reclaim/relay.test.ts index 44f8d84..363e568 100644 --- a/fe/src/lib/reclaim/relay.test.ts +++ b/fe/src/lib/reclaim/relay.test.ts @@ -82,6 +82,15 @@ describe("relayProveRevenue", () => { expect((e as RelayError).code).toBe("account"); }); + it("a job that found no earnings keeps the code empty, and the source", async () => { + const r = relay([{ id: "j1", stage: "failed", error: { code: "empty", message: "no earnings" } }]); + const s = relayProveRevenue(BORROWER, () => {}, { relayUrl: "https://r", signIn: signedIn, fetch: r.fetch, sleep: noSleep, jobs: store().jobs, source: "admob" }); + const e = await s.result.catch((x) => x); + expect(e).toBeInstanceOf(RelayError); + expect((e as RelayError).code).toBe("empty"); + expect((e as RelayError).source).toBe("admob"); + }); + it("names the relay's refusal by its code, and by the status when there is none", async () => { const cases: [number, object, string][] = [ [409, { error: "x", code: "running" }, "running"], diff --git a/fe/src/lib/reclaim/relay.ts b/fe/src/lib/reclaim/relay.ts index 1dc2828..867813f 100644 --- a/fe/src/lib/reclaim/relay.ts +++ b/fe/src/lib/reclaim/relay.ts @@ -184,7 +184,7 @@ export type RelayOptions = { sleep?: (ms: number) => Promise; }; -const CODES: readonly RelayErrorCode[] = ["token", "account", "running", "busy", "unconfigured", "provider", "prove", "audit", "internal"]; +const CODES: readonly RelayErrorCode[] = ["token", "account", "empty", "running", "busy", "unconfigured", "provider", "prove", "audit", "internal"]; class Abandoned extends Error {} diff --git a/fe/src/lib/reclaim/session.ts b/fe/src/lib/reclaim/session.ts index d354b11..8b12cd5 100644 --- a/fe/src/lib/reclaim/session.ts +++ b/fe/src/lib/reclaim/session.ts @@ -45,6 +45,7 @@ export class RelayNotReadyError extends Error { * Why the relay could not make the proof, by whose move it is (docs/api.md): * - `token`: Google refused the sign-in, for example an expired one. Signing in again fixes it. * - `account`: no approved AdSense account (or no AdMob account) behind that Google account. + * - `empty`: the account earned nothing in the three months. Proving again proves the same nothing. * - `running`: a proof for this wallet is already running, started from a tab that no longer has it. * - `gone`: the proof this tab was waiting on is no longer on the relay (it restarted, or an hour passed). * - `busy`: the relay is proving for others and its queue is full. @@ -57,6 +58,7 @@ export class RelayNotReadyError extends Error { export type RelayErrorCode = | "token" | "account" + | "empty" | "running" | "gone" | "busy" diff --git a/fe/src/modules/advance/components/FailurePanel.tsx b/fe/src/modules/advance/components/FailurePanel.tsx index f5e0cec..7da7665 100644 --- a/fe/src/modules/advance/components/FailurePanel.tsx +++ b/fe/src/modules/advance/components/FailurePanel.tsx @@ -127,6 +127,14 @@ export function FailurePanel({ illustration = ; actions = ; break; + // The relay found no earnings in the window (#97). Not on the board yet. Proving again would read the + // same months, so only Back: from 2a the creator can pick the other source. The picture and single + // Back of "Not enough revenue yet", on 2a's step since there is no offer. + case "noRevenue": + case "noRevenueAdmob": + illustration = ; + actions = back; + break; case "proofGone": illustration = ; actions = <>{proveAgain}{back}; diff --git a/fe/src/modules/advance/failures.test.ts b/fe/src/modules/advance/failures.test.ts index 380befe..413c773 100644 --- a/fe/src/modules/advance/failures.test.ts +++ b/fe/src/modules/advance/failures.test.ts @@ -21,6 +21,9 @@ describe("proveFailure", () => { // An AdMob proof names AdMob where the creator has to act on their Google account (#97). expect(proveFailure(new RelayError("token", "x", "admob"))).toEqual({ kind: "googleSignInAdmob" }); expect(proveFailure(new RelayError("account", "x", "admob"))).toEqual({ kind: "noAdmob" }); + // No revenue in the window: its own words, not "try again in a few minutes". + expect(proveFailure(new RelayError("empty", "x"))).toEqual({ kind: "noRevenue" }); + expect(proveFailure(new RelayError("empty", "x", "admob"))).toEqual({ kind: "noRevenueAdmob" }); expect(proveFailure(new RelayError("gone", "x", "admob"))).toEqual({ kind: "proofGone" }); for (const code of ["provider", "prove", "audit", "internal"] as const) { expect(proveFailure(new RelayError(code, "x"))).toEqual({ kind: "relayFailed" }); diff --git a/fe/src/modules/advance/failures.ts b/fe/src/modules/advance/failures.ts index 3323c61..47a3c42 100644 --- a/fe/src/modules/advance/failures.ts +++ b/fe/src/modules/advance/failures.ts @@ -18,6 +18,7 @@ function sorted(e: unknown): AdvanceFailure { const kinds: Partial> = { token: e.source === "admob" ? "googleSignInAdmob" : "googleSignIn", account: e.source === "admob" ? "noAdmob" : "noAdsense", + empty: e.source === "admob" ? "noRevenueAdmob" : "noRevenue", running: "proofRunning", gone: "proofGone", busy: "relayBusy", diff --git a/fe/tests/e2e/relay.spec.ts b/fe/tests/e2e/relay.spec.ts index 04872d4..2793489 100644 --- a/fe/tests/e2e/relay.spec.ts +++ b/fe/tests/e2e/relay.spec.ts @@ -139,6 +139,21 @@ test("a Google account with no AdSense the relay can read is named", async ({ pa await expect(page.getByRole("button", { name: "Back" })).toBeVisible(); }); +test("an AdSense account that earned nothing is named, and only Back is offered", async ({ page }) => { + const relay = relayFor({ j1: [{ id: "j1", stage: "failed", error: { code: "empty", message: "no AdSense earnings" } }] }); + await connect(page, relay, "ok"); + await prove(page); + await expect(heading(page, "No AdSense revenue to prove")).toBeVisible(); + await expect(page.getByText("We found no AdSense revenue in the last three complete months", { exact: false })).toBeVisible(); + await expect(page.getByText("If you earn with AdMob, go back and prove that instead.", { exact: false })).toBeVisible(); + await expect(page.locator('[data-illo="no-advance-yet"]')).toBeVisible(); + // Proving again would read the same months. + await expect(page.getByRole("button", { name: "Prove again" })).toHaveCount(0); + await page.getByRole("button", { name: "Back" }).click(); + await expect(page.getByRole("radio", { name: /AdSense/ })).toBeChecked(); + await expect(page.getByRole("button", { name: "Prove my revenue" })).toBeVisible(); +}); + test("closing Google's window is named, and proving can start again", async ({ page }) => { const relay = relayFor(); await connect(page, relay, "closed"); @@ -348,6 +363,21 @@ test("a Google account with no AdMob is named as AdMob, and Prove again stays on expect(relay.posts.map((p) => p.source)).toEqual(["admob", "admob"]); }); +test("an AdMob account that earned nothing is named as AdMob, and Back stays on AdMob", async ({ page }) => { + const relay = relayFor({ j1: [{ id: "j1", stage: "failed", error: { code: "empty", message: "no AdMob earnings" } }] }); + await connect(page, relay, "ok"); + await chooseAdmob(page); + await prove(page); + await expect(heading(page, "No AdMob revenue to prove")).toBeVisible(); + await expect(page.getByText("We found no AdMob revenue in the last three complete months", { exact: false })).toBeVisible(); + await expect(page.getByText("If you earn with AdSense, go back and prove that instead.", { exact: false })).toBeVisible(); + await expect(page.locator('[data-illo="no-advance-yet"]')).toBeVisible(); + await expect(page.getByRole("button", { name: "Prove again" })).toHaveCount(0); + await page.getByRole("button", { name: "Back" }).click(); + await expect(page.getByRole("radio", { name: /AdMob/ })).toBeChecked(); + expect(relay.posts.map((p) => p.source)).toEqual(["admob"]); +}); + test("an AdMob proof resumed after leaving stays AdMob: its reading, its failure, Prove again and Back", async ({ page }) => { const relay = relayFor({ j1: [{ id: "j1", stage: "failed", error: { code: "account", message: "no AdMob account" } }] }); relay.hold = true;