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

Reviewed Additional Javascript Tests #247

Open
wants to merge 1,016 commits into
base: master
Choose a base branch
from

Conversation

zmetcalf
Copy link
Contributor

@clarkbarz reviewed the javascript tests in pull request #128, which was requested in #127.

justinstollsteimer and others added 30 commits July 10, 2013 11:28
signalhandlers.patch_url_conf calls get_urlconf with a single argument.
It's awkward to be able to drop the success handler anywhere, but
not be able to move it aftewards.
If we disable the submit button in the submit handler, the browser won't
submit its value. We need this value to determine which button was
pressed.
Models with WidgyFields should define a get_action_links method. It
takes a root_node and returns a list of links. This is used for preview
links.

  - Removes the dependency in core on widgy_mezzanine for preview links
  - Removes the VersionCommitAdmin.get_commit_name and
    get_commit_preview_url methods.
  - Removes an attempt at making forms.WidgyField work for non-model
    forms. We'll revisit this when it comes up.
  - Adds preview and diff links for every owner of a VersionTracker.
Because "Django uses different formats for displaying data to those it
uses for parsing data", when using i18n and having a LANGUAGE_CODE other
than 'en', but still viewing the page in English, the widget will output
with the wrong format.
require.js loads data-main asynchronously, so our inline javascript to
instantiate widgy sometimes runs before require is configured. This
results in require not being able to find libraries, and widgy fails to
start. This fixes the intermittent 'blank widgy editor' bug.

Also fixes a hardcoding of `/static/` paths when `{% static %}` should
be used instead.
This test has not been testing anything for a while, because passing
HTTP_COOKIE to the test-client methods was overriding the test client's
cookies, including the session that had a logged-in user. The test
verified that a 403 was being returned, but the 403 wasn't from where we
expected (the UnauthenticatedWidgySite). Also, UnauthenticatedWidgySite
was overriding `authorize`, which doesn't exist any more. The new method
is called `authorize_view`, but this wasn't detected because the test
isn't robust enough.

This patch mocks widgy_site.authorize_view method to ensure it's called,
instead of relying on the PermissionDenied exception. This also allows
us to get rid of UnauthenticatedWidgySite.
Debug toolbar loads all the panel modules regardless of settings.DEBUG.
If we monkey patch at the module level, we'll always replace
get_templates_hierarchy, even in production mode.
Until Django bug #20806 is fixed, we should memoize select_template
because we call it many times with long lists of templates to choose
from. This results in a large speedup while rendering the editors for
large trees.
The request to fetch compatibility data for the shelf can start before
Widgy is done rendering. This results in less latency for the shelf to
be ready.
Instead of making a .drag_placeholder element and trying to get it to
behave exactly like the shelf item, just clone the shelf item. This
prevents the rest of the items from moving at all when picking up a
widget.

Co-Authored-By: Antoine Catton <[email protected]>
Co-Authored-By: Justin Stollsteimer <[email protected]>
Use django-require to bundle Widgy's js during collectstatic.

`widgy-main.js` is a stub that gets turned into the widgy js bundle
during collectstatic. This allows us to always include it during
development. Since it doesn't do anything, require.js will work as
normal (lazily loading everything), until the bundle gets built.
* require:
  cachebust require.js in development
  Fix css paths to make it work with CachedStaticFilesStorage
  Use the require.js optimizer

var create_editor = function(node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions are general camelcased in widgy's javascript. I know it's not important, but it would be nice to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you are getting at here. What would you like changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call it createEditor instead please?

@zmetcalf
Copy link
Contributor Author

@rockymeza, I made the remaining changes, how do you want this squashed since we have some changes from @clarkbarz at some point there?

@rockymeza
Copy link
Contributor

Hi @zmetcalf,

I'm not sure how we should go about restructuring the commits. @gavinwahl, thoughts?

_ = requirejs('underscore');

describe('DraggableView', function() {
var TestView = DraggableView.extend({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this class.

@rockymeza
Copy link
Contributor

@zmetcalf, we're getting a lot closer to a merge! I just have some more comments that we should address before squashing. I think some of the comments must have gotten lost as you were making updates.

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.

6 participants