Open source personal finance application
test: remove 52 low-value tests (redundant patterns, trivial wrappers, constant checks)
Ilya Komichevd2e82f87fa67
diff --git a/app/components/amount/utils.test.ts b/app/components/amount/utils.test.tsdeleted file mode 100644index 8f983e2f..00000000--- a/app/components/amount/utils.test.ts+++ /dev/null@@ -1,59 +0,0 @@-import { describe, expect, it } from 'vitest'--import { formatAmount, formatByCurrency, getCurrencySymbol } from '~/components/amount/utils'--describe('formatAmount', () => {- it('formats integer with default precision 0', () => {- expect(formatAmount(1234)).toBe('1 234')- })-- it('uses space as thousands separator', () => {- expect(formatAmount(1000000)).toBe('1 000 000')- })-- it('formats with explicit precision', () => {- expect(formatAmount(1234.567, undefined, { precision: 2 })).toBe('1 234.57')- })-- it('formats negative amounts', () => {- expect(formatAmount(-1500)).toBe('-1 500')- })-- it('formats zero', () => {- expect(formatAmount(0)).toBe('0')- })-- it('formats small decimals', () => {- expect(formatAmount(0.99, undefined, { precision: 2 })).toBe('0.99')- })-})--describe('getCurrencySymbol', () => {- it('returns symbol for known currency', () => {- expect(getCurrencySymbol('USD')).toBe('$')- expect(getCurrencySymbol('EUR')).toBe('€')- expect(getCurrencySymbol('RUB')).toBe('₽')- })-- it('returns code when no symbol defined', () => {- expect(getCurrencySymbol('AMD')).toBe('AMD')- })-- it('returns empty string for undefined', () => {- expect(getCurrencySymbol(undefined)).toBe('')- })-})--describe('formatByCurrency', () => {- it('adds thousands separator', () => {- expect(formatByCurrency('1000000', ' ')).toBe('1 000 000')- })-- it('does not affect small numbers', () => {- expect(formatByCurrency('999', ' ')).toBe('999')- })-- it('works with different separators', () => {- expect(formatByCurrency('1000000', ',')).toBe('1,000,000')- })-})diff --git a/app/components/date/utils.test.ts b/app/components/date/utils.test.tsindex 74c3e85f..cd087cc9 100644--- a/app/components/date/utils.test.ts+++ b/app/components/date/utils.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest'-import { calculateBestIntervalsBy, getEndOf, getStartOf } from '~/components/date/utils'+import { calculateBestIntervalsBy } from '~/components/date/utils'describe('calculateBestIntervalsBy', () => {it('returns year for range > 400 days', () => {@@ -41,53 +41,3 @@ describe('calculateBestIntervalsBy', () => {expect(calculateBestIntervalsBy({ end: end.getTime(), start: start.getTime() })).toBe('day')})})--describe('getStartOf', () => {- const date = new Date(2025, 2, 12, 15, 30) // Wed Mar 12 2025 15:30-- it('year → Jan 1 00:00', () => {- expect(getStartOf(date, 'year')).toEqual(new Date(2025, 0, 1))- })-- it('month → Mar 1 00:00', () => {- expect(getStartOf(date, 'month')).toEqual(new Date(2025, 2, 1))- })-- it('week → Monday (weekStartsOn: 1)', () => {- expect(getStartOf(date, 'week')).toEqual(new Date(2025, 2, 10))- })-- it('day → Mar 12 00:00', () => {- expect(getStartOf(date, 'day')).toEqual(new Date(2025, 2, 12))- })-})--describe('getEndOf', () => {- const date = new Date(2025, 2, 12, 15, 30) // Wed Mar 12 2025 15:30-- it('year → Dec 31 23:59:59.999', () => {- const result = getEndOf(date, 'year')- expect(result.getFullYear()).toBe(2025)- expect(result.getMonth()).toBe(11)- expect(result.getDate()).toBe(31)- expect(result.getHours()).toBe(23)- })-- it('month → Mar 31 23:59:59.999', () => {- const result = getEndOf(date, 'month')- expect(result.getDate()).toBe(31)- expect(result.getHours()).toBe(23)- })-- it('week → Sunday (weekStartsOn: 1)', () => {- const result = getEndOf(date, 'week')- expect(result.getDay()).toBe(0) // Sunday- expect(result.getDate()).toBe(16)- })-- it('day → Mar 12 23:59:59.999', () => {- const result = getEndOf(date, 'day')- expect(result.getDate()).toBe(12)- expect(result.getHours()).toBe(23)- })-})diff --git a/app/components/trnForm/utils/formatData.test.ts b/app/components/trnForm/utils/formatData.test.tsindex 738d10e6..4f63fc3e 100644--- a/app/components/trnForm/utils/formatData.test.ts+++ b/app/components/trnForm/utils/formatData.test.ts@@ -58,12 +58,6 @@ const transfer: {}const transactions = [{- data: {- become: false,- expect: {},- },- name: 'Format empty',-}, {data: {become: {...transaction.generated,@@ -94,12 +88,6 @@ const transactions = [{}]const transfers = [{- data: {- become: false,- expect: {},- },- name: 'Format empty',-}, {data: {become: {...transfer.generated,@@ -127,15 +115,6 @@ const transfers = [{} as TrnFormValues,},name: 'Format with missing expenseWalletId',-}, {- data: {- become: false,- expect: {- ...transfer.raw,- trnType: 1,- } as TrnFormValues,- },- name: 'Format with wrong type',}]/**diff --git a/convex/categories.test.ts b/convex/categories.test.tsindex 02da8288..7261021c 100644--- a/convex/categories.test.ts+++ b/convex/categories.test.ts@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'import { api } from './_generated/api'import schema from './schema'-import { modules, setMockUser } from './test-utils/setup'+import { modules } from './test-utils/setup'const validCategory = {color: '#ff0000',@@ -14,7 +14,11 @@ const validCategory = {}const validWallet = {- color: '#000', currency: 'USD', name: 'Cash', order: 0, type: 'cash' as const,+ color: '#000',+ currency: 'USD',+ name: 'Cash',+ order: 0,+ type: 'cash' as const,}describe('convex/categories', () => {@@ -37,7 +41,9 @@ describe('convex/categories', () => {const t = convexTest(schema, modules)const parentId = await t.mutation(api.categories.create, validCategory)const childId = await t.mutation(api.categories.create, {- ...validCategory, name: 'Groceries', parentId,+ ...validCategory,+ name: 'Groceries',+ parentId,})const categories = await t.query(api.categories.list)@@ -45,27 +51,6 @@ describe('convex/categories', () => {expect(child.parentId).toBe(parentId)})- it('throws for empty name', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.categories.create, { ...validCategory, name: ' ' }),- ).rejects.toThrow('Name is required')- })-- it('throws for empty icon', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.categories.create, { ...validCategory, icon: '' }),- ).rejects.toThrow('Icon is required')- })-- it('throws for empty color', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.categories.create, { ...validCategory, color: '' }),- ).rejects.toThrow('Color is required')- })-it('throws for duplicate name at same level', async () => {const t = convexTest(schema, modules)await t.mutation(api.categories.create, validCategory)@@ -79,7 +64,6 @@ describe('convex/categories', () => {const parent1 = await t.mutation(api.categories.create, validCategory)const parent2 = await t.mutation(api.categories.create, { ...validCategory, name: 'Transport' })- // Same child name under different parents — OKawait t.mutation(api.categories.create, { ...validCategory, name: 'Taxi', parentId: parent1 })await t.mutation(api.categories.create, { ...validCategory, name: 'Taxi', parentId: parent2 })@@ -92,35 +76,22 @@ describe('convex/categories', () => {const t = convexTest(schema, modules)const parentId = await t.mutation(api.categories.create, validCategory)const childId = await t.mutation(api.categories.create, {- ...validCategory, name: 'Groceries', parentId,+ ...validCategory,+ name: 'Groceries',+ parentId,})await expect(t.mutation(api.categories.create, {- ...validCategory, name: 'Dairy', parentId: childId,+ ...validCategory,+ name: 'Dairy',+ parentId: childId,}),).rejects.toThrow('Cannot nest more than 2 levels deep')})-- it('throws for unauthenticated user', async () => {- const t = convexTest(schema, modules)- setMockUser(null)- await expect(- t.mutation(api.categories.create, validCategory),- ).rejects.toThrow('Unauthorized')- })})describe('update', () => {- it('updates category fields', async () => {- const t = convexTest(schema, modules)- const id = await t.mutation(api.categories.create, validCategory)- await t.mutation(api.categories.update, { id, name: 'Dining', icon: 'restaurant' })-- const categories = await t.query(api.categories.list)- expect(categories![0]).toMatchObject({ name: 'Dining', icon: 'restaurant' })- })-it('throws for duplicate name on rename', async () => {const t = convexTest(schema, modules)await t.mutation(api.categories.create, validCategory)@@ -131,16 +102,6 @@ describe('convex/categories', () => {).rejects.toThrow('Category with this name already exists')})- it('throws for category owned by another user', async () => {- const t = convexTest(schema, modules)- const id = await t.mutation(api.categories.create, validCategory)-- setMockUser('other-user')- await expect(- t.mutation(api.categories.update, { id, name: 'Hack' }),- ).rejects.toThrow('Not found')- })-it('prevents setting self as parent', async () => {const t = convexTest(schema, modules)const id = await t.mutation(api.categories.create, validCategory)@@ -155,7 +116,9 @@ describe('convex/categories', () => {const t = convexTest(schema, modules)const parentId = await t.mutation(api.categories.create, validCategory)const childId = await t.mutation(api.categories.create, {- ...validCategory, name: 'Groceries', parentId,+ ...validCategory,+ name: 'Groceries',+ parentId,})await t.mutation(api.categories.updateWithChildren, {@@ -186,26 +149,6 @@ describe('convex/categories', () => {})})- describe('list', () => {- it('returns null for unauthenticated user', async () => {- const t = convexTest(schema, modules)- setMockUser(null)- expect(await t.query(api.categories.list)).toBeNull()- })-- it('returns only own categories', async () => {- const t = convexTest(schema, modules)- await t.mutation(api.categories.create, validCategory)-- setMockUser('other-user')- await t.mutation(api.categories.create, { ...validCategory, name: 'Other' })-- const result = await t.query(api.categories.list)- expect(result).toHaveLength(1)- expect(result![0].name).toBe('Other')- })- })-describe('remove (cascade)', () => {it('deletes category and its transactions', async () => {const t = convexTest(schema, modules)@@ -213,7 +156,11 @@ describe('convex/categories', () => {const catId = await t.mutation(api.categories.create, validCategory)await t.mutation(api.trns.create, {- amount: 50, categoryId: catId, date: Date.now(), type: 0, walletId,+ amount: 50,+ categoryId: catId,+ date: Date.now(),+ type: 0,+ walletId,})await t.action(api.categories.remove, { id: catId })@@ -227,7 +174,9 @@ describe('convex/categories', () => {const t = convexTest(schema, modules)const parentId = await t.mutation(api.categories.create, validCategory)await t.mutation(api.categories.create, {- ...validCategory, name: 'Child', parentId,+ ...validCategory,+ name: 'Child',+ parentId,})await expect(diff --git a/convex/shared.test.ts b/convex/shared.test.tsindex de6c420c..6e54320f 100644--- a/convex/shared.test.ts+++ b/convex/shared.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest'-import { AMOUNT_MAX, CREDIT_LIMIT_MAX, DATE_MAX, DATE_MIN, validateNumberRange, validateStringLength } from './shared'+import { validateNumberRange, validateStringLength } from './shared'describe('convex/shared validators', () => {describe('validateStringLength', () => {@@ -51,22 +51,4 @@ describe('convex/shared validators', () => {.toThrow('Amount must be between 0 and 100')})})-- describe('constants', () => {- it('DATE_MIN is 2000-01-01', () => {- expect(new Date(DATE_MIN).toISOString()).toBe('2000-01-01T00:00:00.000Z')- })-- it('DATE_MAX is 2100-01-01', () => {- expect(new Date(DATE_MAX).toISOString()).toBe('2100-01-01T00:00:00.000Z')- })-- it('AMOUNT_MAX is 1 trillion', () => {- expect(AMOUNT_MAX).toBe(1_000_000_000_000)- })-- it('CREDIT_LIMIT_MAX is 1 billion', () => {- expect(CREDIT_LIMIT_MAX).toBe(1_000_000_000)- })- })})diff --git a/convex/trns.test.ts b/convex/trns.test.tsindex 0193e1c6..d0b47276 100644--- a/convex/trns.test.ts+++ b/convex/trns.test.ts@@ -6,12 +6,19 @@ import schema from './schema'import { modules, setMockUser } from './test-utils/setup'const validWallet = {- color: '#000', currency: 'USD', name: 'Cash', order: 0, type: 'cash' as const,+ color: '#000',+ currency: 'USD',+ name: 'Cash',+ order: 0,+ type: 'cash' as const,}const validCategory = {- color: '#ff0000', icon: 'food', name: 'Food',- showInLastUsed: true, showInQuickSelector: true,+ color: '#ff0000',+ icon: 'food',+ name: 'Food',+ showInLastUsed: true,+ showInQuickSelector: true,}async function setupWalletAndCategory(t: ReturnType<typeof convexTest>) {@@ -27,13 +34,17 @@ async function setupTwoWallets(t: ReturnType<typeof convexTest>) {}describe('convex/trns', () => {- describe('create — expense/income', () => {+ describe('create — expense', () => {it('creates an expense transaction', async () => {const t = convexTest(schema, modules)const { categoryId, walletId } = await setupWalletAndCategory(t)const id = await t.mutation(api.trns.create, {- amount: 42.5, categoryId, date: Date.now(), type: 0, walletId,+ amount: 42.5,+ categoryId,+ date: Date.now(),+ type: 0,+ walletId,})const trns = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })@@ -48,24 +59,16 @@ describe('convex/trns', () => {})})- it('creates an income transaction', async () => {- const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)-- await t.mutation(api.trns.create, {- amount: 1000, categoryId, date: Date.now(), type: 1, walletId,- })-- const trns = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })- expect(trns!.page[0].type).toBe(1)- })-it('creates an adjustment transaction', async () => {const t = convexTest(schema, modules)const { walletId } = await setupWalletAndCategory(t)const id = await t.mutation(api.trns.create, {- amount: 500, categoryId: 'adjustment', date: Date.now(), type: 0, walletId,+ amount: 500,+ categoryId: 'adjustment',+ date: Date.now(),+ type: 0,+ walletId,})expect(id).toBeDefined()})@@ -76,18 +79,11 @@ describe('convex/trns', () => {await expect(t.mutation(api.trns.create, {- amount: 0, categoryId, date: Date.now(), type: 0, walletId,- }),- ).rejects.toThrow('Amount must be positive')- })-- it('throws for negative amount', async () => {- const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)-- await expect(- t.mutation(api.trns.create, {- amount: -10, categoryId, date: Date.now(), type: 0, walletId,+ amount: 0,+ categoryId,+ date: Date.now(),+ type: 0,+ walletId,}),).rejects.toThrow('Amount must be positive')})@@ -98,33 +94,28 @@ describe('convex/trns', () => {await expect(t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0,+ amount: 100,+ categoryId,+ date: Date.now(),+ type: 0,}),).rejects.toThrow('Wallet is required')})- it('throws without category', async () => {- const t = convexTest(schema, modules)- const { walletId } = await setupWalletAndCategory(t)-- await expect(- t.mutation(api.trns.create, {- amount: 100, date: Date.now(), type: 0, walletId,- }),- ).rejects.toThrow('Category is required')- })-it('throws for wallet owned by another user', async () => {const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)+ const { walletId } = await setupWalletAndCategory(t)- // Create category as other-usersetMockUser('other-user')const otherCat = await t.mutation(api.categories.create, { ...validCategory, name: 'Other' })await expect(t.mutation(api.trns.create, {- amount: 100, categoryId: otherCat, date: Date.now(), type: 0, walletId,+ amount: 100,+ categoryId: otherCat,+ date: Date.now(),+ type: 0,+ walletId,}),).rejects.toThrow('Wallet not found')})@@ -135,7 +126,11 @@ describe('convex/trns', () => {await expect(t.mutation(api.trns.create, {- amount: 100, categoryId: 'transfer', date: Date.now(), type: 0, walletId,+ amount: 100,+ categoryId: 'transfer',+ date: Date.now(),+ type: 0,+ walletId,}),).rejects.toThrow('categoryId "transfer" is only allowed for Transfer type')})@@ -160,9 +155,7 @@ describe('convex/trns', () => {_id: id,categoryId: 'transfer',expenseAmount: 100,- expenseWalletId: w1,incomeAmount: 95,- incomeWalletId: w2,type: 2,})})@@ -171,42 +164,16 @@ describe('convex/trns', () => {const t = convexTest(schema, modules)const { w1 } = await setupTwoWallets(t)- await expect(- t.mutation(api.trns.create, {- date: Date.now(),- expenseAmount: 100, expenseWalletId: w1,- incomeAmount: 100, incomeWalletId: w1,- type: 2,- }),- ).rejects.toThrow('Transfer wallets must be different')- })-- it('throws for missing expense wallet', async () => {- const t = convexTest(schema, modules)- const { w2 } = await setupTwoWallets(t)-await expect(t.mutation(api.trns.create, {date: Date.now(),expenseAmount: 100,- incomeAmount: 100, incomeWalletId: w2,+ expenseWalletId: w1,+ incomeAmount: 100,+ incomeWalletId: w1,type: 2,}),- ).rejects.toThrow('Transfer requires both wallets')- })-- it('throws for zero expense amount', async () => {- const t = convexTest(schema, modules)- const { w1, w2 } = await setupTwoWallets(t)-- await expect(- t.mutation(api.trns.create, {- date: Date.now(),- expenseAmount: 0, expenseWalletId: w1,- incomeAmount: 100, incomeWalletId: w2,- type: 2,- }),- ).rejects.toThrow('Transfer expense amount must be positive')+ ).rejects.toThrow('Transfer wallets must be different')})it('throws for non-"transfer" categoryId', async () => {@@ -218,48 +185,26 @@ describe('convex/trns', () => {t.mutation(api.trns.create, {categoryId: catId,date: Date.now(),- expenseAmount: 100, expenseWalletId: w1,- incomeAmount: 100, incomeWalletId: w2,+ expenseAmount: 100,+ expenseWalletId: w1,+ incomeAmount: 100,+ incomeWalletId: w2,type: 2,}),).rejects.toThrow('Transfer categoryId must be "transfer"')})})- describe('update', () => {- it('updates transaction fields', async () => {- const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)- const id = await t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0, walletId,- })-- await t.mutation(api.trns.update, { id, amount: 200, desc: 'Lunch' })-- const trns = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })- expect(trns!.page[0]).toMatchObject({ amount: 200, desc: 'Lunch' })- })-- it('throws for trn owned by another user', async () => {- const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)- const id = await t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0, walletId,- })-- setMockUser('other-user')- await expect(- t.mutation(api.trns.update, { id, amount: 999 }),- ).rejects.toThrow('Not found')- })- })-describe('remove', () => {it('removes a transaction', async () => {const t = convexTest(schema, modules)const { categoryId, walletId } = await setupWalletAndCategory(t)const id = await t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0, walletId,+ amount: 100,+ categoryId,+ date: Date.now(),+ type: 0,+ walletId,})await t.mutation(api.trns.remove, { id })@@ -272,13 +217,16 @@ describe('convex/trns', () => {const t = convexTest(schema, modules)const { categoryId, walletId } = await setupWalletAndCategory(t)const id = await t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0, walletId,+ amount: 100,+ categoryId,+ date: Date.now(),+ type: 0,+ walletId,})setMockUser('other-user')await t.mutation(api.trns.remove, { id })- // Trn still existssetMockUser('test-user-id')const trns = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })expect(trns!.page).toHaveLength(1)@@ -286,12 +234,6 @@ describe('convex/trns', () => {})describe('idsHash', () => {- it('returns null for unauthenticated user', async () => {- const t = convexTest(schema, modules)- setMockUser(null)- expect(await t.query(api.trns.idsHash)).toBeNull()- })-it('returns consistent hash after create+delete cycle (XOR symmetry)', async () => {const t = convexTest(schema, modules)const { categoryId, walletId } = await setupWalletAndCategory(t)@@ -299,7 +241,11 @@ describe('convex/trns', () => {const hashBefore = await t.query(api.trns.idsHash)const id = await t.mutation(api.trns.create, {- amount: 50, categoryId, date: Date.now(), type: 0, walletId,+ amount: 50,+ categoryId,+ date: Date.now(),+ type: 0,+ walletId,})await t.mutation(api.trns.remove, { id })@@ -307,28 +253,4 @@ describe('convex/trns', () => {expect(hashAfter!.hash).toBe(hashBefore!.hash)})})-- describe('delta', () => {- it('returns null for unauthenticated user', async () => {- const t = convexTest(schema, modules)- setMockUser(null)- expect(await t.query(api.trns.delta, {- paginationOpts: { cursor: null, numItems: 10 }, since: 0,- })).toBeNull()- })-- it('returns transactions for authenticated user', async () => {- const t = convexTest(schema, modules)- const { categoryId, walletId } = await setupWalletAndCategory(t)-- await t.mutation(api.trns.create, {- amount: 100, categoryId, date: Date.now(), type: 0, walletId,- })-- const result = await t.query(api.trns.delta, {- paginationOpts: { cursor: null, numItems: 10 }, since: 0,- })- expect(result!.page).toHaveLength(1)- })- })})diff --git a/convex/wallets.test.ts b/convex/wallets.test.tsindex 55526a1d..006ad2b5 100644--- a/convex/wallets.test.ts+++ b/convex/wallets.test.ts@@ -1,7 +1,7 @@import { convexTest } from 'convex-test'import { describe, expect, it } from 'vitest'-import { api, internal } from './_generated/api'+import { api } from './_generated/api'import schema from './schema'import { modules, setMockUser } from './test-utils/setup'@@ -31,27 +31,6 @@ describe('convex/wallets', () => {})})- it('creates with optional fields', async () => {- const t = convexTest(schema, modules)- await t.mutation(api.wallets.create, {- ...validWallet,- creditLimit: 5000,- desc: 'My wallet',- isArchived: true,- isWithdrawal: true,- type: 'credit',- })-- const wallets = await t.query(api.wallets.list)- expect(wallets![0]).toMatchObject({- creditLimit: 5000,- desc: 'My wallet',- isArchived: true,- isWithdrawal: true,- type: 'credit',- })- })-it('throws for empty name', async () => {const t = convexTest(schema, modules)await expect(@@ -59,34 +38,6 @@ describe('convex/wallets', () => {).rejects.toThrow('Name is required')})- it('throws for empty color', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.wallets.create, { ...validWallet, color: '' }),- ).rejects.toThrow('Color is required')- })-- it('throws for empty currency', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.wallets.create, { ...validWallet, currency: '' }),- ).rejects.toThrow('Currency is required')- })-- it('throws for name exceeding 100 chars', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.wallets.create, { ...validWallet, name: 'a'.repeat(101) }),- ).rejects.toThrow('Name must be at most 100 characters')- })-- it('throws for credit limit exceeding max', async () => {- const t = convexTest(schema, modules)- await expect(- t.mutation(api.wallets.create, { ...validWallet, creditLimit: 2_000_000_000 }),- ).rejects.toThrow('Credit limit must be between')- })-it('throws for unauthenticated user', async () => {const t = convexTest(schema, modules)setMockUser(null)@@ -100,10 +51,10 @@ describe('convex/wallets', () => {it('updates wallet fields', async () => {const t = convexTest(schema, modules)const id = await t.mutation(api.wallets.create, validWallet)- await t.mutation(api.wallets.update, { id, name: 'Updated', color: '#00ff00' })+ await t.mutation(api.wallets.update, { color: '#00ff00', id, name: 'Updated' })const wallets = await t.query(api.wallets.list)- expect(wallets![0]).toMatchObject({ name: 'Updated', color: '#00ff00' })+ expect(wallets![0]).toMatchObject({ color: '#00ff00', name: 'Updated' })})it('throws for wallet owned by another user', async () => {@@ -115,14 +66,6 @@ describe('convex/wallets', () => {t.mutation(api.wallets.update, { id, name: 'Hack' }),).rejects.toThrow('Not found')})-- it('throws for empty name on update', async () => {- const t = convexTest(schema, modules)- const id = await t.mutation(api.wallets.create, validWallet)- await expect(- t.mutation(api.wallets.update, { id, name: ' ' }),- ).rejects.toThrow('Name is required')- })})describe('updateOrder', () => {@@ -141,16 +84,6 @@ describe('convex/wallets', () => {expect(w1.order).toBe(1)expect(w2.order).toBe(0)})-- it('throws for wallet owned by another user', async () => {- const t = convexTest(schema, modules)- const id = await t.mutation(api.wallets.create, validWallet)-- setMockUser('other-user')- await expect(- t.mutation(api.wallets.updateOrder, { orders: [{ id, order: 5 }] }),- ).rejects.toThrow('Not found')- })})describe('list', () => {@@ -178,32 +111,27 @@ describe('convex/wallets', () => {const t = convexTest(schema, modules)const walletId = await t.mutation(api.wallets.create, validWallet)- // Create a category for the trnconst catId = await t.mutation(api.categories.create, {- color: '#000', icon: 'food', name: 'Food',- showInLastUsed: true, showInQuickSelector: true,+ color: '#000',+ icon: 'food',+ name: 'Food',+ showInLastUsed: true,+ showInQuickSelector: true,})- // Create trn referencing this walletawait t.mutation(api.trns.create, {- amount: 100, categoryId: catId, date: Date.now(),- type: 0, walletId,+ amount: 100,+ categoryId: catId,+ date: Date.now(),+ type: 0,+ walletId,})- // Verify trn exists- const trnsBefore = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })- expect(trnsBefore!.page).toHaveLength(1)-- // Remove wallet (cascade action)await t.action(api.wallets.remove, { id: walletId })- // Wallet gone- const wallets = await t.query(api.wallets.list)- expect(wallets).toHaveLength(0)-- // Trn gone too- const trnsAfter = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })- expect(trnsAfter!.page).toHaveLength(0)+ expect(await t.query(api.wallets.list)).toHaveLength(0)+ const trns = await t.query(api.trns.list, { paginationOpts: { cursor: null, numItems: 10 } })+ expect(trns!.page).toHaveLength(0)})})})