Bug/gh issues fiz (#1103)
* refactor: optimize page loading and data fetching * fix: resolve recurring production runtime errors * feat: add MCP company and customer updates * fix: handle year-end tax adjustments * feat: harden annual report compliance * fix: expand invoice logo and font support * fix: sanitize API route error responses * fix: sanitize user-facing error messages * feat: persist onboarding and tax assessment notices * fix: reduce cloud backup audit churn * feat: refine invoice editor layout * fix: show saved tax adjustments in INK2 * fix: complete annual report API mappings * docs: record operational safeguards and decisions * fix: harden annual report review findings * fix: adjust column span for description based on VAT registration * New css class name
This commit is contained in:
@@ -153,7 +153,7 @@ function makeSupabase(data: MockData) {
|
||||
return resolve({ data: [], error: null })
|
||||
},
|
||||
}
|
||||
const passthrough = ['select', 'eq', 'in', 'order', 'range', 'limit']
|
||||
const passthrough = ['select', 'eq', 'neq', 'in', 'order', 'range', 'limit']
|
||||
for (const method of passthrough) {
|
||||
chain[method] = vi.fn().mockImplementation((col?: string, val?: string) => {
|
||||
if (method === 'eq' && col === 'key') key = val ?? null
|
||||
@@ -162,7 +162,7 @@ function makeSupabase(data: MockData) {
|
||||
}
|
||||
return chain
|
||||
})
|
||||
return { supabase: { from } as any, upsert }
|
||||
return { supabase: { from } as any, from, upsert }
|
||||
}
|
||||
|
||||
function syncParams(supabase: any, overrides: Record<string, unknown> = {}) {
|
||||
@@ -310,6 +310,22 @@ describe('performSync needs_reauth handling', () => {
|
||||
})
|
||||
|
||||
describe('performSync per-fiscal-year layout', () => {
|
||||
it('ignores extension runtime state when fingerprinting Grunddata', async () => {
|
||||
const { supabase, from } = makeSupabase({
|
||||
connection: makeConnection(),
|
||||
lastSync: upToDateLastSync(),
|
||||
})
|
||||
|
||||
await performSync(syncParams(supabase))
|
||||
|
||||
const auditCallIndex = from.mock.calls.findIndex(([table]) => table === 'audit_log')
|
||||
expect(auditCallIndex).toBeGreaterThanOrEqual(0)
|
||||
const auditQuery = from.mock.results[auditCallIndex].value
|
||||
expect(auditQuery.neq).toHaveBeenCalledWith('table_name', 'extension_data')
|
||||
expect(auditQuery.order).toHaveBeenNthCalledWith(1, 'created_at', { ascending: false })
|
||||
expect(auditQuery.order).toHaveBeenNthCalledWith(2, 'id', { ascending: false })
|
||||
})
|
||||
|
||||
it('uploads one archive per period plus Grunddata and the folder README on first sync', async () => {
|
||||
const { supabase, upsert } = makeSupabase({ connection: makeConnection() })
|
||||
|
||||
|
||||
@@ -494,12 +494,18 @@ async function fetchLatestAuditAt(
|
||||
supabase: SupabaseClient,
|
||||
companyId: string
|
||||
): Promise<string> {
|
||||
const { data } = await supabase
|
||||
const { data, error } = await supabase
|
||||
.from('audit_log')
|
||||
.select('created_at')
|
||||
.eq('company_id', companyId)
|
||||
// extension_data is non-portable runtime state and includes this sync's
|
||||
// own progress snapshots. Letting those rows advance the watermark makes
|
||||
// every completed backup invalidate Grunddata for the next run.
|
||||
.neq('table_name', 'extension_data')
|
||||
.order('created_at', { ascending: false })
|
||||
.order('id', { ascending: false })
|
||||
.limit(1)
|
||||
if (error) throw new Error(`Failed to fetch backup audit watermark: ${error.message}`)
|
||||
const rows = (data as { created_at: string }[] | null) ?? []
|
||||
return rows[0]?.created_at ?? ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user