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 #5254

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

msilva-broad
Copy link
Contributor

@msilva-broad msilva-broad commented Feb 18, 2025

  • added unit test coverage, made module scope logic into callable (and testable) functions.
  • shifted startup related modules to sub-folder.
  • light Typescript conversions.

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

Summary of changes:

What

Why

  • improve code maintainability

Testing strategy

@msilva-broad msilva-broad force-pushed the msilva/UIE-206_startup-unit-tests_pt2 branch from cdbf54a to 467df78 Compare February 19, 2025 18:09
@msilva-broad msilva-broad marked this pull request as ready for review February 19, 2025 21:54
@msilva-broad msilva-broad force-pushed the msilva/UIE-206_startup-unit-tests_pt2 branch from 467df78 to f9fbc04 Compare February 19, 2025 21:55
@msilva-broad msilva-broad force-pushed the msilva/UIE-206_startup-unit-tests_pt2 branch from f9fbc04 to a28f6a6 Compare February 20, 2025 13:59
const userManager: UserManager = new UserManager(getOidcConfig());

const url = window.location.href;
const isSilent = window.location.pathname.startsWith('/redirect-from-oauth-silent');
const url = getCurrentLocation().href;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

window.location is difficult to mock in unit tests, and it's a global (awkward actor), which makes async unit tests unworkable. So this is being shifted to a thin wrapper that is much easier to mock.

const rootElement = document.getElementById('root');
const root = createRoot(rootElement!);
root.render(h(RedirectFromOAuth));
};
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 from old file location in src/auth, but wrapped in callable function.

/**
* gets the current app window url location object
*/
export const getCurrentLocation = () => window.location;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

window.location is difficult to mock in unit tests, and it's a global (awkward actor), which makes async unit tests unworkable. So this is being shifted to a thin wrapper that is much easier to mock.

close: 'Close',
},
},
});
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 from old src/ location, but now in callable wrapper and light ts conversion

- added unit test coverage, made module scope logic into callable (and testable) functions.
- shifted startup relatid modules to sub-folder.
- light Typescript conversions.
- fixed missing act unit test warning
@msilva-broad msilva-broad force-pushed the msilva/UIE-206_startup-unit-tests_pt2 branch from 3341420 to 5f6e882 Compare February 20, 2025 20:53
Copy link
Contributor

@davidangb davidangb left a comment

Choose a reason for hiding this comment

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

did not test it myself; code looks good. thank you!

@msilva-broad msilva-broad added this pull request to the merge queue Feb 21, 2025
Merged via the queue into dev with commit 9b73a73 Feb 21, 2025
11 checks passed
@msilva-broad msilva-broad deleted the msilva/UIE-206_startup-unit-tests_pt2 branch February 21, 2025 14:08
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