code-charity / youtube

[top~1 open YouTube & Video web-extension] Enrich your experience & choice! 🧰100+clever features📌set&forget📌Longest-standing(yet rare&tough alone. Please help/join🧩us👨‍👩‍👧‍👧) ..⋮ {playback|content discovery|player|extra buttons|distractions|related videos|shorts|ads|quality|codec|full tab|full screen}
http://improvedtube.com
Other
3.28k stars 497 forks source link

Add testing framework and Initial Tests #2332

Open PTheocharis opened 1 week ago

PTheocharis commented 1 week ago

I have noticed that there is currently no test coverage in this project. To improve the stability and maintainability of ImprovedTube, I suggest adding a testing framework and some initial tests. This will aid potential contributing developers to notice where the mistakes are and focus on it accordingly. A framework will also provide a platform for future contributors and encourage them to add more tests increasing the coverage.

Proposed Solution: -Add a Testing Framework for Javascript segments (at first): Using tools like MochaJS, Jest or Jasmine -Create a tests folder in the root of the project to store all test files. -Add Initial Tests on some features

Steps to Reproduce:

  1. Integrate the framework into the project by installing it via npm/yarn.
  2. Create the tests folder.
  3. Add initial test cases for core functionalities.
  4. Run the tests

Should I start on this issue? Do you have any preferences for the framework?

ImprovedTube commented 1 week ago

hi! @PTheocharis welcome back! And thank you!
Sounds good, just adding context:
We can chose tools by most code (/ best features / most dev activity), (next to ease of use and what you used before, in case you want to dedicate time regularly.)

We can start with making github automatically check syntax typos at every commit.

( from 2021 https://github.com/code-charity/youtube/issues/842#issue-838847298 )


Some issues could be easier to prevent than test (Many features might be written once and for all others require change after youtube DOM updates, some of which we could predict by wider CSS selectors or making the extension itself run an analysis of the DOM every now and then to notice some changes. Or we could at least base all of these features on a rule set like this: https://github.com/gijsdev/ublock-hide-yt-shorts/blob/master/list.txt (- and such rule-set can be loaded into an extension from a github repo without updating the stores. compare: https://github.com/darkreader/darkreader/tree/main/src/config) )

PTheocharis commented 1 week ago

To clarify: Do you want me to start my suggested plan with Jest for example, take up issue #842 or both?

ImprovedTube commented 1 week ago

you chose! all options sound good.

I might just be consolidating issue threads (842 could be closed maybe)

Looking forward to teamwork and run integrations and automations (only one yet: https://github.com/code-charity/youtube/blob/master/.github/workflows/build-safari-app.yml thanks to @dodieboy
and @unnamed-orbert was syncing with @crowdin (just gave up on that currently ) )

raszpl commented 1 week ago

Even something as basic as Github Action to validate js and run it thru JSLint on every push would be great.

PTheocharis commented 1 week ago

I have already placed Jest as a framework and placed some initial indicative tests. I will try to add JSlint now.

ImprovedTube commented 1 week ago

BTW, imagine we had to run many routines, like JSLint on every commit in all Repos from 10 to 10000 Stars. How would we find everything on the list, and prioritize it to remain universal?
(compare "Wikipedia's many bots" https://github.com/code-charity/Bulk-Contributor)

raszpl commented 1 week ago

yay github action linter, nice! Did I say JSLint? I meant ESLint, sorry :( JSLint author has this weird notion everyone should format code like he does and everything else is prohibited (Tabs). There is https://github.com/marketplace/actions/run-eslint but I dont know where you configure rules for the linter.

/*eslint indent: ["error", "tab"]*/

raszpl commented 3 days ago

btw current JSLint just fails to parse our codebase and errors out at 4%, but the test still reports pass, so it should not be relied upon at all until fixed