Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(tests): fix remaining 3 immich test failures

jubnl98340aa8552a
diff --git a/server/src/routes/memories/immich.ts b/server/src/routes/memories/immich.ts
index e5bc4c9e3..87f3fa0fd 100644
--- a/server/src/routes/memories/immich.ts
+++ b/server/src/routes/memories/immich.ts
@@ -60,10 +60,16 @@ router.get('/browse', authenticate, async (req: Request, res: Response) => {
router.post('/search', authenticate, async (req: Request, res: Response) => {
const authReq = req as AuthRequest;
- const { from, to, page, size } = req.body;
- const result = await searchPhotos(authReq.user.id, from, to, Number(page) || 1, Math.min(Number(size) || 50, 200));
- if (result.error) return res.status(result.status!).json({ error: result.error });
- res.json({ assets: result.assets, hasMore: result.hasMore });
+ const { from, to, size } = req.body;
+ const pageSize = Math.min(Number(size) || 50, 200);
+ const allAssets: any[] = [];
+ for (let page = 1; page <= 20; page++) {
+ const result = await searchPhotos(authReq.user.id, from, to, page, pageSize);
+ if (result.error) return res.status(result.status!).json({ error: result.error });
+ if (result.assets) allAssets.push(...result.assets);
+ if (!result.hasMore) break;
+ }
+ res.json({ assets: allAssets });
});
// ── Asset Details ──────────────────────────────────────────────────────────
diff --git a/server/tests/integration/memories-immich.test.ts b/server/tests/integration/memories-immich.test.ts
index 0a27b45f8..7cd07babe 100644
--- a/server/tests/integration/memories-immich.test.ts
+++ b/server/tests/integration/memories-immich.test.ts
@@ -119,8 +119,8 @@ vi.mock('../../src/utils/ssrfGuard', async () => {
body: null,
});
}
- // /api/albums — list albums
- if (/\/api\/albums$/.test(u)) {
+ // /api/albums — list albums (owned and shared?=true variant)
+ if (/\/api\/albums(\?.*)?$/.test(u)) {
return Promise.resolve({
ok: true, status: 200,
headers: { get: () => null },
@@ -415,9 +415,11 @@ describe('Immich asset proxy', () => {
const { user: member } = createUser(testDb);
// Insert a shared photo referencing a trip that doesn't exist (FK disabled temporarily)
testDb.exec('PRAGMA foreign_keys = OFF');
+ testDb.prepare('INSERT OR IGNORE INTO trek_photos (provider, asset_id, owner_id) VALUES (?, ?, ?)').run('immich', 'asset-notrip', owner.id);
+ const tkpNotrip = testDb.prepare('SELECT id FROM trek_photos WHERE provider = ? AND asset_id = ? AND owner_id = ?').get('immich', 'asset-notrip', owner.id) as any;
testDb.prepare(
- 'INSERT INTO trip_photos (trip_id, user_id, asset_id, provider, shared) VALUES (?, ?, ?, ?, ?)'
- ).run(9999, owner.id, 'asset-notrip', 'immich', 1);
+ 'INSERT INTO trip_photos (trip_id, user_id, photo_id, shared) VALUES (?, ?, ?, ?)'
+ ).run(9999, owner.id, tkpNotrip.id, 1);
testDb.exec('PRAGMA foreign_keys = ON');
const res = await request(app)