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

Creating the core test suite #392

Closed
sophieeng opened this issue Dec 22, 2022 · 11 comments
Closed

Creating the core test suite #392

sophieeng opened this issue Dec 22, 2022 · 11 comments
Assignees
Labels
testing Accuracy, performance, or other testing issue

Comments

@sophieeng
Copy link
Collaborator

I will create a checklist in this issue of the core tests for the test suite. This is referring to the most important functions to test and will give a basic skeleton that we can begin to add onto.

@sophieeng sophieeng added the testing Accuracy, performance, or other testing issue label Dec 22, 2022
@sophieeng sophieeng self-assigned this Dec 22, 2022
@OliverWang13
Copy link
Collaborator

The biggest issue I am able to predict here is that we may not have a good way to test our ability to set DOM signals and send headers, our two most important functionalities.

I am not sure if we are able to do this because Mocha likely doesn't provide a web page where we can test our code on. It is hard to tell if we can properly set the DOM signal if we can't check where we injected the script to see if it worked or not. The same goes for our headers. If we can find some way to test with a web page (possibly with a headless browser), this would instead be an issue of checking the navigator.GlobalPrivacyControl item and seeing if our header is properly set (not sure how to do that yet).

As a workaround for Chrome, assuming we trust our dynamic rules and content scripts to do their jobs, we could instead test our abilities to register content scripts, modify content scripts, and create/ remove dynamic rules. Firefox does not make use of these and the basis on which it decides to apply DOM signals/headers are based on local variables which would be more difficult to test.

@OliverWang13
Copy link
Collaborator

To point us in a direction, I think that creating test suites to use the functions in editDomainlist.js and editRules.js would be productive. We may have to register the content scripts and the dynamic rules to be able to test these functions though.

sophieeng added a commit that referenced this issue Jan 3, 2023
sophieeng added a commit that referenced this issue Jan 3, 2023
sophieeng added a commit that referenced this issue Jan 3, 2023
sophieeng added a commit that referenced this issue Jan 3, 2023
@SebastianZimmeck
Copy link
Member

The biggest issue I am able to predict here is that we may not have a good way to test our ability to set DOM signals and send headers, our two most important functionalities.

That is the general limitation of all unit test frameworks. Some functionality, e.g., retrieving data from a database, client-server interaction, or pushing buttons on the UI, is difficult to test. For those it may be necessary to set up some fake data coming in, hardcode the signal of a button-push, etc. I am not familiar with Mocha in particular, but generally mocking and using test fixtures is the way to go in those cases.

@OliverWang13
Copy link
Collaborator

As @sophieeng and I discussed, I now believe it is possible to test the DOM signal. Specifically, I decided to look at unit tests made by Duckduckgo. They have two files that I believe will be helpful: test-canvas.js and gpc.js. I believe we can also make use of a site called https://good.third-party.site/privacy-protections/gpc/ to test it as well.

@SebastianZimmeck
Copy link
Member

I now believe it is possible to test the DOM signal.

Excellent! Let's do it!

@OliverWang13
Copy link
Collaborator

I am trying to replicate the same test as duckduckgo does in their test-canvas.js file involving opening a web page and scraping the needed information, but I am missing some information on two packages that they use, backgroundWait and pageWait. @sophieeng, could you take a look into what we can do about this? Additionally, could you check out the file and let me know if you think this is a valid direction to go?

@SebastianZimmeck
Copy link
Member

As discussed, let's try to finish the test suite by mid-February, at which point we also should make a new release.

@OliverWang13
Copy link
Collaborator

I've been able to create a test for the header and the gpc signal by using the 'https://global-privacy-control.glitch.me/' site. @sophieeng and I might look at some other aspects of the extension and see whether we can test them using puppeteer and mocha.

@OliverWang13
Copy link
Collaborator

@sophieeng and I tested a few other aspects with puppeteer and did not find them to be successful, but we are satisfied with testing the GPC Dom and Header signal. I will push the changes to main and close this issue.

@sophieeng
Copy link
Collaborator Author

sophieeng commented Feb 20, 2023

The Manual UI Testing Procedure which I Oliver and I are discussing how to add to the ReadMe.

@OliverWang13
Copy link
Collaborator

The merge conflicts are now resolved, but I had to make it so the puppeteer gpc test doesn't run with the continuous integration. This way, it will only run with npm test done locally. I think that the puppeteer test cannot run with CI because it is not headless. I will merge the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Accuracy, performance, or other testing issue
3 participants