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

UIE-206 App Startup - unit tests pt3 #5277

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

msilva-broad
Copy link
Contributor

Jira Ticket: https://broadworkbench.atlassian.net/browse/[Ticket #]

  • additional unit test coverage on startup flow.
  • moved more startup bits to src/libs/startup
  • improved type-safety on configStore, updated related tests/mock usage.
  • some light Typescript conversion

Summary of changes:

What

Why

  • improve code maintainability and dev velocity

Testing strategy

@msilva-broad msilva-broad force-pushed the msilva/UIE-206_startup-unit-tests_pt3 branch from 7b6dd1a to 4616dab Compare March 11, 2025 16:09
- additional unit test coverage on startup flow.
- moved more startup bits to src/libs/startup
- improved type-safety on configStore, updated related tests/mock usage.
- some light Typescript conversion
- additional unit test coverage on startup flow.
- moved more startup bits to src/libs/startup
- improved type-safety on configStore, updated related tests/mock usage.
- some light Typescript conversion
- fixed build info types to not come from json file, which is not there during github build flow.
- fixed assert not being mocked for underlying getConfig() call in WorkspaceContainer tests
};

export const withDebouncedChange = (WrappedComponent) => {
export const withDebouncedChange = (WrappedComponent: React.FC<any>) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a later pass on these types here and below can improve beyond props type "any" to use generic

props passthru type-flow.

fontSize: 14,
backgroundColor: props.disabled ? colors.dark(0.25) : undefined,
},
const numberInputChild = div([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no functional change, just auto-formatting

@@ -1,6 +1,7 @@
import { TooltipTrigger, useWindowDimensions } from '@terra-ui-packages/components';
import Downshift from 'downshift';
import _ from 'lodash/fp';
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

input.ts was part of a change I decided to back out of,. But here I kept the effort I put into a partial Typescript conversion. No functional changes... some minor Typesecript-surfaced linting errors fixed.

@@ -1 +0,0 @@
export const loadedConfigStore = { current: undefined };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to src/libs/startup/configStore.ts

export const getBuildTimestamp = (): number => {
const timeRaw: number | string = getConfig().buildTimestamp;
const timeStamp = typeof timeRaw === 'number' ? timeRaw : parseInt(timeRaw, 10);
return timeStamp;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

typescript surfaced that the timestamp conversion from string might be an error since buildTimestamp config field is a raw number in local .json file.... to play it safe, that field is typed as string | nubmer, and this helper does conversion if and only if needed.

loadedConfig.current = nullConfig.current;
};

export const loadedConfigStore = (): AppConfigSettings | undefined => loadedConfig.current;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

configStore used to just export a raw object. Changing the module to provide access functions adds more useful structure and ease of mocking/managing in tests.

@msilva-broad msilva-broad marked this pull request as ready for review March 11, 2025 17:37
@msilva-broad msilva-broad requested review from a team as code owners March 11, 2025 17:37
@@ -0,0 +1,34 @@
import { partial } from 'src/testing/test-utils';

import { AppConfigSettings, loadedConfigStore, resetConfigStore, setLoadedConfigStore } from './configStore';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that a typo in the file name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't this so... file exptension are ignosred on import filenames... and it's working without issue in build/test run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants