Skip to content

Commit

Permalink
Merge branch 'master' into label_dashboard_profile_sept_2023
Browse files Browse the repository at this point in the history
  • Loading branch information
shankari authored Sep 23, 2023
2 parents 52bb52b + fce117f commit 53911a2
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 11 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/android-automated-sdk-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ jobs:
- name: Install to a new SDK root
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
printf "Y\nY\nY\nY\nY\n" | bash setup/prereq_android_sdk_install.sh
- name: Verify that all packages are as expected
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
echo "Comparing $ANDROID_SDK_ROOT and $NEW_ANDROID_SDK_ROOT"
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed > /tmp/existing_packages
$NEW_ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --list_installed > /tmp/new_packages
Expand All @@ -58,7 +58,7 @@ jobs:
- name: Verify that directory structure is consistent
shell: bash -l -x {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
ls -al $ANDROID_SDK_ROOT
Expand All @@ -73,7 +73,7 @@ jobs:
- name: Ensure that the path is correct and installed programs are runnable
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
echo "About to run the emulator at $ANDROID_SDK_ROOT/emulator/emulator"
Expand All @@ -84,14 +84,14 @@ jobs:
- name: Setup the cordova environment
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
bash setup/setup_android_native.sh
- name: Ensure that the path is correct and the project can be activated
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_X64
export ANDROID_SDK_ROOT=$NEW_ANDROID_SDK_ROOT
echo "New SDK root $ANDROID_SDK_ROOT"
source setup/activate_native.sh
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/serve-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ jobs:
echo "ionic version"
npx ionic --version
- name: Run Jest tests
shell: bash -l {0}
run: |
npx jest
# TODO: figure out how to check that a server started correctly
# - name: Try starting it
# run: npx run serve
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Pre-requisites
- or this [supposedly easier to use repo](https://github.com/xcpretty/xcode-install)
- **NOTE**: the basic xcode install on Catalina was messed up for me due to a prior installation of command line tools. [These workarounds helped](https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md).
- git
- Java 11. Tested with [OpenJDK 11 (Temurin) using AdoptOpenJDK](https://adoptopenjdk.net/releases.html).
- Java 17. Tested with [OpenJDK 17 (Temurin) using Adoptium](https://adoptium.net).
- android SDK; install manually or use setup script below. Note that you only need to run this once **per computer**.
```
$ bash setup/prereq_android_sdk_install.sh
Expand Down
15 changes: 15 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"testPathIgnorePatterns": [
"/node_modules/",
"/platforms/",
"/plugins/",
"/lib/",
"/manual_lib/"
],
"transform": {
"^.+\\.(ts|tsx|js|jsx)$": "ts-jest"
},
"moduleNameMapper": {
"^react-native$": "react-native-web"
}
}
6 changes: 5 additions & 1 deletion package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"setup-serve": "./bin/download_settings_controls.js && ./bin/setup_autodeploy.js",
"serve": "webpack --config webpack.dev.js && concurrently -k \"phonegap --verbose serve\" \"webpack --config webpack.dev.js --watch\"",
"serve-prod": "webpack --config webpack.prod.js && concurrently -k \"phonegap --verbose serve\" \"webpack --config webpack.prod.js --watch\"",
"serve-only": "phonegap --verbose serve"
"serve-only": "phonegap --verbose serve",
"test": "npx jest"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand All @@ -33,11 +34,13 @@
"exports-loader": "^4.0.0",
"expose-loader": "^4.1.0",
"file-loader": "^6.2.0",
"jest": "^29.7.0",
"phonegap": "9.0.0+cordova.9.0.0",
"process": "^0.11.10",
"sass": "^1.62.1",
"sass-loader": "^13.3.1",
"style-loader": "^3.3.3",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.2",
"typescript": "^5.0.3",
"url-loader": "^4.1.1",
Expand All @@ -48,6 +51,7 @@
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
"@types/jest": "^29.5.5",
"angular": "1.6.7",
"angular-animate": "1.6.7",
"angular-local-storage": "^0.7.1",
Expand Down
5 changes: 4 additions & 1 deletion setup/android_sdk_packages
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
build-tools;31.0.0
build-tools;32.0.0
build-tools;33.0.2
build-tools;34.0.0
emulator
extras;google;google_play_services
extras;intel;Hardware_Accelerated_Execution_Manager
patcher;v4
platform-tools
platforms;android-30
platforms;android-31
platforms;android-32
platforms;android-33
platforms;android-34
system-images;android-22;google_apis;x86_64
system-images;android-23;google_apis;x86_64
system-images;android-24;google_apis_playstore;x86
Expand All @@ -24,3 +25,5 @@ system-images;android-32;google_apis;x86_64
system-images;android-32;google_apis_playstore;x86_64
system-images;android-33;google_apis;x86_64
system-images;android-33;google_apis_playstore;x86_64
system-images;android-34;google_apis;x86_64
system-images;android-34;google_apis_playstore;x86_64
2 changes: 1 addition & 1 deletion setup/prereq_android_sdk_install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TOOLS_VERSION=9477386
TOOLS_VERSION=10406996
TOOLS_ZIP_FILENAME=commandlinetools-mac-${TOOLS_VERSION}_latest.zip

echo "Installing command line tools from $TOOLS_ZIP_FILENAME"
Expand Down
65 changes: 65 additions & 0 deletions www/__tests__/diaryHelper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { getFormattedSectionProperties, getFormattedDate, motionTypeOf, isMultiDay, getFormattedDateAbbr, getFormattedTimeRange, getPercentages } from "../js/diary/diaryHelper";
import { useImperialConfig } from "../js/config/useImperialConfig";

it('returns a formatted date', () => {
expect(getFormattedDate("2023-09-18T00:00:00-07:00")).toBe("Mon September 18, 2023");
expect(getFormattedDate("")).toBeUndefined();
expect(getFormattedDate("2023-09-18T00:00:00-07:00", "2023-09-21T00:00:00-07:00")).toBe("Mon September 18, 2023 - Thu September 21, 2023");
});

it('returns an abbreviated formatted date', () => {
expect(getFormattedDateAbbr("2023-09-18T00:00:00-07:00")).toBe("Mon, Sep 18");
expect(getFormattedDateAbbr("")).toBeUndefined();
expect(getFormattedDateAbbr("2023-09-18T00:00:00-07:00", "2023-09-21T00:00:00-07:00")).toBe("Mon, Sep 18 - Thu, Sep 21");
});

it('returns a human readable time range', () => {
expect(getFormattedTimeRange("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:20")).toBe("2 hours");
expect(getFormattedTimeRange("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:30")).toBe("3 hours");
expect(getFormattedTimeRange("", "2023-09-18T00:00:00-09:30")).toBeFalsy();
});

it("returns a MotionType object", () => {
expect(motionTypeOf("WALKING")).toEqual({ name: "WALKING", icon: "walk", color: '#0068a5' });
expect(motionTypeOf("MotionTypes.WALKING")).toEqual({ name: "WALKING", icon: "walk", color: '#0068a5' });
expect(motionTypeOf("I made this type up")).toEqual({ name: "UNKNOWN", icon: "help", color: '#484848'});
});

it('returns true/false is multi day', () => {
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-19T00:00:00-07:00")).toBeTruthy();
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:00")).toBeFalsy();
expect(isMultiDay("", "2023-09-18T00:00:00-09:00")).toBeFalsy();
});

//created a fake trip with relevant sections by examining log statements
let myFakeTrip = {sections: [
{ "sensed_mode_str": "BICYCLING", "distance": 6013.73657416706 },
{ "sensed_mode_str": "WALKING", "distance": 715.3078629361006 }
]};
let myFakeTrip2 = {sections: [
{ "sensed_mode_str": "BICYCLING", "distance": 6013.73657416706 },
{ "sensed_mode_str": "BICYCLING", "distance": 715.3078629361006 }
]};

let myFakePcts = [
{ mode: "BICYCLING",
icon: "bike",
color: '#007e46',
pct: 89 },
{ mode: "WALKING",
icon: "walk",
color: '#0068a5',
pct: 11 }];

let myFakePcts2 = [
{ mode: "BICYCLING",
icon: "bike",
color: '#007e46',
pct: 100 }];

it('returns the percetnages by mode for a trip', () => {
expect(getPercentages(myFakeTrip)).toEqual(myFakePcts);
expect(getPercentages(myFakeTrip2)).toEqual(myFakePcts2);
expect(getPercentages({})).toEqual({});
})

2 changes: 1 addition & 1 deletion www/js/diary/diaryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type BaseModeKey = keyof typeof BaseModes;
export function getBaseModeByKey(motionName: BaseModeKey | MotionTypeKey | `MotionTypes.${MotionTypeKey}`) {
let key = ('' + motionName).toUpperCase();
key = key.split(".").pop(); // if "MotionTypes.WALKING", then just take "WALKING"
return BaseModes[motionName] || BaseModes.UNKNOWN;
return BaseModes[key] || BaseModes.UNKNOWN;
}

export function getBaseModeOfLabeledTrip(trip, labelOptions) {
Expand Down

0 comments on commit 53911a2

Please sign in to comment.