Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix dependencies and support unit tests for app #619 #1131 #1233

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e859d60
fix: missing deps
vincentkoc Nov 1, 2024
0495915
Update .gitignore
vincentkoc Nov 1, 2024
1d41cf3
Create test.sh
vincentkoc Nov 1, 2024
1e7b0e4
Create app_test.dart
vincentkoc Nov 1, 2024
0d8dc54
Create app_test.mocks.dart
vincentkoc Nov 1, 2024
efdd13e
Create basic_test.dart
vincentkoc Nov 1, 2024
9be4025
Create mock_helper.dart
vincentkoc Nov 1, 2024
1978550
Create firebase_mock.dart
vincentkoc Nov 1, 2024
ecc4a9b
Update pubspec.yaml
vincentkoc Nov 1, 2024
3e00786
Update main.dart
vincentkoc Nov 1, 2024
f90a396
Create app_test.dart
vincentkoc Nov 1, 2024
246fdeb
Update app_test.mocks.dart
vincentkoc Nov 1, 2024
f562b24
Update app_test.dart
vincentkoc Nov 1, 2024
a7c8042
fix: font loading strict nomenclature
vincentkoc Nov 1, 2024
b1066d6
Update pubspec.yaml
vincentkoc Nov 1, 2024
b7ae798
Create auth_provider_test.dart
vincentkoc Nov 1, 2024
b526272
Create auth_provider_test.mocks.dart
vincentkoc Nov 1, 2024
bddc0be
Update main.dart
vincentkoc Nov 1, 2024
a3b0bf5
Update test.sh
vincentkoc Nov 1, 2024
b4c8405
Create message_test.dart
vincentkoc Nov 1, 2024
1fad845
Update mock_helper.dart
vincentkoc Nov 1, 2024
e4e1f76
Update auth_provider_test.dart
vincentkoc Nov 1, 2024
66b8e32
Create capture_provider_test.dart
vincentkoc Nov 1, 2024
f6aeb8a
Create capture_provider_test.mocks.dart
vincentkoc Nov 1, 2024
0e747e8
Create memory_provider_test.dart
vincentkoc Nov 1, 2024
083b058
Create memory_provider_test.mocks.dart
vincentkoc Nov 1, 2024
7613c7e
Create device_connection_test.dart
vincentkoc Nov 1, 2024
424e02f
Create device_connection_test.mocks.dart
vincentkoc Nov 1, 2024
c7f2c24
Create notifications_test.dart
vincentkoc Nov 1, 2024
3581811
Update test.sh
vincentkoc Nov 1, 2024
5b8da1c
Create Makefile
vincentkoc Nov 1, 2024
510a980
Update message_test.dart
vincentkoc Nov 1, 2024
89292b9
Create auth_mock_helper.dart
vincentkoc Nov 1, 2024
88ffdfc
Update mock_helper.dart
vincentkoc Nov 1, 2024
701e73f
Update auth_provider_test.dart
vincentkoc Nov 1, 2024
3a4aaff
Update auth_provider_test.mocks.dart
vincentkoc Nov 1, 2024
dff53cf
Create notifications_test.mocks.dart
vincentkoc Nov 1, 2024
ec09cd2
Update notifications_test.dart
vincentkoc Nov 1, 2024
f84e3e8
Update main.dart
vincentkoc Nov 2, 2024
9cc6b6e
Update Makefile
vincentkoc Nov 2, 2024
661559f
Update Podfile
vincentkoc Nov 2, 2024
03f7029
Update test.sh
vincentkoc Nov 2, 2024
4472624
Update test.sh
vincentkoc Nov 2, 2024
d319d1c
Update test.sh
vincentkoc Nov 2, 2024
212aa92
Update .gitignore
vincentkoc Nov 2, 2024
76bf9a6
if exists on pod
vincentkoc Nov 2, 2024
50df4df
Update .env.template
vincentkoc Nov 2, 2024
5afd8cc
chore: update firebase
vincentkoc Nov 2, 2024
48e422e
Update AppDelegate.swift
vincentkoc Nov 2, 2024
fe5b10c
Update app/Makefile
vincentkoc Nov 3, 2024
44e90ee
Update app/Makefile
vincentkoc Nov 3, 2024
2be42b6
Update app/test/app_test.dart
vincentkoc Nov 3, 2024
2ac7c82
Update app/test/app_test.dart
vincentkoc Nov 3, 2024
0c9dd2b
Update app/test/providers/capture_provider_test.mocks.dart
vincentkoc Nov 3, 2024
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
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ yarn.lock
build/
dist/

# Google Services
**/GoogleService-Info.plist
**/google-services.json

# Android specific
**/android/**/build/
**/android/.gradle
Expand All @@ -32,9 +36,6 @@ dist/
**/android/**/gradle-wrapper.jar
**/android/**/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/app/google-services.json
**/android/app/src/dev/google-services.json
**/android/app/src/prod/google-services.json

# iOS specific
**/ios/**/Pods/
Expand All @@ -47,9 +48,10 @@ dist/
**/ios/Runner.xcworkspace
**/ios/**/GeneratedPluginRegistrant.*
**/ios/**/xcuserdata
**/ios/Runner/GoogleService-Info.plist
**/ios/Config/*
**/ios/Config/**/*
**/ios/ogg.xcframework
**/ios/opus.xcframework

# macOS specific
**/macos/**/Pods/
Expand All @@ -63,6 +65,7 @@ dist/
**/macos/.generated/
**/macos/Runner.xcworkspace
**/macos/**/GeneratedPluginRegistrant.*
**/macos/Runner/GoogleService-Info.plist

# Linux specific
**/linux/.dart_tool/
Expand Down Expand Up @@ -112,6 +115,7 @@ src/recordings

# test output
test/recordings
app/coverage

# Flutter
env.g.dart
Expand Down
6 changes: 3 additions & 3 deletions app/.env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
OPENAI_API_KEY=
API_BASE_URL=
GOOGLE_MAPS_API_KEY=
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
API_BASE_URL="YOUR_BACKEND_DOMAIN i.e. test-omi.ngrok-free.app"
GOOGLE_MAPS_API_KEY="YOUR_GOOGLE_MAPS_API_KEY"
21 changes: 21 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: test build clean

test:
@echo "🧪 Running tests..."
@dart run build_runner build --delete-conflicting-outputs || { echo "❌ Build runner failed"; exit 1; }
@[ -x "$(CURDIR)/test.sh" ] || { echo "❌ test.sh not found or not executable"; exit 1; }
@if ! "$(CURDIR)/test.sh"; then \
echo "❌ Tests failed"; \
echo "Please check the test output above for details"; \
exit 1; \
fi
build:
@echo "🏗️ Building..."
@dart run build_runner build --delete-conflicting-outputs || { echo "❌ Build failed"; exit 1; }
@echo "✅ Build completed successfully"
clean:
@echo "🧹 Cleaning..."
@command -v flutter >/dev/null 2>&1 || { echo "❌ Flutter not found"; exit 1; }
@flutter clean
@rm -rf coverage build 2>/dev/null || true
@echo "✅ Clean completed successfully"
18 changes: 18 additions & 0 deletions app/integration_test/app_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:integration_test/integration_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:friend_private/main.dart';
import 'package:flutter/material.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('Full App Tests', () {
testWidgets('App shows onboarding flow', (tester) async {
await tester.pumpWidget(const MyApp());
await tester.pumpAndSettle();

// Test full app flow with real dependencies
expect(find.byType(DeciderWidget), findsOneWidget);
});
vincentkoc marked this conversation as resolved.
Show resolved Hide resolved
});
}
4 changes: 2 additions & 2 deletions app/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include? "Generated.xcconfig"
4 changes: 2 additions & 2 deletions app/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include? "Generated.xcconfig"
149 changes: 93 additions & 56 deletions app/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
# Uncomment this line to define a global platform for your project
platform :ios, '15.0'

# Move these to the top level, before any target definitions
use_frameworks! :linkage => :static
use_modular_headers!

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

# Add script to download XCFrameworks
def download_xcframework(url, name)
require 'shellwords'
require 'uri'

# Validate inputs
raise "Invalid URL" unless url =~ URI::regexp
vincentkoc marked this conversation as resolved.
Show resolved Hide resolved
raise "Invalid name" unless name =~ /^[a-zA-Z0-9_-]+$/

escaped_url = Shellwords.escape(url)
escaped_name = Shellwords.escape(name)
system("echo downloading #{url}")
download_success = system("curl -L #{escaped_url} -o #{escaped_name}.xcframework.zip")
raise "Download failed" unless download_success

unzip_success = system("unzip -o #{escaped_name}.xcframework.zip")
raise "Extraction failed" unless unzip_success

framework_path = "#{escaped_name}.xcframework"
raise "Framework not found after extraction" unless Dir.exist?(framework_path)

File.delete("#{escaped_name}.xcframework.zip")
end

project 'Runner', {
'Debug-prod' => :debug,
'Profile-prod' => :release,
Expand All @@ -14,70 +42,79 @@ project 'Runner', {
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks! :linkage => :static
use_modular_headers!
# Add Firebase pods with explicit modular headers setting
pod 'Firebase/Core', :modular_headers => true
pod 'Firebase/Analytics', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
vincentkoc marked this conversation as resolved.
Show resolved Hide resolved

# Download XCFrameworks before installing pods
download_xcframework("https://github.com/sbooth/opus-binary-xcframework/releases/download/0.2.0/opus.xcframework.zip", "opus")
download_xcframework("https://github.com/sbooth/ogg-binary-xcframework/releases/download/0.1.0/ogg.xcframework.zip", "ogg")
vincentkoc marked this conversation as resolved.
Show resolved Hide resolved

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

# dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',

# dart: PermissionGroup.bluetooth
'PERMISSION_BLUETOOTH=1',

## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
## macro.
##
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
'PERMISSION_LOCATION_WHENINUSE=1',
'PERMISSION_LOCATION_ALWAYS=1',

## dart: PermissionGroup.calendarFullAccess
'PERMISSION_EVENTS_FULL_ACCESS=1',

## dart: PermissionGroup.calendar
'PERMISSION_EVENTS=1',
]

end
end
# ################ Awesome Notifications pod modification 1 ###################
# awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
# require awesome_pod_file
# update_awesome_pod_build_settings(installer)
# ################ Awesome Notifications pod modification 1 ###################
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)

# Force Swift modules for all pods
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings['DEFINES_MODULE'] = 'YES'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'

# Add framework search paths for manually added XCFrameworks
config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= ['$(inherited)']
config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '$(PROJECT_DIR)'

# Add specific settings for opus and ogg
config.build_settings['OTHER_LDFLAGS'] ||= ['$(inherited)']
config.build_settings['OTHER_LDFLAGS'] << '-framework opus'
config.build_settings['OTHER_LDFLAGS'] << '-framework ogg'

config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

# dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',

# dart: PermissionGroup.bluetooth
'PERMISSION_BLUETOOTH=1',

## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
## macro.
##
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
'PERMISSION_LOCATION_WHENINUSE=1',
'PERMISSION_LOCATION_ALWAYS=1',

## dart: PermissionGroup.calendarFullAccess
'PERMISSION_EVENTS_FULL_ACCESS=1',

## dart: PermissionGroup.calendar
'PERMISSION_EVENTS=1',
]
end
end
end
#
# ################ Awesome Notifications pod modification 2 ###################
# awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
# require awesome_pod_file
# update_awesome_main_target_settings('Runner', File.dirname(File.realpath(__FILE__)), flutter_root)
# ################ Awesome Notifications pod modification 2 ###################
2 changes: 2 additions & 0 deletions app/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit
import Flutter
import UserNotifications
import Firebase

@main
@objc class AppDelegate: FlutterAppDelegate {
Expand All @@ -13,6 +14,7 @@ import UserNotifications
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
//Creates a method channel to handle notifications on kill
let controller = window?.rootViewController as? FlutterViewController
Expand Down
Loading