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

refactor(react-components): unit tests for rule based coloring: core and sub components #5014

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

danpriori
Copy link
Contributor

Type of change

Refactor

Jira ticket 📘

https://cognitedata.atlassian.net/browse/

Description 📝

Unit test for the Rule Based Outputs for the functions and components in the subfolders: core and components.

Note: the MVVM refactoring will take place at the upper level components on the other ticket related to the unit test and MVVM for the other components like hooks and the entry point components like RuleBasedOutputSelector which calls the item components from this ticket and the entry Button.

How has this been tested? 🔍

Test instructions ℹ️

Checklist ☑️

  • I am proud of this feature.
  • I have performed a self-review of my own code.
  • I have added PR type (Feat, Bug, Chore, Test, Docs, Style, Refactor) to the PR title.
  • I have manually tested this for different scenarios (different models, formats, devices, browsers).
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the public documentation.
  • I have added unit and visuals tests to prove that my feature works to the best of my ability.
  • I have refactored the code for readability to the best of my ability.
  • I have checked that my changes do not introduce regressions in the public documentation.
  • I have outlined any known defects / lacking capabilities in the contents of this PR.
  • I have listed any remaining work that should follow this PR in the description or jira/miro/etc.
  • I have added TSDoc to any public facing changes.
  • I have added "developer documentation" in any package README.md that is related / applicable to this PR.
  • I have noted down and am currently tracking any technical debt introduced in this PR.
  • I have thoroughly thought about the architecture of this implementation.
  • I have asked peers to test this feature.

@danpriori danpriori requested a review from a team as a code owner February 23, 2025 23:40
@danpriori danpriori changed the title refactor(react-components): unit tests for rule based coloring refactor(react-components): unit tests for rule based coloring: core and sub components Feb 23, 2025
It will be back once the v10 is in reveal
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 32.00%. Comparing base (dfe17bb) to head (4c96525).
Report is 665 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5014       +/-   ##
===========================================
- Coverage   71.10%   32.00%   -39.11%     
===========================================
  Files         378      667      +289     
  Lines       38591    54383    +15792     
  Branches     2774      760     -2014     
===========================================
- Hits        27442    17407    -10035     
- Misses      11039    36753    +25714     
- Partials      110      223      +113     
Files with missing lines Coverage Δ
...ts/RuleBasedOutputs/components/OutputPanelItem.tsx 100.00% <100.00%> (ø)
...uleBasedOutputs/components/OutputPanelShowMore.tsx 100.00% <100.00%> (ø)
...BasedOutputs/components/RuleBasedSelectionItem.tsx 100.00% <100.00%> (ø)
...puts/core/analyzeAssetMappingsAgainstExpression.ts 100.00% <ø> (ø)
...eBasedOutputs/core/applyAssetMappingsNodeStyles.ts 100.00% <100.00%> (ø)
...sedOutputs/core/checkBooleanExpressionStatement.ts 100.00% <100.00%> (ø)
...edOutputs/core/checkDatetimeExpressionStatement.ts 96.00% <100.00%> (ø)
.../RuleBasedOutputs/core/generateRuleBasedOutputs.ts 100.00% <100.00%> (ø)
...sedOutputs/core/getTriggerTimeseriesNumericData.ts 100.00% <100.00%> (ø)

... and 1036 files with indirect coverage changes

Copy link
Contributor

@haakonflatval-cognite haakonflatval-cognite left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Just a couple of harmless comments

type: 'size',
fill: '',
label: 'Size'
} as unknown as RuleOutput;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this unknown-casting necessary? Can we instead add data into the object to make it fit the type? Or are we testing something that isn't really covered by the type system (in that case, I would actually rather that we either change the type or just don't test this case at all)

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 was considering a potential case if the type is non-type defined in RuleOutput type definitions (like canvasAnnotation, email, etc. that is covered by RuleOutput type but we dont support those yet) and this test just throw anything else other than "color" type.... but maybe you're right.. maybe we dont need to cover this case as well in here. I will remove it

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.

2 participants