diff --git a/backend/src/__tests__/profile.test.js b/backend/src/__tests__/profile.test.js index 0e39c2b..96015f6 100644 --- a/backend/src/__tests__/profile.test.js +++ b/backend/src/__tests__/profile.test.js @@ -94,4 +94,56 @@ test('GET / should return user profile', async () => { } finally { pool.query = originalQuery; } +}); + +// Test profile route GET / with valid decryption +test('GET / should return user profile with decrypted phone', async () => { + const req = { + user: { userId: 1 } + }; + + const res = { + status: (code) => { + res.statusCode = code; + return res; + }, + json: (data) => { + res.body = data; + } + }; + + // Mock the pool.query function to simulate database fetch + const originalQuery = pool.query; + pool.query = async (sql, params) => { + if (sql.includes('SELECT id, name, email, phone_encrypted FROM users')) { + return [[{ + id: 1, + name: 'Test User', + email: 'test@example.com', + phone_encrypted: 'valid_encrypted_data' + }]]; + } + return []; + }; + + // Mock decryptText to return a valid phone number + const originalDecrypt = decryptText; + decryptText = (payload) => { + if (payload === 'valid_encrypted_data') return '123-456-7890'; + throw new Error('Decryption failed'); + }; + + try { + await router.get('/', req, res); + assert.strictEqual(res.statusCode, 200); + assert.deepStrictEqual(res.body, { + id: 1, + name: 'Test User', + email: 'test@example.com', + phone: '123-456-7890' + }); + } finally { + pool.query = originalQuery; + decryptText = originalDecrypt; + } }); \ No newline at end of file diff --git a/docs/runtime/pick_next_task_state.env b/docs/runtime/pick_next_task_state.env index e9d5c99..760b220 100644 --- a/docs/runtime/pick_next_task_state.env +++ b/docs/runtime/pick_next_task_state.env @@ -1,2 +1,2 @@ -LAST_ROUTE=offers.js -UPDATED_AT=2026-03-06T20:42:06Z +LAST_ROUTE=profile.js +UPDATED_AT=2026-03-06T20:43:06Z