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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃帹 [RUM-262] Move view metrics in dedicated files #2386

Merged
merged 6 commits into from Aug 29, 2023

Conversation

amortemousque
Copy link
Contributor

@amortemousque amortemousque commented Aug 23, 2023

Motivation

Isolate each view metrics and initial view timings in a dedicated file for easier maintenance and discoverability

Changes

before after
image image

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@amortemousque amortemousque marked this pull request as ready for review August 23, 2023 09:29
@amortemousque amortemousque requested a review from a team as a code owner August 23, 2023 09:29
@bcaudan
Copy link
Contributor

bcaudan commented Aug 24, 2023

Should we do something with initialViewTimings as well?

Copy link
Member

Choose a reason for hiding this comment

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

It seems you replaced the tests from this file with the test suite that was in trackViewMetrics.spec.ts. So, this spec file is not about trackViewEventCounts anymore: it's a higher level test suite that actually test the behavior of trackViewMetrics (actually, trackViews, since trackViewMetrics isn't used directly either).

I don't think that's a good idea. Spec files should be about testing the corresponding module, not a higher level module, else we won't have unit tests anymore and only integration tests.

I understand that it was already the case in the previous trackViewMetrics.spec.ts where trackViews was used (via setupViewTest) instead of trackViewMetrics, which isn't great, but I still think this PR shouldn't remove real unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the problem you describe is true for all the new viewMetrics/* modules.
While I agree on the fact that spec files should be about testing the corresponding module in this case it would mean rewriting lots of tests. This PR was more about readability and discoverability, so I'm wondering if revisiting these tests will bring much value for now. Wdyt?

Also about trackViewEventCounts original tests, to me it has a strange level of testing because it's mainly a wrapper around trackEventCounts which already has unit tests. So in that sens it could already be considered has integration tests which is why I merged it with the tests in trackViewMetrics.spec.ts

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the problem you describe is true for all the new viewMetrics/* modules. While I agree on the fact that spec files should be about testing the corresponding module in this case it would mean rewriting lots of tests. This PR was more about readability and discoverability, so I'm wondering if revisiting these tests will bring much value for now. Wdyt?

I agree, this is not the place or the time to change the tests :) my concern was more about removed tests

Also about trackViewEventCounts original tests, to me it has a strange level of testing because it's mainly a wrapper around trackEventCounts which already has unit tests. So in that sens it could already be considered has integration tests which is why I merged it with the tests in trackViewMetrics.spec.ts

I don't agree,trackViewEventCounts tests were specifically testing trackViewEventCounts logic (increment when receiving an event related to the view, don't increment when it's not related to the view, delayed stop)

@amortemousque amortemousque force-pushed the aymeric/isolate-view-metrics-dedicated-files branch from 5319186 to 34648f0 Compare August 25, 2023 14:53
@amortemousque amortemousque force-pushed the aymeric/isolate-view-metrics-dedicated-files branch from d7681fd to c0e83a7 Compare August 25, 2023 16:00
@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2023

Codecov Report

Merging #2386 (1a4eb40) into main (323d407) will decrease coverage by 0.02%.
Report is 3 commits behind head on main.
The diff coverage is 98.99%.

@@            Coverage Diff             @@
##             main    #2386      +/-   ##
==========================================
- Coverage   93.91%   93.89%   -0.02%     
==========================================
  Files         212      219       +7     
  Lines        6312     6311       -1     
  Branches     1405     1405              
==========================================
- Hits         5928     5926       -2     
- Misses        384      385       +1     
Files Changed Coverage 螖
.../domain/rumEventsCollection/view/viewCollection.ts 100.00% <酶> (酶)
...ction/view/viewMetrics/interactionCountPolyfill.ts 47.05% <酶> (酶)
...ntsCollection/view/viewMetrics/trackFirstHidden.ts 100.00% <酶> (酶)
...on/view/viewMetrics/trackInteractionToNextPaint.ts 100.00% <酶> (酶)
...ion/view/viewMetrics/trackCumulativeLayoutShift.ts 94.73% <94.73%> (酶)
.../src/domain/rumEventsCollection/view/trackViews.ts 100.00% <100.00%> (酶)
...lection/view/viewMetrics/trackCommonViewMetrics.ts 100.00% <100.00%> (酶)
...tion/view/viewMetrics/trackFirstContentfulPaint.ts 100.00% <100.00%> (酶)
...lection/view/viewMetrics/trackFirstInputTimings.ts 100.00% <100.00%> (酶)
...ection/view/viewMetrics/trackInitialViewMetrics.ts 100.00% <100.00%> (酶)
... and 4 more

... and 1 file with indirect coverage changes

馃摚 We鈥檙e building smart automated test selection to slash your CI/CD build times. Learn more

@amortemousque amortemousque force-pushed the aymeric/isolate-view-metrics-dedicated-files branch from 698fcd4 to 0fa717b Compare August 28, 2023 07:24
@amortemousque amortemousque merged commit d65e956 into main Aug 29, 2023
17 checks passed
@amortemousque amortemousque deleted the aymeric/isolate-view-metrics-dedicated-files branch August 29, 2023 08:26
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.

None yet

4 participants