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

feat(tests): tests for Opensearch components #1048

Merged
merged 18 commits into from
Jan 24, 2025
Merged

Conversation

thetif
Copy link
Collaborator

@thetif thetif commented Jan 21, 2025

💬 Description / Notes

Working towards OY2-31569. Added test coverage for Opensearch components. Discovered issue with offsetToUTC and offsetFromUTC. Resolved them by adding @date-fns/utc and @date-fns/tz and using that provided functionality.

🛠 Changes

  • removed moment from shared-utils package.json
  • added @date-fns/utc, @date-fns/tz, and date-fns to shared-utils package.json
  • added @date-fns/utc to react-app package.json
  • replaced offsetToUTC and offsetFromUTC with @date-fns/utc in all the code and removed those tests
  • updated seaToolFriendlyTimestamp with functions from @date-fns/utc and date-fns
  • updated formatSeatoolDate to use date-fns instead of moment, so that we could remove moment from the project entirely
  • updated getNextBusinessDayTimestamp to use functions from date-fns and @date-fns/tz to convert the time to the NY timezone.
  • updated the Chipbar component to use @date-fns instead of offsetFromUTC
  • added some null checking and handling to Chipbar
  • updated FilterableDateRange to use @date-fns/utc instead of offsetToUTC and offsetFromUTC and to use UTCDate objects instead of Date
  • exported ContextState from OsProvider so it was available in the tests

Copy link
Contributor

github-actions bot commented Jan 21, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 85.58% 3990 / 4662
🔵 Statements 85% 4349 / 5116
🔵 Functions 76.62% 1180 / 1540
🔵 Branches 69.64% 1925 / 2764
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
lib/packages/shared-utils/seatool-date-helper.ts 93.33% 81.81% 66.66% 100% 27
react-app/src/components/Opensearch/main/Filtering/Chipbar/index.tsx 94.87% 92.59% 93.75% 100% 34, 78
react-app/src/components/Opensearch/main/Filtering/Drawer/Filterable/DateRange.tsx 64.78% 54.41% 82.35% 64.17% 57-79, 84-101, 116, 139-143, 236
react-app/src/components/Opensearch/main/Provider/index.tsx 100% 100% 0% 100%
Generated in workflow #1667 for commit f692404 by the Vitest Coverage Report Action

@thetif thetif changed the title added tests feat(tests): tests for Opensearch components Jan 21, 2025
@thetif thetif temporarily deployed to test-opensearch-components January 21, 2025 22:31 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 21, 2025 22:31 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-app January 21, 2025 22:31 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-kibana January 21, 2025 22:31 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 21, 2025 22:31 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 22, 2025 23:23 — with GitHub Actions Inactive
@thetif thetif had a problem deploying to test-opensearch-components January 22, 2025 23:23 — with GitHub Actions Failure
@thetif thetif temporarily deployed to test-opensearch-components January 22, 2025 23:29 — with GitHub Actions Inactive
@thetif thetif had a problem deploying to test-opensearch-components January 22, 2025 23:29 — with GitHub Actions Failure
@thetif thetif temporarily deployed to test-opensearch-components January 22, 2025 23:33 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-kibana January 22, 2025 23:33 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-app January 22, 2025 23:33 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 22, 2025 23:33 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 22, 2025 23:33 — with GitHub Actions Inactive
@thetif thetif had a problem deploying to test-opensearch-components January 23, 2025 23:14 — with GitHub Actions Failure
@thetif thetif temporarily deployed to test-opensearch-components January 23, 2025 23:14 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 23, 2025 23:18 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 23, 2025 23:18 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-kibana January 23, 2025 23:18 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:22 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:24 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-kibana January 24, 2025 14:24 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:24 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-app January 24, 2025 14:24 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:24 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:36 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:36 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:38 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-app January 24, 2025 14:38 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components-kibana January 24, 2025 14:38 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:38 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 14:38 — with GitHub Actions Inactive
@thetif thetif marked this pull request as ready for review January 24, 2025 14:38
Copy link
Collaborator

@asharonbaltazar asharonbaltazar left a comment

Choose a reason for hiding this comment

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

Great work on simplifying

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good stuff. Much much more readable

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're updating comments, would it be nice to have them in JSX doc so they show up when hovering over the function?

@@ -11,7 +11,9 @@
"devDependencies": {},
"dependencies": {
"@18f/us-federal-holidays": "^4.0.0",
"moment-timezone": "^0.5.45",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good riddance

@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 18:22 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 18:22 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 18:25 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 18:25 — with GitHub Actions Inactive
@thetif thetif temporarily deployed to test-opensearch-components January 24, 2025 18:26 — with GitHub Actions Inactive
@thetif thetif merged commit 30b0726 into main Jan 24, 2025
15 checks passed
@thetif thetif deleted the test-opensearch-components branch January 24, 2025 18:40
Copy link
Contributor

🎉 This PR is included in version 1.5.0-val.114 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

RanyeM pushed a commit that referenced this pull request Jan 25, 2025
* added tests for opensearch components
* removed custom written UTC handling and replaced it with `@date-fns/utc`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants