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

🎀 UI Migration Wrap-up #1106

Merged
merged 137 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
6fc9894
Merge branch 'controlHelper-rewrite' of https://github.com/the-bay-ka…
JGreenlee Nov 21, 2023
6d64774
Merge branch 'expand-enketo-helper' of https://github.com/Abby-Wheeli…
JGreenlee Nov 21, 2023
2c92ff9
Merge branch 'diaryServices-rewrite' of https://github.com/the-bay-ka…
JGreenlee Nov 21, 2023
0092ace
Merge branch 'notifScheduler-rewrite' of https://github.com/sebastian…
JGreenlee Nov 21, 2023
dd39c92
fix missing import in timelineHelper
JGreenlee Nov 21, 2023
c0170de
fix bad merge conflict resolution in diaryTypes
JGreenlee Nov 21, 2023
30eccf3
Merge branch 'service_rewrite_2023_emailService' of https://github.co…
JGreenlee Nov 21, 2023
c03324f
Merge branch 'metrics-services-rewrite' of https://github.com/Abby-Wh…
JGreenlee Nov 21, 2023
3760d25
remove all remaining uses of getAngularService()
JGreenlee Nov 21, 2023
2a0daf9
remove unused files + services
JGreenlee Nov 21, 2023
2871402
remove angular from customMetricsHelper
JGreenlee Nov 21, 2023
4df43c2
don't use angular in ngApp.js
JGreenlee Nov 21, 2023
3242697
remove angular and ionic packages
JGreenlee Nov 21, 2023
5b0cea0
Merge branch 'service_rewrite_2023_emailService' of https://github.co…
JGreenlee Nov 21, 2023
ea60154
remove unused styles; consolidate into style.css
JGreenlee Nov 21, 2023
2c4afca
Merge branch 'expand-enketo-helper' of https://github.com/Abby-Wheeli…
JGreenlee Nov 21, 2023
2d438f0
consolidate ngApp.js into index.js
JGreenlee Nov 21, 2023
5bb56fe
fix failing test in notifScheduler
JGreenlee Nov 21, 2023
80fa776
remove ng-i18next
JGreenlee Nov 21, 2023
ebe7fe5
remove unused /build folder
JGreenlee Nov 21, 2023
263c90a
remove outdated comments referencing angular
JGreenlee Nov 21, 2023
99e1090
fix missing newline at end of index.html
JGreenlee Nov 21, 2023
49a1a64
comply to Typescript "strictNullChecks": true
JGreenlee Nov 22, 2023
9f7bc4a
more type safety to comply with strictNullChecks
JGreenlee Nov 22, 2023
3d14e37
clean/reformat pushNotifySettings
JGreenlee Nov 22, 2023
6b70afd
use aria-hidden instead of accessibilityHidden
JGreenlee Nov 22, 2023
72b3f7a
i18next: typesafe translation keys
JGreenlee Nov 22, 2023
12133ba
remove french and italian
JGreenlee Nov 22, 2023
b60a05f
convert remaining jsx to tsx
JGreenlee Nov 22, 2023
50fb40d
add js/types to typeRoots
JGreenlee Nov 22, 2023
df0f03f
cleanup and fix types in ProfileSettings
JGreenlee Nov 22, 2023
9e58c7e
more cleanup related to typings
JGreenlee Nov 22, 2023
3bebd8c
fix DiaryCard showing current time if blank
JGreenlee Nov 29, 2023
9a2567c
add TimestampRange type
JGreenlee Nov 29, 2023
3e232ab
fix DiaryCard showing blank TimestampBadges
JGreenlee Nov 29, 2023
7a0ea59
new LabelTab functions for user inputs
JGreenlee Nov 29, 2023
cf7027e
handle enketo validation with try/catch
JGreenlee Nov 30, 2023
45799c6
fix UserInputButton not filling in after response
JGreenlee Nov 30, 2023
27549a3
add duration to ConfirmedPlace type def
JGreenlee Nov 30, 2023
2efb03d
refactor enketo user input types
JGreenlee Nov 30, 2023
fa1dfbf
ignore /dist directory
JGreenlee Nov 30, 2023
44ecc45
fix reload on every tab switch
JGreenlee Nov 30, 2023
31ce4d3
UI touchups
JGreenlee Nov 30, 2023
76e579e
remove unused bits from index.html
JGreenlee Dec 2, 2023
f04079b
Merge branch 'notifScheduler-rewrite' of https://github.com/sebastian…
JGreenlee Dec 2, 2023
a0eb054
Merge branch 'diaryServices-rewrite' of https://github.com/the-bay-ka…
JGreenlee Dec 2, 2023
4959198
add "/dist/" to jest ignore
JGreenlee Dec 4, 2023
c0e29ef
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
JGreenlee Dec 4, 2023
f5dc166
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
JGreenlee Dec 4, 2023
76e6867
Merge branch 'diaryServices-rewrite' of https://github.com/the-bay-ka…
JGreenlee Dec 4, 2023
47acc03
fix getFormattedTimeRange
JGreenlee Dec 5, 2023
ee2fe2a
rework resolveTimestamps validation to fix test
JGreenlee Dec 5, 2023
aa9ee64
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
JGreenlee Dec 6, 2023
4f173ba
update to Prettier 3.1
JGreenlee Dec 6, 2023
0f77f5c
Merge branch 'notifScheduler-rewrite' of https://github.com/sebastian…
JGreenlee Dec 7, 2023
b3dd4b1
Merge branch 'diaryServices-rewrite' of https://github.com/the-bay-ka…
JGreenlee Dec 7, 2023
60ef5ed
fix type warnings in timelineHelper
JGreenlee Dec 7, 2023
a9042d3
fix type warnings on timelineHelperMocks
JGreenlee Dec 7, 2023
8e78f79
fix Enketo type warnings
JGreenlee Dec 7, 2023
1a35e1f
fix type warnings in confirmHelper.test.ts
JGreenlee Dec 7, 2023
107eb84
fix type warnings in confirmHelper.test.ts
JGreenlee Dec 7, 2023
81f4558
Merge branch 'migration-wrapup' of https://github.com/JGreenlee/e-mis…
JGreenlee Dec 7, 2023
0eab473
Merge branch 'notifScheduler-rewrite' of https://github.com/sebastian…
JGreenlee Dec 14, 2023
58fba92
add specific prettier version
jiji14 Dec 13, 2023
17deb22
use prettier 3.1.0 in workflow
JGreenlee Dec 14, 2023
ae0ae28
Merge branch 'service_rewrite_2023' into migration-wrapup
shankari Dec 21, 2023
80e3903
Fix merge conflict the right way
shankari Dec 21, 2023
5cb8187
Fixed WSOD on single-date pick
the-bay-kay Dec 26, 2023
588f685
Clean up a line of test code
the-bay-kay Dec 26, 2023
961ac78
update unprocessed inputs after recording user input
JGreenlee Jan 8, 2024
68ae2bb
allow labels to be stored as a batch
JGreenlee Jan 8, 2024
5166bef
Added to WSOD fix on metrics tab
the-bay-kay Jan 9, 2024
27e7a51
Merge pull request #1 from the-bay-kay/diary_wsod_fix
JGreenlee Jan 9, 2024
1474833
use memoization pattern for added notes' displayDt
JGreenlee Jan 9, 2024
01f33d3
display error properly if thrown in EnketoModal
JGreenlee Jan 9, 2024
f1bd447
revise type defs for additions / EnketoUserInputEntry
JGreenlee Jan 9, 2024
cb7b191
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
JGreenlee Jan 25, 2024
d1927b3
fix missing import in timelineHelper
JGreenlee Nov 21, 2023
0d417f2
remove all remaining uses of getAngularService()
JGreenlee Nov 21, 2023
e558163
remove unused files + services
JGreenlee Nov 21, 2023
0153f0f
remove angular from customMetricsHelper
JGreenlee Nov 21, 2023
ce81699
don't use angular in ngApp.js
JGreenlee Nov 21, 2023
2c18cc1
remove angular and ionic packages
JGreenlee Nov 21, 2023
e920752
remove unused styles; consolidate into style.css
JGreenlee Nov 21, 2023
385a384
consolidate ngApp.js into index.js
JGreenlee Nov 21, 2023
6d5566e
fix failing test in notifScheduler
JGreenlee Nov 21, 2023
40f7aad
remove ng-i18next
JGreenlee Nov 21, 2023
4d9a8ef
remove unused /build folder
JGreenlee Nov 21, 2023
98b08bf
remove outdated comments referencing angular
JGreenlee Nov 21, 2023
78661da
fix missing newline at end of index.html
JGreenlee Nov 21, 2023
c901e91
comply to Typescript "strictNullChecks": true
JGreenlee Nov 22, 2023
8178c1f
more type safety to comply with strictNullChecks
JGreenlee Nov 22, 2023
dd00645
clean/reformat pushNotifySettings
JGreenlee Nov 22, 2023
a5edfb7
use aria-hidden instead of accessibilityHidden
JGreenlee Nov 22, 2023
5f9c665
i18next: typesafe translation keys
JGreenlee Nov 22, 2023
60f12b3
remove french and italian
JGreenlee Nov 22, 2023
7286a04
convert remaining jsx to tsx
JGreenlee Nov 22, 2023
aa74a4f
add js/types to typeRoots
JGreenlee Nov 22, 2023
e77b92a
cleanup and fix types in ProfileSettings
JGreenlee Nov 22, 2023
6a17228
more cleanup related to typings
JGreenlee Nov 22, 2023
9dc0d48
fix DiaryCard showing current time if blank
JGreenlee Nov 29, 2023
da0a311
add TimestampRange type
JGreenlee Nov 29, 2023
1e906c0
fix DiaryCard showing blank TimestampBadges
JGreenlee Nov 29, 2023
63c14d6
new LabelTab functions for user inputs
JGreenlee Nov 29, 2023
9ac6e00
handle enketo validation with try/catch
JGreenlee Nov 30, 2023
d339de7
fix UserInputButton not filling in after response
JGreenlee Nov 30, 2023
6deab9f
add duration to ConfirmedPlace type def
JGreenlee Nov 30, 2023
e37fa01
refactor enketo user input types
JGreenlee Nov 30, 2023
098ba21
ignore /dist directory
JGreenlee Nov 30, 2023
36bbf08
fix reload on every tab switch
JGreenlee Nov 30, 2023
412b3b8
UI touchups
JGreenlee Nov 30, 2023
c9b2683
remove unused bits from index.html
JGreenlee Dec 2, 2023
e1d03a6
add "/dist/" to jest ignore
JGreenlee Dec 4, 2023
07befbc
fix getFormattedTimeRange
JGreenlee Dec 5, 2023
fec6a4b
rework resolveTimestamps validation to fix test
JGreenlee Dec 5, 2023
3c65612
update to Prettier 3.1
JGreenlee Dec 6, 2023
59a080f
fix type warnings in timelineHelper
JGreenlee Dec 7, 2023
3563698
fix type warnings on timelineHelperMocks
JGreenlee Dec 7, 2023
699d90f
fix Enketo type warnings
JGreenlee Dec 7, 2023
ff840ff
fix type warnings in confirmHelper.test.ts
JGreenlee Dec 7, 2023
88c72f8
use prettier 3.1.0 in workflow
JGreenlee Dec 14, 2023
a6e7a79
update unprocessed inputs after recording user input
JGreenlee Jan 8, 2024
8161d58
allow labels to be stored as a batch
JGreenlee Jan 8, 2024
b6a9155
Fixed WSOD on single-date pick
the-bay-kay Dec 26, 2023
ce760b6
Clean up a line of test code
the-bay-kay Dec 26, 2023
7483fe5
Added to WSOD fix on metrics tab
the-bay-kay Jan 9, 2024
b3785fd
use memoization pattern for added notes' displayDt
JGreenlee Jan 9, 2024
3e44ebc
display error properly if thrown in EnketoModal
JGreenlee Jan 9, 2024
316d4e9
revise type defs for additions / EnketoUserInputEntry
JGreenlee Jan 9, 2024
d5fe4b4
Merge branch 'service_rewrite_2023' of https://github.com/e-mission/e…
JGreenlee Jan 25, 2024
b0d6e7b
Merge branch 'migration-wrapup' of https://github.com/JGreenlee/e-mis…
JGreenlee Jan 25, 2024
6631890
fix notifScheduler test
JGreenlee Jan 25, 2024
a086892
fix type defs for notifScheduler
JGreenlee Jan 25, 2024
0aec763
fix type defs for timelineHelper
JGreenlee Jan 25, 2024
79d18a1
fix type warnings
JGreenlee Jan 25, 2024
004b9ea
replace remaining uses of `moment` & remove it from dependencies
JGreenlee Jan 26, 2024
48633c3
remove jQuery from dependencies + webpack
JGreenlee Jan 26, 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
2 changes: 1 addition & 1 deletion .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npx prettier@3.0.3 --check www
- run: npx prettier@3.1.0 --check www


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
node_modules/
platforms/
plugins/
dist/
www/lib/
package-hooks/
.DS_Store
Expand Down
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Ignore www/dist, manual_lib, json
# Ignore www/dist, json
www/dist
www/manual_lib
www/json

# Ignore all HTML files:
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module.exports = {
testEnvironment: 'jsdom',
testPathIgnorePatterns: [
"/node_modules/",
"/dist/",
"/platforms/",
"/plugins/",
"/lib/",
"/manual_lib/"
],
preset: 'react-native',
transform: {
Expand Down
23 changes: 4 additions & 19 deletions package.cordovabuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@types/luxon": "^3.3.0",
"@types/react": "^18.2.20",
"babel-loader": "^9.1.2",
"babel-plugin-angularjs-annotate": "^0.10.0",
"babel-plugin-optional-require": "^0.3.1",
"concurrently": "^8.0.1",
"cordova": "^11.1.0",
Expand Down Expand Up @@ -106,15 +105,7 @@
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
"@types/leaflet": "1.9.4",
"angular": "1.6.7",
"angular-animate": "1.6.7",
"angular-local-storage": "^0.7.1",
"angular-sanitize": "1.6.7",
"angular-simple-logger": "^0.1.7",
"angular-translate": "^2.18.1",
"angular-translate-loader-static-files": "^2.18.1",
"angular-ui-router": "0.2.13",
"@types/leaflet": "^1.9.4",
"animate.css": "^3.5.2",
"bottleneck": "^2.19.5",
"chart.js": "^4.3.0",
Expand Down Expand Up @@ -146,25 +137,19 @@
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
"fs-extra": "^9.0.1",
"humanize-duration": "3.31.0",
"i18next": "^22.5.0",
"humanize-duration": "^3.31.0",
"i18next": "^23.7.6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we actually have any tests for i18n? In general, we rely upon the automated tests to catch regressions during upgrades, so it would be good to ensure that it isn't broken. (we can check this visually/manually) for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we don't specifically test the i18nextInit.ts file, some of the tests do invoke it because those tests depend on i18n

So there is coverage for it downstream

"install": "^0.13.0",
"ionic-datepicker": "1.2.1",
"ionic-toast": "^0.4.1",
"jquery": "^3.1.0",
"klaw-sync": "^6.0.0",
"leaflet": "^1.9.4",
"luxon": "^3.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"ng-i18next": "^1.0.7",
"npm": "^9.6.3",
"phonegap-plugin-barcodescanner": "git+https://github.com/phonegap/phonegap-plugin-barcodescanner#v8.1.0",
"prop-types": "^15.8.1",
"react": "^18.2.*",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.*",
"react-i18next": "^12.3.1",
"react-i18next": "^13.5.0",
"react-native-paper": "^5.8.0",
"react-native-paper-dates": "^0.18.12",
"react-native-safe-area-context": "^4.6.3",
Expand Down
25 changes: 5 additions & 20 deletions package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"@types/react": "^18.2.20",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.2",
"babel-plugin-angularjs-annotate": "^0.10.0",
"babel-plugin-optional-require": "^0.3.1",
"concurrently": "^8.0.1",
"cordova": "^11.1.0",
Expand All @@ -50,23 +49,15 @@
"url-loader": "^4.1.1",
"webpack": "^5.0.1",
"webpack-cli": "^5.0.1",
"prettier": "3.0.3"
"prettier": "3.1.0"
},
"dependencies": {
"@messageformat/core": "^3.2.0",
"@react-navigation/native": "^6.1.7",
"@react-navigation/stack": "^6.3.17",
"@shopify/flash-list": "^1.3.1",
"@types/jest": "^29.5.5",
"@types/leaflet": "1.9.4",
"angular": "1.6.7",
"angular-animate": "1.6.7",
"angular-local-storage": "^0.7.1",
"angular-sanitize": "1.6.7",
"angular-simple-logger": "^0.1.7",
"angular-translate": "^2.18.1",
"angular-translate-loader-static-files": "^2.18.1",
"angular-ui-router": "0.2.13",
"@types/leaflet": "^1.9.4",
"animate.css": "^3.5.2",
"bottleneck": "^2.19.5",
"chart.js": "^4.3.0",
Expand All @@ -77,24 +68,18 @@
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
"fs-extra": "^9.0.1",
"humanize-duration": "3.31.0",
"i18next": "^22.5.0",
"humanize-duration": "^3.31.0",
"i18next": "^23.7.6",
"install": "^0.13.0",
"ionic-datepicker": "1.2.1",
"ionic-toast": "^0.4.1",
"jquery": "^3.1.0",
"klaw-sync": "^6.0.0",
"leaflet": "^1.9.4",
"luxon": "^3.3.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"ng-i18next": "^1.0.7",
"npm": "^9.6.3",
"prop-types": "^15.8.1",
"react": "^18.2.*",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.*",
"react-i18next": "^12.3.1",
"react-i18next": "^13.5.0",
"react-native-paper": "^5.8.0",
"react-native-paper-dates": "^0.18.12",
"react-native-safe-area-context": "^4.6.3",
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"sourceMap": true,
"module": "es6",
"target": "es5",
"strictNullChecks": true,
"downlevelIteration": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
"moduleResolution": "node",
"typeRoots": ["node_modules/@types", "www/js/types"],
},
"include": ["www/**/*"],
"exclude": ["**/www/manual_lib/*", "**/node_modules/*", "**/dist/*"],
"exclude": ["**/node_modules/*", "**/dist/*"],
}
6 changes: 1 addition & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = {
{
test: /\.(scss|css)$/,
include: [path.resolve(__dirname, 'www/css'),
path.resolve(__dirname, 'www/manual_lib'),
path.resolve(__dirname, 'node_modules/enketo-core'),
path.resolve(__dirname, 'node_modules/leaflet')],
use: ['style-loader', 'css-loader', 'sass-loader'],
Expand Down Expand Up @@ -57,11 +56,8 @@ module.exports = {
],
},
plugins: [
// to load jQuery and moment globally
// to load Leaflet globally
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
moment: 'moment',
L: 'leaflet',
}),
new webpack.DefinePlugin({
Expand Down
17 changes: 0 additions & 17 deletions webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ module.exports = merge(common, {
devtool: 'source-map',
module: {
rules: [
/* In production, Webpack minifies JS files and randomizes variable names.
This causes problems with AngularJS unless you use explicit annotations,
which we don't.
https://docs.angularjs.org/error/$injector/strictdi
(The syntax we use is like the 'bad' example: implicit annotations)
So rather than change every file in our codebase, I'm adding this
babel plugin which basically preprocesses our 'bad' code into 'good' code.
Only needed on production because minification doesn't happen on dev. */
{
test: /\.(js)$/,
include: path.resolve(__dirname, 'www'),
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ["angularjs-annotate"],
},
},
{
test: /\.(js|jsx|ts|tsx)$/,
loader: 'babel-loader',
Expand Down
2 changes: 1 addition & 1 deletion www/__mocks__/globalMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const mockLogger = () => {
};
};

let alerts = [];
let alerts: string[] = [];

export const mockAlert = () => {
window['alert'] = (message) => {
Expand Down
54 changes: 18 additions & 36 deletions www/__mocks__/timelineHelperMocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MetaData, BEMData, ServerResponse } from '../js/types/serverData';
import { LocalDt, MetaData, BEMData, ServerResponse } from '../js/types/serverData';
import {
CompositeTrip,
ConfirmedPlace,
Expand All @@ -15,7 +15,7 @@ const mockMetaData: MetaData = {
platform: 'test',
time_zone: 'America/Los_Angeles',
write_fmt_time: '1969-07-16T07:01:49.000Z',
write_local_dt: null,
write_local_dt: null as any,
origin_key: '1',
};

Expand All @@ -24,9 +24,9 @@ export const mockLabelOptions: LabelOptions = {
PURPOSE: null,
REPLACED_MODE: null,
translations: null,
};
} as unknown as LabelOptions;

const mockConfirmedPlaceData: ConfirmedPlace = {
const mockConfirmedPlaceData = {
source: 'DwellSegmentationTimeFilter',
key: null,
origin_key: null,
Expand All @@ -46,34 +46,30 @@ const mockConfirmedPlaceData: ConfirmedPlace = {
raw_places: [null, null],
enter_ts: 1437578093.881,
exit_ts: 1437578093.881,
};
} as unknown as ConfirmedPlace;

// using parse/stringify to deep copy & populate data
let tempMetaData = JSON.parse(JSON.stringify(mockMetaData));
tempMetaData.write_ts = 2;
tempMetaData.origin_key = '2';
export const mockMetaDataTwo = tempMetaData;

export const mockUnprocessedTrip: UnprocessedTrip = {
export const mockUnprocessedTrip = {
_id: { $oid: 'mockUnprocessedTrip' },
additions: [],
confidence_threshold: 0.0,
distance: 1.0,
duration: 3.0,
end_fmt_time: '',
end_loc: { type: 'Point', coordinates: [] },
end_local_dt: null,
expectation: null,
inferred_labels: [],
key: 'mockUnprocessedTrip',
locations: [],
origin_key: '',
source: '',
start_local_dt: null,
start_ts: 0.1,
start_loc: { type: 'Point', coordinates: [] },
starting_trip: null,
user_input: null,
};
} as unknown as UnprocessedTrip;

export const mockCompData: ServerResponse<CompositeTrip> = {
phone_data: [
Expand Down Expand Up @@ -152,7 +148,8 @@ export const mockCompData: ServerResponse<CompositeTrip> = {
metadata: mockMetaData,
},
],
};
} as unknown as ServerResponse<CompositeTrip>;

// Setup for second mockData
let newPhoneData = JSON.parse(JSON.stringify(mockCompData.phone_data[0]));
newPhoneData.data._id.$oid = 'mockDataTwo';
Expand Down Expand Up @@ -188,18 +185,10 @@ export const mockTransitions: Array<BEMData<TripTransition>> = [

const mockFilterLocation: FilteredLocation = {
accuracy: 0.1,
altitude: 100,
elapsedRealtimeNanos: 10000,
filter: 'time',
fmt_time: '',
heading: 1.0,
latitude: 1.0,
Comment on lines -191 to -195
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you remove these? Is it because they are not used in the tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those properties are not used by the test. If we declare like as FilteredLocation, we don't have to list every single property.
I thought this would be a better strategy for unit tests, where we're quite often testing with 'stub' objects, or declaring invalid inputs.

loc: null,
local_dt: null,
longitude: -1.0,
sensed_speed: 0,
ts: 100,
};
} as FilteredLocation;
let mockFilterLocationTwo = JSON.parse(JSON.stringify(mockFilterLocation));
mockFilterLocationTwo.ts = 900;
mockFilterLocationTwo.longitude = 200;
Expand All @@ -216,38 +205,31 @@ export const mockFilterLocations: Array<BEMData<FilteredLocation>> = [
},
];

export const mockConfigModeOfStudy: AppConfig = {
server: null,
export const mockConfigModeOfStudy = {
survey_info: {
'trip-labels': 'MULTILABEL',
surveys: null,
},
intro: {
mode_studied: 'sample_study',
},
};
export const mockConfigNoModeOfStudy: AppConfig = {
server: null,
} as AppConfig;
export const mockConfigNoModeOfStudy = {
survey_info: {
'trip-labels': 'MULTILABEL',
surveys: null,
},
intro: {},
};
export const mockConfigEnketo: AppConfig = {
server: null,
} as AppConfig;
export const mockConfigEnketo = {
survey_info: {
'trip-labels': 'ENKETO',
surveys: {
TripConfirmSurvey: {
compatibleWith: 1.2,
formPath: null,
labelTemplate: null,
version: null,
},
},
},
};
intro: {},
} as unknown as AppConfig;

// Used by jest.mocks() to return a various mocked objects.
export const fakeStartTsOne = -14576291;
Expand Down
Loading
Loading