fix: back-merge v3.1.4 hotfixes into dev (#1371)

Port the three main-only fixes onto dev's (post-rewrite) architecture:
- fix(backups): prevent recursion when the backup path sits inside the backed-up dir
- fix(share): convert budget items to the viewer's base currency instead of a flat EUR
- fix(files): surface the descriptive server error for unsupported upload types (#1363)

Cherry-picked from 819aa793 on main; the SharedTripPage and useTripPlanner
conflicts were resolved to keep dev's font-scaling and full import set while
taking the fixes' currency conversion and translateApiError wiring.
This commit is contained in:
jubnl
2026-07-01 18:57:16 +02:00
committed by Maurice
parent 3686792ce8
commit 60cbd20327
37 changed files with 276 additions and 18 deletions
+2
View File
@@ -126,6 +126,8 @@ describe('Upload file', () => {
.set('Cookie', authCookie(user.id))
.attach('file', svgPath);
expect(res.status).toBe(400);
// The error is an i18n key the client resolves via t() (issue #1363).
expect(res.body.error).toBe('files.uploadErrorType');
} finally {
if (fs.existsSync(svgPath)) fs.unlinkSync(svgPath);
}
+50
View File
@@ -354,6 +354,56 @@ describe('Shared trip — ordering parity (issue #981)', () => {
});
});
describe('Shared trip — display currency (issue #1361)', () => {
it('SHARE-021 — baseCurrency resolves from the share owner\'s default_currency setting', async () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
// Trip keeps the EUR default; the owner's Costs display currency is CAD.
testDb.prepare("INSERT INTO settings (user_id, key, value) VALUES (?, 'default_currency', ?)")
.run(user.id, JSON.stringify('CAD'));
const { body: { token } } = await request(app)
.post(`/api/trips/${trip.id}/share-link`)
.set('Cookie', authCookie(user.id))
.send({ share_budget: true });
const res = await request(app).get(`/api/shared/${token}`);
expect(res.status).toBe(200);
expect(res.body.baseCurrency).toBe('CAD');
});
it('SHARE-022 — baseCurrency falls back to the trip currency when the owner has no setting', async () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id);
testDb.prepare('UPDATE trips SET currency = ? WHERE id = ?').run('GBP', trip.id);
const { body: { token } } = await request(app)
.post(`/api/trips/${trip.id}/share-link`)
.set('Cookie', authCookie(user.id))
.send({ share_budget: true });
const res = await request(app).get(`/api/shared/${token}`);
expect(res.status).toBe(200);
expect(res.body.baseCurrency).toBe('GBP');
});
it('SHARE-023 — baseCurrency uses the admin instance default when the owner has no per-user setting', async () => {
const { user } = createUser(testDb);
const trip = createTrip(testDb, user.id); // EUR trip default, no user setting
testDb.prepare("INSERT INTO app_settings (key, value) VALUES ('default_user_setting_default_currency', ?)")
.run(JSON.stringify('USD'));
const { body: { token } } = await request(app)
.post(`/api/trips/${trip.id}/share-link`)
.set('Cookie', authCookie(user.id))
.send({ share_budget: true });
const res = await request(app).get(`/api/shared/${token}`);
expect(res.status).toBe(200);
expect(res.body.baseCurrency).toBe('USD');
});
});
describe('Shared trip — place photos in shared links (issue #1100)', () => {
const PLACE_ID = 'ChIJsharedPhoto1100';
const PROXY_URL = `/api/maps/place-photo/${encodeURIComponent(PLACE_ID)}/bytes`;