Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ CONTENT_CHECKER_PROD="https://uhsocial.in/content-intel"
# PROD_URL="http://localhost:3000/api" # iOS simulator
# SOCKET_PROD="http://10.0.2.2:3000"
# CONTENT_CHECKER_PROD="http://10.0.2.2:3000/content-intel"
FIREBASE_API_KEY = "FIREBASE_API_KEY"
FIREBASE_AUTH_DOMAIN ="FIREBASE_AUTH_DOMAIN"
FIREBASE_PROJECT_ID = "FIREBASE_PROJECT_ID"
FIREBASE_STORAGE_BUCKET = "FIREBASE_STORAGE_BUCKET"
FIREBASE_SENDER_ID = "FIREBASE_SENDER_ID"
FIREBASE_APP_ID = "FIREBASE_APP_ID"

# Gemini API Configuration (for AI-powered article summaries)
# Get your free API key at: https://aistudio.google.com/app/apikey
# Free tier: 1500 requests/day, no credit card required
EXPO_PUBLIC_GEMINI_API_KEY="AIza-YOUR-FREE-KEY-HERE"
FIREBASE_MEASUREMENT_ID = "FIREBASE_MEASUREMENT_ID"
FIREBASE_DATABASE_URL = "FIREBASE_DATABASE_URL"

# Sentry Configuration
EXPO_PUBLIC_SENTRY_DSN = "YOUR_SENTRY_DSN"
EXPO_PUBLIC_APP_ENV = "development"
{
"expo": {
"name": "UltimateHealth",
"extra": {
"geminiApiKey": "AIza-AQ.Ab8RN6LVTyuc1zr5a4YJVPl84xXgL1FaecqEhQCzT5jB599AHQ"
}
}
}

# Firebase Configuration
FIREBASE_API_KEY_ANDROID=""
Expand Down
180 changes: 90 additions & 90 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
*.jks
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
**/.xcode.env.local
# Android/IntelliJ
#
build/
.kotlin/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore
google-services*.json
# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output
# Bundle artifact
*.jsbundle
# Ruby / CocoaPods
**/Pods/
/vendor/bundle/
# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*
# testing
/coverage
.env
design.md
# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli
expo-env.d.ts
# @end expo-cli
# Expo local state (machine-specific device history and dev server settings)
.expo/
dist/
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
*.jks
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
**/.xcode.env.local

# Android/IntelliJ
#
build/
.kotlin/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore
google-services*.json

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
**/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
.env
design.md

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions


# @generated expo-cli sync-2b81b286409207a5da26e14c78851eb30d8ccbdb
# The following patterns were generated by expo-cli

expo-env.d.ts
# @end expo-cli

# Expo local state (machine-specific device history and dev server settings)
.expo/
dist/
67 changes: 67 additions & 0 deletions frontend/src/__tests__/ResearchSummaryCard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import ResearchSummaryCard from '../components/ResearchSummaryCard';

const mockSummary = {
simplifiedExplanation: 'Diabetes is when your body cannot control blood sugar properly.',
keyFindings: [
'Insulin resistance causes Type 2 diabetes',
'Diet and exercise can prevent it',
],
beginnerTakeaways: [
'Reduce sugar intake',
'Walk 30 minutes daily',
],
whyItMatters: 'Diabetes affects 500 million people and is largely preventable.',
};

describe('ResearchSummaryCard', () => {

it('shows loading spinner when loading is true', () => {
const { getByText } = render(
<ResearchSummaryCard summary={null} loading={true} />
);
expect(getByText('📋 Generating AI Summary...')).toBeTruthy();
});

it('renders nothing when summary is null and not loading', () => {
const { toJSON } = render(
<ResearchSummaryCard summary={null} loading={false} />
);
expect(toJSON()).toBeNull();
});

it('shows simplified explanation by default', () => {
const { getByText } = render(
<ResearchSummaryCard summary={mockSummary} loading={false} />
);
expect(getByText(mockSummary.simplifiedExplanation)).toBeTruthy();
});

it('hides key findings before expanding', () => {
const { queryByText } = render(
<ResearchSummaryCard summary={mockSummary} loading={false} />
);
expect(queryByText('• Insulin resistance causes Type 2 diabetes')).toBeNull();
});

it('expands to show all sections on tap', () => {
const { getByText } = render(
<ResearchSummaryCard summary={mockSummary} loading={false} />
);
fireEvent.press(getByText('📋 Research Summary'));
expect(getByText('• Insulin resistance causes Type 2 diabetes')).toBeTruthy();
expect(getByText('✓ Reduce sugar intake')).toBeTruthy();
expect(getByText(mockSummary.whyItMatters)).toBeTruthy();
});

it('collapses again on second tap', () => {
const { getByText, queryByText } = render(
<ResearchSummaryCard summary={mockSummary} loading={false} />
);
fireEvent.press(getByText('📋 Research Summary'));
fireEvent.press(getByText('📋 Research Summary'));
expect(queryByText('• Insulin resistance causes Type 2 diabetes')).toBeNull();
});

});
38 changes: 38 additions & 0 deletions frontend/src/__tests__/SummaryService.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { generateArticleSummary } from '../services/SummaryService';

global.fetch = jest.fn();

describe('generateArticleSummary', () => {

beforeEach(() => {
jest.clearAllMocks();
});

it('returns null when fetch throws a network error', async () => {
(global.fetch as jest.Mock).mockRejectedValueOnce(new Error('Network error'));
const result = await generateArticleSummary('Some article text here for testing purposes');
expect(result).toBeNull();
});

it('returns null when API returns non-OK status', async () => {
(global.fetch as jest.Mock).mockResolvedValueOnce({
ok: false,
status: 403,
text: async () => 'Forbidden',
});
const result = await generateArticleSummary('Article content here');
expect(result).toBeNull();
});

it('returns null when response JSON is malformed', async () => {
(global.fetch as jest.Mock).mockResolvedValueOnce({
ok: true,
json: async () => ({
candidates: [{ content: { parts: [{ text: 'NOT VALID JSON' }] } }],
}),
});
const result = await generateArticleSummary('Article content here');
expect(result).toBeNull();
});

});
Loading