-
Notifications
You must be signed in to change notification settings - Fork 0
Complete subscription nudge #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
19155b2
Enable Reanimated + gesture-handler; animate onboarding
saikumarbt c3c80e1
"Complete your subscription" nudge: confirm renewal date
saikumarbt a6b0421
Fix renewal math: a charge due today shows as today
saikumarbt a09ad29
Fix guest dead-end: add Back affordance to sign-in/sign-up
saikumarbt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // Native modules are mocked with factories (never loading the real ones, which | ||
| // pull unresolvable native deps under jest) so importing the db layer is safe — | ||
| // migrateIfNeeded takes an injected db, and rowToSubscription is pure. | ||
| jest.mock("expo-sqlite", () => ({ openDatabaseSync: jest.fn() })); | ||
| jest.mock("expo-crypto", () => ({ randomUUID: jest.fn(() => "test-id") })); | ||
|
|
||
| import { migrateIfNeeded } from "@/db/database"; | ||
| import { MIGRATIONS } from "@/db/migrations"; | ||
| import { rowToSubscription, type SubscriptionRow } from "@/db/subscriptionsRepo"; | ||
|
|
||
| /** Minimal fake of the SQLiteDatabase surface migrateIfNeeded uses. */ | ||
| const makeFakeDb = (startVersion: number) => { | ||
| let version = startVersion; | ||
| const executed: string[] = []; | ||
| const db = { | ||
| getFirstSync: (query: string) => | ||
| query.includes("user_version") ? { user_version: version } : null, | ||
| withTransactionSync: (fn: () => void) => fn(), | ||
| execSync: (sql: string) => { | ||
| executed.push(sql); | ||
| const match = sql.match(/PRAGMA user_version = (\d+)/); | ||
| if (match) version = Number(match[1]); | ||
| }, | ||
| }; | ||
| return { db, executed, version: () => version }; | ||
| }; | ||
|
|
||
| const run = (start: number) => { | ||
| const fake = makeFakeDb(start); | ||
| migrateIfNeeded(fake.db as unknown as Parameters<typeof migrateIfNeeded>[0]); | ||
| return fake; | ||
| }; | ||
|
|
||
| const latest = MIGRATIONS[MIGRATIONS.length - 1].version; | ||
|
|
||
| describe("MIGRATIONS list", () => { | ||
| it("is append-only: strictly ascending versions", () => { | ||
| for (let i = 1; i < MIGRATIONS.length; i++) { | ||
| expect(MIGRATIONS[i].version).toBeGreaterThan(MIGRATIONS[i - 1].version); | ||
| } | ||
| }); | ||
|
|
||
| it("adds the date_assumed column at v2", () => { | ||
| const v2 = MIGRATIONS.find((m) => m.version === 2); | ||
| expect(v2?.sql).toMatch(/date_assumed/); | ||
| expect(latest).toBe(2); | ||
| }); | ||
| }); | ||
|
|
||
| describe("migrateIfNeeded", () => { | ||
| it("runs every migration on a fresh db and bumps to the latest version", () => { | ||
| const fake = run(0); | ||
| expect(fake.version()).toBe(latest); | ||
| expect(fake.executed.some((s) => s.includes("CREATE TABLE"))).toBe(true); | ||
| expect(fake.executed.some((s) => s.includes("date_assumed"))).toBe(true); | ||
| }); | ||
|
|
||
| it("runs only pending migrations when already at v1", () => { | ||
| const fake = run(1); | ||
| expect(fake.version()).toBe(2); | ||
| // v1 (CREATE TABLE) is skipped; v2 (ALTER) runs. | ||
| expect(fake.executed.some((s) => s.includes("CREATE TABLE"))).toBe(false); | ||
| expect(fake.executed.some((s) => s.includes("date_assumed"))).toBe(true); | ||
| }); | ||
|
|
||
| it("is a no-op when already at the latest version", () => { | ||
| const fake = run(latest); | ||
| expect(fake.executed).toHaveLength(0); | ||
| expect(fake.version()).toBe(latest); | ||
| }); | ||
| }); | ||
|
|
||
| describe("rowToSubscription date_assumed mapping", () => { | ||
| const baseRow: SubscriptionRow = { | ||
| id: "1", | ||
| name: "Netflix", | ||
| icon_key: null, | ||
| color: null, | ||
| plan: null, | ||
| category: null, | ||
| payment_method: null, | ||
| notes: null, | ||
| status: "active", | ||
| price: 15.49, | ||
| currency: "USD", | ||
| billing_cycle: "monthly", | ||
| custom_interval_days: null, | ||
| is_trial: 0, | ||
| date_assumed: 0, | ||
| trial_end_date: null, | ||
| start_date: null, | ||
| next_renewal_date: null, | ||
| cancelled_at: null, | ||
| paused_at: null, | ||
| created_at: "2026-01-01T00:00:00.000Z", | ||
| updated_at: "2026-01-01T00:00:00.000Z", | ||
| deleted_at: null, | ||
| }; | ||
|
|
||
| it("maps 0 -> false and 1 -> true", () => { | ||
| expect(rowToSubscription(baseRow).dateAssumed).toBe(false); | ||
| expect(rowToSubscription({ ...baseRow, date_assumed: 1 }).dateAssumed).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,22 @@ export default function SignIn() { | |
| > | ||
| <ScrollView className="auth-scroll"> | ||
| <View className="auth-content"> | ||
| <Pressable | ||
| className="mb-2 flex-row items-center gap-1 self-start py-2" | ||
| onPress={() => | ||
| router.canGoBack() ? router.back() : router.replace("/") | ||
| } | ||
| hitSlop={8} | ||
| accessibilityRole="button" | ||
| accessibilityLabel="Back to app" | ||
| > | ||
| <Text className="text-2xl font-sans-medium text-muted-foreground"> | ||
| ‹ | ||
| </Text> | ||
| <Text className="text-sm font-sans-semibold text-muted-foreground"> | ||
| Back | ||
| </Text> | ||
| </Pressable> | ||
|
Comment on lines
+144
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Expose back navigation from both verification screens. The back button is placed only in each normal form branch, while both verification branches return before reaching it.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| <View className="auth-brand-block"> | ||
| <View className="auth-logo-wrap"> | ||
| <View className="auth-logo-mark"> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use an accurate accessibility label for conditional back navigation.
Because the handler may return to another authentication screen,
"Back to app"does not describe the actual action.app/(auth)/sign-in.tsx#L150-L151: change the label to"Go back"or"Back".app/(auth)/sign-up.tsx#L131-L132: change the label to"Go back"or"Back".📍 Affects 2 files
app/(auth)/sign-in.tsx#L150-L151(this comment)app/(auth)/sign-up.tsx#L131-L132🤖 Prompt for AI Agents