From 3e6652e46086d0f9a3e8568a5e2528575f11b10f Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 00:46:48 +0100
Subject: [PATCH 1/7] fix: show a retryable error on RequireAuth failure and
preserve query and hash on login redirect
---
frontend/src/app/RequireAuth.test.tsx | 83 +++++++++++++++++++
frontend/src/app/RequireAuth.tsx | 25 ++++--
frontend/src/features/auth/LoginPage.test.tsx | 32 ++++++-
3 files changed, 132 insertions(+), 8 deletions(-)
create mode 100644 frontend/src/app/RequireAuth.test.tsx
diff --git a/frontend/src/app/RequireAuth.test.tsx b/frontend/src/app/RequireAuth.test.tsx
new file mode 100644
index 0000000..d00494a
--- /dev/null
+++ b/frontend/src/app/RequireAuth.test.tsx
@@ -0,0 +1,83 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { useLocation } from 'react-router'
+import { jsonResponse, renderRoutes } from '@/test/utils'
+import type { LoginLocationState } from '@/features/auth/LoginPage'
+import { RequireAuth } from './RequireAuth'
+
+function LoginProbe() {
+ const location = useLocation()
+ const state = location.state as LoginLocationState
+ return
Loading…
@@ -14,8 +16,21 @@ export function RequireAuth() {
)
}
- if (!me) {
- return
+ if (!meQuery.data && meQuery.isError) {
+ return (
+
+ meQuery.refetch()}
+ isRetrying={meQuery.isFetching}
+ />
+
+ )
+ }
+
+ if (!meQuery.data) {
+ const from = `${location.pathname}${location.search}${location.hash}`
+ return
}
return
diff --git a/frontend/src/features/auth/LoginPage.test.tsx b/frontend/src/features/auth/LoginPage.test.tsx
index fb80385..3e9eac3 100644
--- a/frontend/src/features/auth/LoginPage.test.tsx
+++ b/frontend/src/features/auth/LoginPage.test.tsx
@@ -2,7 +2,7 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
-import { createMemoryRouter, RouterProvider } from 'react-router'
+import { createMemoryRouter, RouterProvider, type InitialEntry } from 'react-router'
import { TestI18nProvider } from '@/test/i18n'
import { LoginPage } from './LoginPage'
@@ -14,14 +14,15 @@ vi.mock('@/api/auth', async () => {
}
})
-function renderLogin() {
+function renderLogin(initialEntry: InitialEntry = '/login') {
const queryClient = new QueryClient({ defaultOptions: { mutations: { retry: false } } })
const router = createMemoryRouter(
[
{ path: '/login', element:
},
{ path: '/', element:
Feed home
},
+ { path: '/add', element:
Add screen
},
],
- { initialEntries: ['/login'] },
+ { initialEntries: [initialEntry] },
)
render(
@@ -109,4 +110,29 @@ describe('LoginPage', () => {
await waitFor(() => expect(router.state.location.pathname).toBe('/'))
expect(await screen.findByText('Feed home')).toBeInTheDocument()
})
+
+ it('navigates back to the saved path including query string and hash', async () => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn().mockResolvedValue(
+ new Response(JSON.stringify({ id: 1, email: 'alice@example.com' }), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ }),
+ ),
+ )
+ const router = renderLogin({
+ pathname: '/login',
+ state: { from: '/add?tab=payment&contact=2#note' },
+ })
+
+ await userEvent.type(screen.getByLabelText('Email'), 'alice@example.com')
+ await userEvent.type(screen.getByLabelText('Password'), 'secret')
+ await userEvent.click(screen.getByRole('button', { name: 'Sign in' }))
+
+ await waitFor(() => expect(router.state.location.pathname).toBe('/add'))
+ expect(router.state.location.search).toBe('?tab=payment&contact=2')
+ expect(router.state.location.hash).toBe('#note')
+ expect(await screen.findByText('Add screen')).toBeInTheDocument()
+ })
})
From 3204694e6bd5e4c96ae04bbbf50d3c5365f1815d Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 00:46:48 +0100
Subject: [PATCH 2/7] fix: add a catch-all not-found route and root
errorElement to the router
---
frontend/src/app/ErrorPages.tsx | 63 ++++++++++++++++++++++++++++++
frontend/src/app/router.test.tsx | 67 ++++++++++++++++++++++++++++++++
frontend/src/app/router.tsx | 47 +++++++++++++---------
3 files changed, 158 insertions(+), 19 deletions(-)
create mode 100644 frontend/src/app/ErrorPages.tsx
create mode 100644 frontend/src/app/router.test.tsx
diff --git a/frontend/src/app/ErrorPages.tsx b/frontend/src/app/ErrorPages.tsx
new file mode 100644
index 0000000..531e07d
--- /dev/null
+++ b/frontend/src/app/ErrorPages.tsx
@@ -0,0 +1,63 @@
+import { Link, isRouteErrorResponse, useRouteError } from 'react-router'
+import { CircleAlert, RefreshCw, SearchX } from 'lucide-react'
+import { Trans, useLingui } from '@lingui/react/macro'
+import { BackLink } from '@/components/BackLink'
+import { PageHeader } from '@/components/PageHeader'
+import { StateMessage } from '@/components/StateMessage'
+import { Button } from '@/components/ui/button'
+import { buttonClassName } from '@/components/ui/button-variants'
+
+function NotFoundMessage() {
+ const { t } = useLingui()
+ return (
+ }
+ title={t`This page doesn’t exist`}
+ description={t`Check the address or go back to your contacts.`}
+ >
+
+ Go to contacts
+
+
+ )
+}
+
+export function NotFoundPage() {
+ const { t } = useLingui()
+ return (
+ <>
+ } />
+
+ >
+ )
+}
+
+export function RouteErrorPage() {
+ const { t } = useLingui()
+ const error = useRouteError()
+
+ if (isRouteErrorResponse(error) && error.status === 404) {
+ return (
+
+
+
+ )
+ }
+
+ return (
+
+ }
+ iconClassName="bg-destructive/10 text-destructive"
+ title={t`Something went wrong`}
+ description={t`Reload the page to try again.`}
+ >
+
+
+
+ )
+}
diff --git a/frontend/src/app/router.test.tsx b/frontend/src/app/router.test.tsx
new file mode 100644
index 0000000..b8ff94a
--- /dev/null
+++ b/frontend/src/app/router.test.tsx
@@ -0,0 +1,67 @@
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { screen } from '@testing-library/react'
+import { jsonResponse, renderRoutes } from '@/test/utils'
+import { routes } from './router'
+
+const me = { id: 1, email: 'ame@example.com', name: 'Ame' }
+
+afterEach(() => {
+ vi.unstubAllGlobals()
+ vi.restoreAllMocks()
+})
+
+describe('router', () => {
+ it('renders a not-found screen inside AppShell for unknown routes', async () => {
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse(200, me)))
+ renderRoutes(routes, '/nope')
+
+ expect(
+ await screen.findByRole('heading', { name: 'This page doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('navigation', { name: 'Main' })).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Go to contacts' })).toHaveAttribute('href', '/')
+ expect(screen.queryByText(/Hey developer/)).not.toBeInTheDocument()
+ })
+
+ it('redirects unknown routes to /login when signed out', async () => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn().mockResolvedValue(jsonResponse(401, { status: 401, title: 'Unauthorized' })),
+ )
+ const router = renderRoutes(routes, '/nope?x=1')
+
+ expect(await screen.findByRole('heading', { name: 'Sign in' })).toBeInTheDocument()
+ expect(router.state.location.pathname).toBe('/login')
+ })
+
+ it('keeps specific routes outside AppShell matched ahead of the catch-all', async () => {
+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse(200, me)))
+ renderRoutes(routes, '/expenses/abc')
+
+ expect(
+ await screen.findByRole('heading', { name: 'This expense doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(screen.queryByRole('navigation', { name: 'Main' })).not.toBeInTheDocument()
+ })
+
+ it('renders the root errorElement instead of React Router’s developer page on crash', async () => {
+ vi.spyOn(console, 'error').mockImplementation(() => {})
+ function Boom(): never {
+ throw new Error('render failure')
+ }
+ const rootErrorElement = routes[0].errorElement
+ renderRoutes(
+ [
+ {
+ errorElement: rootErrorElement,
+ children: [{ path: '/boom', element: }],
+ },
+ ],
+ '/boom',
+ )
+
+ expect(await screen.findByRole('alert')).toHaveTextContent('Something went wrong')
+ expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument()
+ expect(screen.queryByText(/Hey developer/)).not.toBeInTheDocument()
+ })
+})
diff --git a/frontend/src/app/router.tsx b/frontend/src/app/router.tsx
index ea5372c..019f8aa 100644
--- a/frontend/src/app/router.tsx
+++ b/frontend/src/app/router.tsx
@@ -1,5 +1,6 @@
-import { createBrowserRouter } from 'react-router'
+import { createBrowserRouter, type RouteObject } from 'react-router'
import { AppShell } from './AppShell'
+import { NotFoundPage, RouteErrorPage } from './ErrorPages'
import { RequireAuth } from './RequireAuth'
import { LoginPage } from '@/features/auth/LoginPage'
import { SignUpPage } from '@/features/auth/SignUpPage'
@@ -16,29 +17,37 @@ import { EditContactPage } from '@/features/contacts/EditContactPage'
import { ProfilePage } from '@/features/profile/ProfilePage'
import { EditNamePage } from '@/features/profile/EditNamePage'
-export const router = createBrowserRouter([
- { path: '/login', element: },
- { path: '/signup', element: },
+export const routes: RouteObject[] = [
{
- element: ,
+ errorElement: ,
children: [
+ { path: '/login', element: },
+ { path: '/signup', element: },
{
- element: ,
+ element: ,
children: [
- { index: true, element: },
- { path: 'activity', element: },
- { path: 'profile', element: },
- { path: 'contacts/:userId', element: },
+ {
+ element: ,
+ children: [
+ { index: true, element: },
+ { path: 'activity', element: },
+ { path: 'profile', element: },
+ { path: 'contacts/:userId', element: },
+ { path: '*', element: },
+ ],
+ },
+ { path: 'contacts/new', element: },
+ { path: 'contacts/:userId/edit', element: },
+ { path: 'profile/name', element: },
+ { path: 'expenses/:id', element: },
+ { path: 'transfers/:id', element: },
+ { path: 'add', element: },
+ { path: 'expenses/:id/edit', element: },
+ { path: 'transfers/:id/edit', element: },
],
},
- { path: 'contacts/new', element: },
- { path: 'contacts/:userId/edit', element: },
- { path: 'profile/name', element: },
- { path: 'expenses/:id', element: },
- { path: 'transfers/:id', element: },
- { path: 'add', element: },
- { path: 'expenses/:id/edit', element: },
- { path: 'transfers/:id/edit', element: },
],
},
-])
+]
+
+export const router = createBrowserRouter(routes)
From 63d2d0caecdd2752232bc0faf7b66d94e1b96b4a Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 00:46:48 +0100
Subject: [PATCH 3/7] fix: give contact not-found headers a title and cover
edit not-found states
---
.../src/features/add/EditExpensePage.test.tsx | 22 ++++++++++
.../features/add/EditTransferPage.test.tsx | 42 +++++++++++++++++++
.../src/features/contacts/ContactNotFound.tsx | 7 +++-
.../features/contacts/ContactPage.test.tsx | 15 ++++++-
.../src/features/contacts/ContactPage.tsx | 1 +
.../contacts/EditContactPage.test.tsx | 16 +++++--
.../src/features/contacts/EditContactPage.tsx | 13 +++++-
7 files changed, 108 insertions(+), 8 deletions(-)
diff --git a/frontend/src/features/add/EditExpensePage.test.tsx b/frontend/src/features/add/EditExpensePage.test.tsx
index 15b2227..255d525 100644
--- a/frontend/src/features/add/EditExpensePage.test.tsx
+++ b/frontend/src/features/add/EditExpensePage.test.tsx
@@ -90,4 +90,26 @@ describe('EditExpensePage with a malformed id', () => {
false,
)
})
+
+ it('shows StateMessage with a way back when the expense is not found (404)', async () => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async (path: string) => {
+ if (path === '/api/me') return jsonResponse(200, me)
+ return jsonResponse(404, { status: 404, title: 'Not Found' })
+ }),
+ )
+ renderRoutes(
+ [{ path: '/expenses/:id/edit', element: }],
+ '/expenses/999999/edit',
+ )
+
+ expect(
+ await screen.findByRole('heading', { name: 'This expense doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Go to activity' })).toHaveAttribute(
+ 'href',
+ '/activity',
+ )
+ })
})
diff --git a/frontend/src/features/add/EditTransferPage.test.tsx b/frontend/src/features/add/EditTransferPage.test.tsx
index bc6648d..a782a5e 100644
--- a/frontend/src/features/add/EditTransferPage.test.tsx
+++ b/frontend/src/features/add/EditTransferPage.test.tsx
@@ -70,4 +70,46 @@ describe('EditTransferPage', () => {
description: 'BLIK',
})
})
+
+ it('shows not found without calling the API for a malformed id', async () => {
+ const fetchMock = vi.fn(async (_path: string) => jsonResponse(200, me))
+ vi.stubGlobal('fetch', fetchMock)
+ renderRoutes(
+ [{ path: '/transfers/:id/edit', element: }],
+ '/transfers/abc/edit',
+ )
+
+ expect(
+ await screen.findByRole('heading', { name: 'This payment doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Go to activity' })).toHaveAttribute(
+ 'href',
+ '/activity',
+ )
+ expect(fetchMock.mock.calls.some(([path]) => String(path).startsWith('/api/transfers'))).toBe(
+ false,
+ )
+ })
+
+ it('shows StateMessage with a way back when the payment is not found (404)', async () => {
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async (path: string) => {
+ if (path === '/api/me') return jsonResponse(200, me)
+ return jsonResponse(404, { status: 404, title: 'Not Found' })
+ }),
+ )
+ renderRoutes(
+ [{ path: '/transfers/:id/edit', element: }],
+ '/transfers/999999/edit',
+ )
+
+ expect(
+ await screen.findByRole('heading', { name: 'This payment doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('link', { name: 'Go to activity' })).toHaveAttribute(
+ 'href',
+ '/activity',
+ )
+ })
})
diff --git a/frontend/src/features/contacts/ContactNotFound.tsx b/frontend/src/features/contacts/ContactNotFound.tsx
index 1afee23..b1d6f03 100644
--- a/frontend/src/features/contacts/ContactNotFound.tsx
+++ b/frontend/src/features/contacts/ContactNotFound.tsx
@@ -6,11 +6,14 @@ import { PageHeader } from '@/components/PageHeader'
import { StateMessage } from '@/components/StateMessage'
import { buttonClassName } from '@/components/ui/button-variants'
-export function ContactNotFound() {
+export function ContactNotFound({ title }: { title?: string } = {}) {
const { t } = useLingui()
return (
<>
- } />
+ }
+ />
>
)
diff --git a/frontend/src/features/contacts/ContactPage.test.tsx b/frontend/src/features/contacts/ContactPage.test.tsx
index 57b80d5..2269d93 100644
--- a/frontend/src/features/contacts/ContactPage.test.tsx
+++ b/frontend/src/features/contacts/ContactPage.test.tsx
@@ -155,9 +155,22 @@ describe('ContactPage', () => {
expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument()
})
- it('says the contact was not found for an unknown or invalid id', async () => {
+ it('says the contact was not found with a header title for an unknown or invalid id', async () => {
stubApi([contact()])
renderContact(99)
expect(await screen.findByRole('heading', { name: 'Contact not found' })).toBeInTheDocument()
+ expect(
+ within(screen.getByRole('banner')).getByRole('heading', { name: 'Contact' }),
+ ).toBeInTheDocument()
+ })
+
+ it('shows contact not found with a header title for a non-numeric id without calling the API', async () => {
+ const fetchMock = stubApi([contact()])
+ renderContact('abc')
+ expect(await screen.findByRole('heading', { name: 'Contact not found' })).toBeInTheDocument()
+ expect(
+ within(screen.getByRole('banner')).getByRole('heading', { name: 'Contact' }),
+ ).toBeInTheDocument()
+ expect(fetchMock).not.toHaveBeenCalled()
})
})
diff --git a/frontend/src/features/contacts/ContactPage.tsx b/frontend/src/features/contacts/ContactPage.tsx
index f0925a2..08bc390 100644
--- a/frontend/src/features/contacts/ContactPage.tsx
+++ b/frontend/src/features/contacts/ContactPage.tsx
@@ -37,6 +37,7 @@ function ContactView({ userId }: { userId: number }) {
return (
<>
}
trailing={
contact && (
diff --git a/frontend/src/features/contacts/EditContactPage.test.tsx b/frontend/src/features/contacts/EditContactPage.test.tsx
index 80f988d..a7c4076 100644
--- a/frontend/src/features/contacts/EditContactPage.test.tsx
+++ b/frontend/src/features/contacts/EditContactPage.test.tsx
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { screen } from '@testing-library/react'
+import { screen, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import type { ContactListItem } from '@/api/types'
import { jsonResponse, renderRoutes } from '@/test/utils'
@@ -33,13 +33,13 @@ function putCalls(fetchMock: ReturnType) {
.map(([input, init]) => [input, JSON.parse(String(init?.body))])
}
-function renderEdit() {
+function renderEdit(userId: number | string = 2) {
return renderRoutes(
[
{ path: '/contacts/:userId/edit', element: },
{ path: '/contacts/:userId', element: Contact view
},
],
- '/contacts/2/edit',
+ `/contacts/${userId}/edit`,
)
}
@@ -117,4 +117,14 @@ describe('EditContactPage', () => {
expect(await screen.findByText('Nickname can be at most 64 characters.')).toBeInTheDocument()
expect(putCalls(fetchMock)).toEqual([])
})
+
+ it('shows contact not found with the Edit contact header for a missing contact', async () => {
+ stubApi()
+ renderEdit(99)
+
+ expect(await screen.findByRole('heading', { name: 'Contact not found' })).toBeInTheDocument()
+ expect(
+ within(screen.getByRole('banner')).getByRole('heading', { name: 'Edit contact' }),
+ ).toBeInTheDocument()
+ })
})
diff --git a/frontend/src/features/contacts/EditContactPage.tsx b/frontend/src/features/contacts/EditContactPage.tsx
index 791b3de..74fcfe3 100644
--- a/frontend/src/features/contacts/EditContactPage.tsx
+++ b/frontend/src/features/contacts/EditContactPage.tsx
@@ -32,10 +32,19 @@ const editContactSchema = z.object({
type EditContactValues = z.infer
+function EditContactNotFound() {
+ const { t } = useLingui()
+ return (
+
+
+
+ )
+}
+
export function EditContactPage() {
const userId = parseIdParam(useParams().userId)
- return userId === null ? :
+ return userId === null ? :
}
function EditContact({ userId }: { userId: number }) {
@@ -44,7 +53,7 @@ function EditContact({ userId }: { userId: number }) {
const contact = contactQuery.data
if (contact === null) {
- return
+ return
}
const shortName = contact ? getShortName(contact.person.displayName) : ''
From 76eb0a05a11acdc1a1b125db6d3d8b6b270edf45 Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 00:46:48 +0100
Subject: [PATCH 4/7] chore: extract and translate new UI error and not-found
copy
---
frontend/src/locales/en.po | 35 +++++++++++++++++++++++++++++++++++
frontend/src/locales/pl.po | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+)
diff --git a/frontend/src/locales/en.po b/frontend/src/locales/en.po
index 7c1291e..652fafb 100644
--- a/frontend/src/locales/en.po
+++ b/frontend/src/locales/en.po
@@ -307,6 +307,7 @@ msgstr "Amounts"
msgid "An account with this email already exists."
msgstr "An account with this email already exists."
+#: src/app/ErrorPages.tsx
#: src/features/contacts/EditContactPage.tsx
#: src/features/detail/DetailParts.tsx
msgid "Back"
@@ -363,6 +364,10 @@ msgstr "Change who paid"
msgid "Changes saved."
msgstr "Changes saved."
+#: src/app/ErrorPages.tsx
+msgid "Check the address or go back to your contacts."
+msgstr "Check the address or go back to your contacts."
+
#: src/features/add/SplitEditorSheet.tsx
msgid "Check the numbers"
msgstr "Check the numbers"
@@ -412,6 +417,11 @@ msgstr "Comment"
msgid "Comments"
msgstr "Comments"
+#: src/features/contacts/ContactNotFound.tsx
+#: src/features/contacts/ContactPage.tsx
+msgid "Contact"
+msgstr "Contact"
+
#: src/features/contacts/ContactNotFound.tsx
msgid "Contact not found"
msgstr "Contact not found"
@@ -489,6 +499,10 @@ msgstr "Couldn’t load this expense"
msgid "Couldn’t load this payment"
msgstr "Couldn’t load this payment"
+#: src/app/RequireAuth.tsx
+msgid "Couldn’t reach Settle"
+msgstr "Couldn’t reach Settle"
+
#: src/features/add/PaymentForm.tsx
msgid "Couldn’t record the payment. Nothing was saved and your entries are still here. Try again."
msgstr "Couldn’t record the payment. Nothing was saved and your entries are still here. Try again."
@@ -717,6 +731,7 @@ msgstr "Give someone a share"
msgid "Go to activity"
msgstr "Go to activity"
+#: src/app/ErrorPages.tsx
#: src/features/contacts/ContactNotFound.tsx
msgid "Go to contacts"
msgstr "Go to contacts"
@@ -946,6 +961,10 @@ msgstr "Nobody owes you for this"
msgid "Nobody shares this yet"
msgstr "Nobody shares this yet"
+#: src/app/ErrorPages.tsx
+msgid "Not found"
+msgstr "Not found"
+
#: src/features/add/PeopleField.tsx
msgid "Not in your contacts? Type their email."
msgstr "Not in your contacts? Type their email."
@@ -1105,6 +1124,14 @@ msgstr "Record payment"
msgid "Recording…"
msgstr "Recording…"
+#: src/app/ErrorPages.tsx
+msgid "Reload"
+msgstr "Reload"
+
+#: src/app/ErrorPages.tsx
+msgid "Reload the page to try again."
+msgstr "Reload the page to try again."
+
#: src/features/add/PeopleField.tsx
msgid "Remove {displayName}"
msgstr "Remove {displayName}"
@@ -1182,6 +1209,10 @@ msgstr "Signing in…"
msgid "Someone already added you? Sign up with that same email and your shared expenses will be waiting."
msgstr "Someone already added you? Sign up with that same email and your shared expenses will be waiting."
+#: src/app/ErrorPages.tsx
+msgid "Something went wrong"
+msgstr "Something went wrong"
+
#: src/features/auth/LoginPage.tsx
msgid "Something went wrong. Please try again."
msgstr "Something went wrong. Please try again."
@@ -1277,6 +1308,10 @@ msgstr "This can’t be undone."
msgid "This expense doesn’t exist"
msgstr "This expense doesn’t exist"
+#: src/app/ErrorPages.tsx
+msgid "This page doesn’t exist"
+msgstr "This page doesn’t exist"
+
#: src/components/ItemStates.tsx
msgid "This payment doesn’t exist"
msgstr "This payment doesn’t exist"
diff --git a/frontend/src/locales/pl.po b/frontend/src/locales/pl.po
index 872aaf0..8bf3ad5 100644
--- a/frontend/src/locales/pl.po
+++ b/frontend/src/locales/pl.po
@@ -307,6 +307,7 @@ msgstr "Kwoty"
msgid "An account with this email already exists."
msgstr "Konto z tym adresem e-mail już istnieje."
+#: src/app/ErrorPages.tsx
#: src/features/contacts/EditContactPage.tsx
#: src/features/detail/DetailParts.tsx
msgid "Back"
@@ -363,6 +364,10 @@ msgstr "Zmień, kto płaci"
msgid "Changes saved."
msgstr "Zapisano zmiany."
+#: src/app/ErrorPages.tsx
+msgid "Check the address or go back to your contacts."
+msgstr "Sprawdź adres albo wróć do kontaktów."
+
#: src/features/add/SplitEditorSheet.tsx
msgid "Check the numbers"
msgstr "Sprawdź wartości"
@@ -412,6 +417,11 @@ msgstr "Komentarz"
msgid "Comments"
msgstr "Komentarze"
+#: src/features/contacts/ContactNotFound.tsx
+#: src/features/contacts/ContactPage.tsx
+msgid "Contact"
+msgstr "Kontakt"
+
#: src/features/contacts/ContactNotFound.tsx
msgid "Contact not found"
msgstr "Nie znaleziono kontaktu"
@@ -489,6 +499,10 @@ msgstr "Nie udało się wczytać wydatku"
msgid "Couldn’t load this payment"
msgstr "Nie udało się wczytać płatności"
+#: src/app/RequireAuth.tsx
+msgid "Couldn’t reach Settle"
+msgstr "Nie udało się połączyć z Settle"
+
#: src/features/add/PaymentForm.tsx
msgid "Couldn’t record the payment. Nothing was saved and your entries are still here. Try again."
msgstr "Nie udało się zapisać płatności. Niczego nie zapisano, ale wpisane dane nie zniknęły. Spróbuj ponownie."
@@ -717,6 +731,7 @@ msgstr "Przydziel komuś udział"
msgid "Go to activity"
msgstr "Przejdź do aktywności"
+#: src/app/ErrorPages.tsx
#: src/features/contacts/ContactNotFound.tsx
msgid "Go to contacts"
msgstr "Przejdź do kontaktów"
@@ -946,6 +961,10 @@ msgstr "Nikt nie ma ci nic do oddania za ten wydatek"
msgid "Nobody shares this yet"
msgstr "Nikt jeszcze nie ma udziału w wydatku"
+#: src/app/ErrorPages.tsx
+msgid "Not found"
+msgstr "Nie znaleziono"
+
#: src/features/add/PeopleField.tsx
msgid "Not in your contacts? Type their email."
msgstr "Nie ma tej osoby w kontaktach? Wpisz jej adres e-mail."
@@ -1105,6 +1124,14 @@ msgstr "Zapisz płatność"
msgid "Recording…"
msgstr "Zapisywanie…"
+#: src/app/ErrorPages.tsx
+msgid "Reload"
+msgstr "Odśwież"
+
+#: src/app/ErrorPages.tsx
+msgid "Reload the page to try again."
+msgstr "Odśwież stronę, aby spróbować ponownie."
+
#: src/features/add/PeopleField.tsx
msgid "Remove {displayName}"
msgstr "Usuń: {displayName}"
@@ -1182,6 +1209,10 @@ msgstr "Logowanie…"
msgid "Someone already added you? Sign up with that same email and your shared expenses will be waiting."
msgstr "Dodano cię już do Settle? Załóż konto na ten sam adres e-mail, a wspólne wydatki będą na ciebie czekać."
+#: src/app/ErrorPages.tsx
+msgid "Something went wrong"
+msgstr "Coś poszło nie tak"
+
#: src/features/auth/LoginPage.tsx
msgid "Something went wrong. Please try again."
msgstr "Coś poszło nie tak. Spróbuj ponownie."
@@ -1277,6 +1308,10 @@ msgstr "Tego nie można cofnąć."
msgid "This expense doesn’t exist"
msgstr "Ten wydatek nie istnieje"
+#: src/app/ErrorPages.tsx
+msgid "This page doesn’t exist"
+msgstr "Ta strona nie istnieje"
+
#: src/components/ItemStates.tsx
msgid "This payment doesn’t exist"
msgstr "Ta płatność nie istnieje"
From 1f5884b415f0e08f699b45554e23f5516433ed99 Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 00:51:08 +0100
Subject: [PATCH 5/7] refactor: drop unreachable 404 branch in RouteErrorPage
and tidy review nits
---
frontend/src/app/ErrorPages.tsx | 36 ++++++-------------
.../src/features/add/EditExpensePage.test.tsx | 36 +++++++++----------
.../src/features/contacts/ContactNotFound.tsx | 2 +-
3 files changed, 29 insertions(+), 45 deletions(-)
diff --git a/frontend/src/app/ErrorPages.tsx b/frontend/src/app/ErrorPages.tsx
index 531e07d..d1f501c 100644
--- a/frontend/src/app/ErrorPages.tsx
+++ b/frontend/src/app/ErrorPages.tsx
@@ -1,4 +1,4 @@
-import { Link, isRouteErrorResponse, useRouteError } from 'react-router'
+import { Link } from 'react-router'
import { CircleAlert, RefreshCw, SearchX } from 'lucide-react'
import { Trans, useLingui } from '@lingui/react/macro'
import { BackLink } from '@/components/BackLink'
@@ -7,42 +7,26 @@ import { StateMessage } from '@/components/StateMessage'
import { Button } from '@/components/ui/button'
import { buttonClassName } from '@/components/ui/button-variants'
-function NotFoundMessage() {
- const { t } = useLingui()
- return (
- }
- title={t`This page doesn’t exist`}
- description={t`Check the address or go back to your contacts.`}
- >
-
- Go to contacts
-
-
- )
-}
-
export function NotFoundPage() {
const { t } = useLingui()
return (
<>
} />
-
+ }
+ title={t`This page doesn’t exist`}
+ description={t`Check the address or go back to your contacts.`}
+ >
+
+ Go to contacts
+
+
>
)
}
export function RouteErrorPage() {
const { t } = useLingui()
- const error = useRouteError()
-
- if (isRouteErrorResponse(error) && error.status === 404) {
- return (
-
-
-
- )
- }
return (
diff --git a/frontend/src/features/add/EditExpensePage.test.tsx b/frontend/src/features/add/EditExpensePage.test.tsx
index 255d525..ba524da 100644
--- a/frontend/src/features/add/EditExpensePage.test.tsx
+++ b/frontend/src/features/add/EditExpensePage.test.tsx
@@ -72,24 +72,6 @@ describe('EditExpensePage', () => {
description: null,
})
})
-})
-
-describe('EditExpensePage with a malformed id', () => {
- it('shows not found without loading anything', async () => {
- const fetchMock = vi.fn(async (_path: string) => jsonResponse(200, me))
- vi.stubGlobal('fetch', fetchMock)
- renderRoutes(
- [{ path: '/expenses/:id/edit', element: }],
- '/expenses/abc/edit',
- )
-
- expect(
- await screen.findByRole('heading', { name: 'This expense doesn’t exist' }),
- ).toBeInTheDocument()
- expect(fetchMock.mock.calls.some(([path]) => String(path).startsWith('/api/expenses'))).toBe(
- false,
- )
- })
it('shows StateMessage with a way back when the expense is not found (404)', async () => {
vi.stubGlobal(
@@ -113,3 +95,21 @@ describe('EditExpensePage with a malformed id', () => {
)
})
})
+
+describe('EditExpensePage with a malformed id', () => {
+ it('shows not found without loading anything', async () => {
+ const fetchMock = vi.fn(async (_path: string) => jsonResponse(200, me))
+ vi.stubGlobal('fetch', fetchMock)
+ renderRoutes(
+ [{ path: '/expenses/:id/edit', element: }],
+ '/expenses/abc/edit',
+ )
+
+ expect(
+ await screen.findByRole('heading', { name: 'This expense doesn’t exist' }),
+ ).toBeInTheDocument()
+ expect(fetchMock.mock.calls.some(([path]) => String(path).startsWith('/api/expenses'))).toBe(
+ false,
+ )
+ })
+})
diff --git a/frontend/src/features/contacts/ContactNotFound.tsx b/frontend/src/features/contacts/ContactNotFound.tsx
index b1d6f03..2fad357 100644
--- a/frontend/src/features/contacts/ContactNotFound.tsx
+++ b/frontend/src/features/contacts/ContactNotFound.tsx
@@ -6,7 +6,7 @@ import { PageHeader } from '@/components/PageHeader'
import { StateMessage } from '@/components/StateMessage'
import { buttonClassName } from '@/components/ui/button-variants'
-export function ContactNotFound({ title }: { title?: string } = {}) {
+export function ContactNotFound({ title }: { title?: string }) {
const { t } = useLingui()
return (
<>
From 62d0573d6a374c27cdde0734719e0cbc8727ec0c Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 13:54:11 +0100
Subject: [PATCH 6/7] test: give each router test fetch a fresh response and
cover non-numeric edit contact ids
---
frontend/src/app/router.test.tsx | 6 +++---
.../src/features/contacts/EditContactPage.test.tsx | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/frontend/src/app/router.test.tsx b/frontend/src/app/router.test.tsx
index b8ff94a..8fd998e 100644
--- a/frontend/src/app/router.test.tsx
+++ b/frontend/src/app/router.test.tsx
@@ -12,7 +12,7 @@ afterEach(() => {
describe('router', () => {
it('renders a not-found screen inside AppShell for unknown routes', async () => {
- vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse(200, me)))
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse(200, me)))
renderRoutes(routes, '/nope')
expect(
@@ -26,7 +26,7 @@ describe('router', () => {
it('redirects unknown routes to /login when signed out', async () => {
vi.stubGlobal(
'fetch',
- vi.fn().mockResolvedValue(jsonResponse(401, { status: 401, title: 'Unauthorized' })),
+ vi.fn(async () => jsonResponse(401, { status: 401, title: 'Unauthorized' })),
)
const router = renderRoutes(routes, '/nope?x=1')
@@ -35,7 +35,7 @@ describe('router', () => {
})
it('keeps specific routes outside AppShell matched ahead of the catch-all', async () => {
- vi.stubGlobal('fetch', vi.fn().mockResolvedValue(jsonResponse(200, me)))
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse(200, me)))
renderRoutes(routes, '/expenses/abc')
expect(
diff --git a/frontend/src/features/contacts/EditContactPage.test.tsx b/frontend/src/features/contacts/EditContactPage.test.tsx
index a7c4076..66601a7 100644
--- a/frontend/src/features/contacts/EditContactPage.test.tsx
+++ b/frontend/src/features/contacts/EditContactPage.test.tsx
@@ -127,4 +127,15 @@ describe('EditContactPage', () => {
within(screen.getByRole('banner')).getByRole('heading', { name: 'Edit contact' }),
).toBeInTheDocument()
})
+
+ it('shows contact not found without fetching for a non-numeric id', async () => {
+ const fetchMock = stubApi()
+ renderEdit('abc')
+
+ expect(await screen.findByRole('heading', { name: 'Contact not found' })).toBeInTheDocument()
+ expect(
+ within(screen.getByRole('banner')).getByRole('heading', { name: 'Edit contact' }),
+ ).toBeInTheDocument()
+ expect(fetchMock).not.toHaveBeenCalled()
+ })
})
From 0ed7df76d17b1741956fb4e217b9327c8d77bddb Mon Sep 17 00:00:00 2001
From: Ame <37273244+ame180@users.noreply.github.com>
Date: Thu, 26 Nov 2026 13:54:23 +0100
Subject: [PATCH 7/7] style: format router test
---
frontend/src/app/router.test.tsx | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/frontend/src/app/router.test.tsx b/frontend/src/app/router.test.tsx
index 8fd998e..feb30c9 100644
--- a/frontend/src/app/router.test.tsx
+++ b/frontend/src/app/router.test.tsx
@@ -12,7 +12,10 @@ afterEach(() => {
describe('router', () => {
it('renders a not-found screen inside AppShell for unknown routes', async () => {
- vi.stubGlobal('fetch', vi.fn(async () => jsonResponse(200, me)))
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async () => jsonResponse(200, me)),
+ )
renderRoutes(routes, '/nope')
expect(
@@ -35,7 +38,10 @@ describe('router', () => {
})
it('keeps specific routes outside AppShell matched ahead of the catch-all', async () => {
- vi.stubGlobal('fetch', vi.fn(async () => jsonResponse(200, me)))
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async () => jsonResponse(200, me)),
+ )
renderRoutes(routes, '/expenses/abc')
expect(