Skip to content

Commit

Permalink
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
Browse files Browse the repository at this point in the history
…-mission-phone into diaryServices-rewrite
  • Loading branch information
JGreenlee committed Dec 4, 2023
2 parents 1cb28c6 + c1f6dc3 commit b6b7c94
Show file tree
Hide file tree
Showing 47 changed files with 1,652 additions and 1,191 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/serve-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ jobs:
run: |
npx jest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage/coverage-final.json
flags: unit
fail_ci_if_error: ${{ github.repository == 'e-mission/e-mission-phone' }}

# TODO: figure out how to check that a server started correctly
# - name: Try starting it
# run: npx run serve
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ app-settings.json
www/dist/
config.xml
package.json
coverage/
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
comment:
layout: " diff, flags, files"
behavior: default
require_changes: false
require_base: false
require_head: true
hide_project_coverage: false

4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ module.exports = {
"^.+\\.(ts|tsx|js|jsx)$": "babel-jest"
},
transformIgnorePatterns: [
"node_modules/(?!((jest-)?react-native(-.*)?|@react-native(-community)?)/)"
"node_modules/(?!((enketo-transformer/dist/enketo-transformer/web)|(jest-)?react-native(-.*)?|@react-native(-community)?)/)",
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
moduleDirectories: ["node_modules", "src"],
globals: {"__DEV__": false},
collectCoverage: true,
};
3 changes: 2 additions & 1 deletion package.cordovabuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
},
"dependencies": {
"@havesource/cordova-plugin-push": "git+https://github.com/havesource/cordova-plugin-push.git#4.0.0-dev.0",
"@messageformat/core": "^3.2.0",
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
Expand Down Expand Up @@ -142,6 +143,7 @@
"cordova-plugin-x-socialsharing": "6.0.4",
"core-js": "^2.5.7",
"enketo-core": "^6.1.7",
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
"fs-extra": "^9.0.1",
"humanize-duration": "3.31.0",
Expand All @@ -153,7 +155,6 @@
"klaw-sync": "^6.0.0",
"leaflet": "^1.9.4",
"luxon": "^3.3.0",
"messageformat": "^2.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"ng-i18next": "^1.0.7",
Expand Down
3 changes: 2 additions & 1 deletion package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"prettier": "3.0.3"
},
"dependencies": {
"@messageformat/core": "^3.2.0",
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
Expand All @@ -73,6 +74,7 @@
"chartjs-plugin-annotation": "^3.0.1",
"core-js": "^2.5.7",
"enketo-core": "^6.1.7",
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
"fs-extra": "^9.0.1",
"humanize-duration": "3.31.0",
Expand All @@ -84,7 +86,6 @@
"klaw-sync": "^6.0.0",
"leaflet": "^1.9.4",
"luxon": "^3.3.0",
"messageformat": "^2.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"ng-i18next": "^1.0.7",
Expand Down
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ module.exports = {
/* Enketo expects its per-app configuration to be available as 'enketo-config',
so we have to alias it here.
https://github.com/enketo/enketo-core#global-configuration */
'enketo/config': path.resolve(__dirname, 'www/js/config/enketo-config')
'enketo/config': path.resolve(__dirname, 'www/js/config/enketo-config'),
/* enketo-transformer has 'libxslt' as an optional peer dependency.
We don't need it since we are only doing client-side transformations via
enketo-transformer/web (https://github.com/enketo/enketo-transformer#web).
So, we can tell webpack it's ok to ignore libxslt by aliasing it to false. */
'libxslt': false,
},
extensions: ['.web.js', '.jsx', '.tsx', '.ts', '.js'],
},
Expand Down
37 changes: 31 additions & 6 deletions www/__mocks__/cordovaMocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import packageJsonBuild from '../../package.cordovabuild.json';
import fakeConfig from './fakeConfig.json';

export const mockCordova = () => {
window['cordova'] ||= {};
window['cordova'].platformId ||= 'ios';
Expand Down Expand Up @@ -35,7 +37,7 @@ const _storage = {};

type MessageData = any;
type Message = { key: string; data: MessageData; metadata: { write_ts: number; [k: string]: any } };
export const mockBEMUserCache = () => {
export const mockBEMUserCache = (config?) => {
const _cache = {};
const messages: Message[] = [];
const mockBEMUserCache = {
Expand Down Expand Up @@ -119,11 +121,20 @@ export const mockBEMUserCache = () => {
// Used for getUnifiedDataForInterval
},
getDocument: (key: string, withMetadata?: boolean) => {
return new Promise<any[]>((rs, rj) =>
setTimeout(() => {
rs(_storage[key]);
}, 100),
);
//returns the config provided as a paramenter to this mock!
if (key == 'config/app_ui_config') {
return new Promise<any>((rs, rj) =>
setTimeout(() => {
rs(config || fakeConfig);
}, 100),
);
} else {
return new Promise<any[]>((rs, rj) =>
setTimeout(() => {
rs(_storage[key]);
}, 100),
);
}
},
isEmptyDoc: (doc) => {
if (doc == undefined) {
Expand All @@ -136,6 +147,20 @@ export const mockBEMUserCache = () => {
return false;
}
},
getAllTimeQuery: () => {
return { key: 'write_ts', startTs: 0, endTs: Date.now() / 1000 };
},
getSensorDataForInterval: (key, tq, withMetadata) => {
if (key == `manual/demographic_survey`) {
return new Promise<any>((rs, rj) =>
setTimeout(() => {
rs({ metadata: { write_ts: '1699897723' }, data: 'completed', time: '01/01/2001' });
}, 100),
);
} else {
return undefined;
}
},
};
window['cordova'] ||= {};
window['cordova'].plugins ||= {};
Expand Down
88 changes: 88 additions & 0 deletions www/__mocks__/fakeConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"version": 1,
"ts": 1655143472,
"server": {
"connectUrl": "https://openpath-test.nrel.gov/api/",
"aggregate_call_auth": "user_only"
},
"intro": {
"program_or_study": "study",
"start_month": "10",
"start_year": "2023",
"program_admin_contact": "K. Shankari",
"deployment_partner_name": "NREL",
"translated_text": {
"en": {
"deployment_partner_name": "NREL",
"deployment_name": "Testing environment for Jest testing",
"summary_line_1": "",
"summary_line_2": "",
"summary_line_3": "",
"short_textual_description": "",
"why_we_collect": "",
"research_questions": ["", ""]
},
"es": {
"deployment_partner_name": "NREL",
"deployment_name": "Ambiente prueba para las pruebas de Jest",
"summary_line_1": "",
"summary_line_2": "",
"summary_line_3": "",
"short_textual_description": "",
"why_we_collect": "",
"research_questions": ["", ""]
}
}
},
"survey_info": {
"surveys": {
"TimeUseSurvey": {
"compatibleWith": 1,
"formPath": "https://raw.githubusercontent.com/sebastianbarry/nrel-openpath-deploy-configs/surveys-info-and-surveys-data/survey-resources/data-json/time-use-survey-form-v9.json",
"labelTemplate": {
"en": "{ erea, plural, =0 {} other {# Employment/Education, } }{ da, plural, =0 {} other {# Domestic, } }",
"es": "{ erea, plural, =0 {} other {# Empleo/Educación, } }{ da, plural, =0 {} other {# Actividades domesticas, }}"
},
"labelVars": {
"da": {
"key": "Domestic_activities",
"type": "length"
},
"erea": {
"key": "Employment_related_a_Education_activities",
"type": "length"
}
},
"version": 9
}
},
"trip-labels": "ENKETO"
},
"display_config": {
"use_imperial": false
},
"profile_controls": {
"support_upload": true,
"trip_end_notification": false
},
"admin_dashboard": {
"overview_users": true,
"overview_active_users": true,
"overview_trips": true,
"overview_signup_trends": true,
"overview_trips_trend": true,
"data_uuids": true,
"data_trips": true,
"data_trips_columns_exclude": [],
"additional_trip_columns": [],
"data_uuids_columns_exclude": [],
"token_generate": true,
"token_prefix": "nrelop",
"map_heatmap": true,
"map_bubble": true,
"map_trip_lines": true,
"push_send": true,
"options_uuids": true,
"options_emails": true
}
}
Loading

0 comments on commit b6b7c94

Please sign in to comment.