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

Revive tests/test.html #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

cwalther
Copy link
Contributor

As mentioned in #77, tests/test.html appears to have been left behind and currently neither works nor tests the current code. There are automated tests now, which is certainly better, but their coverage is limited, so I think the examples in test.html are still useful as additional manual regression tests. This commit revives them.

Fixing the “works” part required:

  • Adapting paths to the move of several things into public/.
  • Fixing the $.get() call that does not seem to automatically decode JSON when it's coming from a file:https:// URL.

To fix the “test the current code” part, it replaces the outdated public/docson.js by public/js/docson.js that is built from current sources: A script that can be loaded in the browser and exports the docson API as a global variable. (It also exports the bundled jQuery as a convenience to test.html that uses it, so it doesn’t have to bring its own copy, but if there is a better solution for that, src/index.js could also be webpacked directly.) Note that I’m not familiar with webpack and may be using it wrong, I just did what appears to work.

As an alternative solution, I first tried using widget.js, but gave up after hitting several obstacles: #73, it wouldn’t work when the <script> tags were generated by code rather than present in static HTML (apparently document.write() has no effect then), and the many iframes just looked messy.

The commit also removes public/lib/ that is not used by anything anymore.

I’m not sure what to do about the new generated file public/js/docson.js (as well as lib/docson.browser.js, which occured as a byproduct and is probably useless): My usual solution would be to add it to .gitignore, but then other generated files are committed and appear to be updated occasionally in a separate commit before a release, so I left it alone.

This reveals several deficiencies compared to http:https://lbovet.github.io/docson/tests/test.html, I will try to fix some of them in subsequent pull requests to make the tests useful again for regression-testing my own changes.

It appears to have bitrotted in several respects, but despite the new automated tests in integration/, these examples are still useful as additional manual regression tests. Reviving them required:

* Adapting paths to the move of several things into public/.
* Fixing the $.get() call that does not seem to automatically decode JSON when it's coming from a file:https:// URL.
* Replacing the outdated public/docson.js by public/js/docson.js that is built from current sources: A script that can be loaded in the browser and exports the docson API as a global variable. (It also exports the bundled jQuery as a convenience to test.html that uses it, so it doesn't have to bring its own copy, but if there is a better solution for that, src/index.js could also be webpacked directly.)
* Removing public/lib/ that is not used by anything anymore.
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

1 participant