RepoSense icon indicating copy to clipboard operation
RepoSense copied to clipboard

[#2136] Add Tests for Segment CSS

Open sopa301 opened this issue 1 year ago • 1 comments

Fixes #2136

Proposed commit message

Write Tests for Code Highlighting for Segment

A regression has occurred during refactoring of the Segment component.
It would be good to write tests to catch regressions if it happens
again for this component.

Let's write tests to catch further regressions of the same nature.

Other information

Hex values cannot be used directly because of Cypress limitations. Since we'll need an external library (Chai) for that, I have opted to use rgb values instead.

I chose to suppress warnings for testing the colors of a commit history of _colors.scss instead of using another file because it's a scss file which is unlikely to be touched, while the other files are java files. This may not be so necessary if the below concern is addressed.

Also, it seems that for quite a few tests (including the ones these are derived from), the until date is set to the current date, which can produce regressions like #2111. Additionally, for certain types of tests (like the ones which group a repo's entire commit history), certain assumptions (like the latest author for a line of code) can be broken which may cause the test to break.

The most convenient solution would be to set the until date for relevant tests to a fixed date in the past (like 2021), while the generated report for testing could also be anchored to a past date. Perhaps this should be addressed in another PR so we can avoid more nasty surprises.

sopa301 avatar Feb 22 '24 12:02 sopa301

I've also looked at #1613 suggesting snapshot testing, but I have a few concerns. For example, there may be differences between systems that make snapshots unreliable.

Here's a sample report from dashboard #2137 (The relevant commit history is taken from Jor, testrepo-Delta): image

And here's the locally built equivalent: image

Perhaps this points to a deeper bug, but I've opted to stay away from this solution for now. If anyone has an idea of what's causing or how to fix this, do let me know!

sopa301 avatar Feb 22 '24 15:02 sopa301

@reposense/active-developers Please help us with a final review for this PR!

ckcherry23 avatar Apr 01 '24 17:04 ckcherry23

The following links are for previewing this pull request:

  • Dashboard Preview: https://dashboard-2137-pr-reposense-reposense.surge.sh
  • Docs Preview: https://docs-2137-pr-reposense-reposense.surge.sh

github-actions[bot] avatar Apr 18 '24 13:04 github-actions[bot]