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

test(react-components) Unit test for UndoManager #5028

Merged
merged 7 commits into from
Mar 6, 2025

Conversation

nilscognite
Copy link
Contributor

Type of change

Test <!-- adding missing tests, refactoring tests; no production code

Description 📝

This test the classes

  • UndoManager
  • DomainObjectTransaction
  • Transaction

@@ -82,12 +82,6 @@ export class RevealRenderTarget {
options?: RevealRenderTargetOptions
) {
this._viewer = viewer;

const cameraManager = this.cameraManager;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not needed and will give problems in the unit test

@@ -42,10 +40,6 @@ export abstract class BoxDomainObject extends SolidDomainObject {
// OVERRIDES of DomainObject
// ==================================================

public override get icon(): IconName {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed, implementation is already in the base class

@@ -32,10 +30,6 @@ export abstract class CylinderDomainObject extends SolidDomainObject {
// OVERRIDES of DomainObject
// ==================================================

public override get icon(): IconName {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed, implementation is already in the base class

@@ -36,6 +37,8 @@ export const cameraManagerMock = new Mock<CameraManager>()
})
.setup((p) => p.getCameraState())
.returns(cameraManagerGlobalCurrentCameraState as Required<CameraState>)
.setup((p) => p.getCamera)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to the ,mock. It is needed.

@@ -43,4 +43,16 @@ export const viewerMock = new Mock<Cognite3DViewer<DataSourceType>>()
.returns(fitCameraToModelsMock)
.setup((p) => p.requestRedraw)
.returns(vi.fn())
.setup((p) => p.on)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also needed in the unit tests

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.

Project coverage is 24.31%. Comparing base (943e515) to head (590c73f).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...mponents/src/architecture/base/undo/Transaction.ts 66.66% 2 Missing ⚠️
...mponents/src/architecture/base/undo/UndoManager.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5028      +/-   ##
==========================================
+ Coverage   23.69%   24.31%   +0.61%     
==========================================
  Files         686      686              
  Lines       36817    36809       -8     
  Branches     1275     1368      +93     
==========================================
+ Hits         8725     8949     +224     
+ Misses      27816    27584     -232     
  Partials      276      276              
Files with missing lines Coverage Δ
...chitecture/base/renderTarget/RevealRenderTarget.ts 43.70% <ø> (+15.60%) ⬆️
.../architecture/base/undo/DomainObjectTransaction.ts 90.24% <ø> (+73.17%) ⬆️
...chitecture/concrete/example/ExampleDomainObject.ts 37.31% <100.00%> (ø)
...tecture/concrete/primitives/box/BoxDomainObject.ts 27.40% <ø> (+7.98%) ⬆️
...re/concrete/primitives/common/SolidDomainObject.ts 42.85% <ø> (+8.16%) ⬆️
...ncrete/primitives/cylinder/CylinderDomainObject.ts 23.33% <ø> (-1.14%) ⬇️
...cture/concrete/primitives/line/LineDomainObject.ts 22.75% <100.00%> (ø)
...ure/concrete/primitives/plane/PlaneDomainObject.ts 24.85% <100.00%> (ø)
...mponents/src/architecture/base/undo/UndoManager.ts 77.27% <75.00%> (+58.22%) ⬆️
...mponents/src/architecture/base/undo/Transaction.ts 84.61% <66.66%> (+55.44%) ⬆️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@anders-hopland anders-hopland left a comment

Choose a reason for hiding this comment

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

LGTM

@nilscognite nilscognite requested review from a team and finnag and removed request for a team March 6, 2025 12:20
Copy link

@finnag finnag left a comment

Choose a reason for hiding this comment

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

🦄

@nilscognite nilscognite enabled auto-merge (squash) March 6, 2025 12:55
@nilscognite nilscognite merged commit 1b7e69e into master Mar 6, 2025
15 checks passed
@nilscognite nilscognite deleted the np/undo-unit-test branch March 6, 2025 13:00
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.

3 participants