WebMemex / webmemex-extension

📇 Your digital memory extension, as a browser extension
https://webmemex.org
Other
208 stars 45 forks source link

[Work in Progress] Testing Suite #107

Closed reficul31 closed 6 years ago

reficul31 commented 7 years ago

Refs

NOTE: Do not merge. Work in progress for the testing suite built with jest.

Status

reficul31 commented 7 years ago

Status Update.

reficul31 commented 7 years ago

I am actually a bit confused on the implementation of the following modules and any help will be greatly appreciated. This will help finish off the utils and the page-analysis module. To be clear, I am not sure how I can test these modules.

Treora commented 7 years ago

@reficul31: ok, good that you ask about it, I added a bit of documentation to those three utils to clarify their workings. Not perfect still. Ask if something specific is unclear, and feel free to suggest more/better documentation (especially the larger things in util should soon be spun off into their own repo's).

reficul31 commented 7 years ago

@Treora Thanks for updating the documentation for the functions in the util module. I actually wanted to know how to approach testing the functions in the module. Would there be some specific functionality you wanted to be tested for in those module?

reficul31 commented 7 years ago

This is a summary of all the problems I have been facing for quite a few days now.

Issue with the render method of src/options/components/navigation

There seems to be a very weird error that keeps recurring in the render method of the Navigation component in the options module. I know it is a problem with the tag, but I can't seem to figure out why. I have updated all my packages(repeatedly), scoured the world if weird react doubts, but nothing seem to be working. I know it is something extremely trivial but I can't seem to put my finger on it. To check out the failing test Test

Can't seem to figure out how to test these moudles

I already mentioned this before, but I can't seem to figure out a good testing method to test the following components. Any help will be extremely appreciated. Just to be clear I know what the modules are being used for I just want to know how should I go about testing them.

Progress Report 90 tests written Unit testing framework almost setup. Have started working on the on the UI/UX tests of options and overview module. Will write some integration tests this week as well.

For in depth progress report. Please refer to the blog.

Treora commented 7 years ago

Thanks for reporting the progress, and sorry to leave you hanging with some problems. Have you discussed them with your GSoC mentors? (as for the options page, I would not bother about it now, since we don't even have any options yet! I thought to just remove it from the code base for the moment)

I am now working hard on getting a release out, and hacking proof-of-concepts to demo and explore subsequent features. I plan to have a break from that effort next week, and reserve a few days to clean up, document and reorganise code (#112), which would be a good moment to add some tests! Perhaps we could find some time then to code together over chat or call?

reficul31 commented 7 years ago

Sure thing! Dm me whenever you find the time to talk. I know the release date is coming fast, thanks for taking the effort to reply to my queries. I know you must be swamped. As for the options module it's up to you to leave it in. I have written some tests which I think act as great placeholders for system tests for when the module is ready. The query was one of concept.

Have you discussed them with your GSoC mentors?

This is the agreed upon place of discussion with my mentors where I can communicate with them easily.

ghost commented 7 years ago

Issue with the render method of src/options/components/navigation

There seems to be a very weird error that keeps recurring in the render method of the Navigation component in the options module. I know it is a problem with the tag, but I can't seem to figure out why. I have updated all my packages(repeatedly), scoured the world if weird react doubts, but nothing seem to be working. I know it is something extremely trivial but I can't seem to put my finger on it. To check out the failing test Test

I have debugged the issue. @reficul31 You need to downgrade react-router in package.json to "react-router": "^3.0.5". The problem is that @Treora has recently upgraded react-router to 4.x and hasn't done the necessary migrations (+ using react-router-dom), which resulted in import { Link } from 'react-router' not being an export anymore.

How have I debugged and found the problem

(Might be interesting to learn from for future errors)

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `Navigation`.
ghost commented 7 years ago

Response to: Can't seem to figure out how to test these moudles

I already mentioned this before, but I can't seem to figure out a good testing method to test the following components. Any help will be extremely appreciated. Just to be clear I know what the modules are being used for I just want to know how should I go about testing them.

src/page-analysis/background/index src/page-analysis/content_script/extract-pdf-content src/util/event-to-promise src/util/sync-location-hash src/util/tab-events src/util/webextensionRPC src/util/when-all-settled

If you still have trouble testing anything after reading the suggestions, let me know. I didn't write down every detail.

Suggestions for testing

src/page-analysis/background/index

src/page-analysis/content_script/extract-pdf-content

src/util/event-to-promise

src/util/sync-location-hash

function createWindowStub({hash}) {
  return {
    location: {hash},
    addEventListener: jest.fn(),
    removeEventListener: jest.fn()
  }
}

src/util/tab-events

If we want to unit test those functions, I would mock the browser.tabs API.

src/util/webextensionRPC

src/util/when-all-settled

reficul31 commented 7 years ago

So I have been writing some React tests using enzyme, and I was wondering to get some help regarding what all functionality is to be tested for. Right now the way the react tests stands is

I would really like to know more things I could test for in the components. Ps. I have also added a test for src/dev/redux-devtools-component.jsx just to check if it mounts correctly.