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

Fixes #2288: Refactor how we do form submission #2419

Merged
merged 16 commits into from
May 1, 2018
Merged

Conversation

miketaylr
Copy link
Member

Just pushing these deps upgrades so I can see what tests fail and fix them. Not worth looking at yet!

@miketaylr

This comment has been minimized.

@miketaylr

This comment has been minimized.

@miketaylr

This comment has been minimized.

@miketaylr

This comment has been minimized.

@TravisBuddy
Copy link

TravisBuddy commented Apr 24, 2018

Travis tests have failed

Hey @miketaylr,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

1st Build

npm run test:js -- --reporters="runner" --firefoxBinary=`which firefox`
> webcompat@ test:js /home/travis/build/webcompat/webcompat.com
> node ./tests/functional/_intern.js "--reporters=runner" "--firefoxBinary=/home/travis/firefox-58.0/firefox/firefox"

Listening on localhost:9000 (ws 9001)
Tunnel started

‣ Created remote session firefox on linux 4.4.0-101-generic (33598be0-e27b-4e77-bae7-258a389c93ae)
✓ firefox on linux 4.4.0-101-generic - Comments (auth) - Comments form visible when logged in (0.688s)
✓ firefox on linux 4.4.0-101-generic - Comments (auth) - Posting a comment (2.087s)
✓ firefox on linux 4.4.0-101-generic - Comments (auth) - Posting an empty comment fails (2.636s)
× firefox on linux 4.4.0-101-generic - Comments (auth) - Add a screenshot to a comment (5.67s)
    AssertionError: The image was correctly uploaded and its URL was copied to the comment text.: expected '' to include '[![Screenshot Description](http://localhost:5000/uploads/'
      at Command.Add a screenshot to a comment.FunctionalHelpers.openPage.findById.type.end.sleep.execute.then.val  <tests/functional/comments-auth.js:97:18>
      at Test.Add a screenshot to a comment [as test]  <tests/functional/comments-auth.js:96:10>
      at <src/lib/Test.ts:260:47>

✓ firefox on linux 4.4.0-101-generic - Comments (auth) - Pressing 'g' inside of comment textarea *doesn't* go to github issue (2.637s)
✓ firefox on linux 4.4.0-101-generic - Comments (auth) - Pressing 'l' inside of comment textarea *doesn't* open the label editor box (0.619s)
✓ firefox on linux 4.4.0-101-generic - Comments (non-auth) - Comment form not visible for logged out users (10.464s)
✓ firefox on linux 4.4.0-101-generic - History navigation - Back button works from issues page (1.507s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - postMessaged dataURI preview (1.303s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - postMessaged blob preview (1.327s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - uploaded image file preview (1.368s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - postMessaged dataURI image doesn't upload before form submission (1.31s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - postMessaged blob image doesn't upload before form submission (1.329s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - uploaded image file doesn't upload before form submission (1.343s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - remove image upload button is shown (1.352s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - clicking remove image upload button removes preview (1.347s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - clicking remove image upload button removes image URL (1.334s)
✓ firefox on linux 4.4.0-101-generic - Image Uploads (non-auth) - double image select works (3.441s)
✓ firefox on linux 4.4.0-101-generic - Index - front page loads (0.408s)
✓ firefox on linux 4.4.0-101-generic - Index - reporter addon link is shown (0.465s)
✓ firefox on linux 4.4.0-101-generic - Index - form toggles open then closed (3.081s)
✓ firefox on linux 4.4.0-101-generic - Index - browse issues (needstriage) (0.621s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - FilterView renders (0.576s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - IssueListView renders (1.762s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - PaginationControlsView tests (6.539s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Pagination dropdown tests (1.348s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Pressing g goes to github issues (1.339s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Pressing g inside of search input *doesn't* go to github issues (0.894s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Loading issues page has default params in URL (0.633s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Loading partial params results in merge with defaults (0.667s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Dropdowns reflect state from URL (0.686s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Going back in history updates issue list and URL state (1.385s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Loading URL with stage param loads issues (0.569s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Clicking on a stage filter adds the correct param to the URL (0.94s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Toggling a stage filter doesn't leave the param in the URL (1.103s)
✓ firefox on linux 4.4.0-101-generic - Issue-list - Toggling between stage filters results in last param in URL (1.134s)
✓ firefox on linux 4.4.0-101-generic - Issues (auth) - Pressing 'l' opens the label editor box (0.731s)
✓ firefox on linux 4.4.0-101-generic - Issues - Issue page loads (0.678s)
✓ firefox on linux 4.4.0-101-generic - Issues - Issue comments load (0.625s)
✓ firefox on linux 4.4.0-101-generic - Issues - Pressing g goes to the github issue page (1.165s)
✓ firefox on linux 4.4.0-101-generic - Issues - NSFW images are blurred (0.48s)
✓ firefox on linux 4.4.0-101-generic - Issues - Clicking NSFW images toggles between blurry and not-blurry (1.059s)
✓ firefox on linux 4.4.0-101-generic - Labels (auth) - Label editor opens then closes (clicks) (1.28s)
✓ firefox on linux 4.4.0-101-generic - Labels (auth) - Label editor opens then closes (key events) (0.819s)
✓ firefox on linux 4.4.0-101-generic - Labels (auth) - Clicking outside label editor closes it (0.915s)
✓ firefox on linux 4.4.0-101-generic - Labels (auth) - Clicking close button actually closes it (0.676s)
✓ firefox on linux 4.4.0-101-generic - Milestones (auth) - Milestone editor opens then closes (clicks) (1.297s)
✓ firefox on linux 4.4.0-101-generic - Milestones (auth) - Milestone editor opens then closes (key events) (0.927s)
✓ firefox on linux 4.4.0-101-generic - Milestones (auth) - Clicking outside milestone editor closes it (1.05s)
✓ firefox on linux 4.4.0-101-generic - Milestones (auth) - Clicking close button actually closes it (0.74s)
✓ firefox on linux 4.4.0-101-generic - Milestones (non-auth) - Page loads without milestone set (0.452s)
✓ firefox on linux 4.4.0-101-generic - Milestones (non-auth) - Missing status error displays (0.423s)
✓ firefox on linux 4.4.0-101-generic - New Issue Page - new issue page loads (0.325s)
✓ firefox on linux 4.4.0-101-generic - Reporting (auth) - Report button shows name (0.308s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Submit buttons are disabled (0.429s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Wyciwyg bug workaround (0.817s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Report button shows via GitHub (0.318s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - URL validation (1.218s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Description validation (1.266s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - (optional) browser + os validation (0.898s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Image extension validation (0.504s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - Submits are enabled (1.019s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - problem_type param selects problem type (0.314s)
✓ firefox on linux 4.4.0-101-generic - Reporting (non-auth) - details param doesn't add info to description (0.385s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search/filter interaction (1.841s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Results are loaded from the query params (0.459s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search works by icon click (1.11s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search works by Return key (0.975s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search from the homepage (2.663s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search with a dash works (0.761s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - After search without results, suggested label appear and have a clickable URL. (3.563s)
✓ firefox on linux 4.4.0-101-generic - Search (auth) - Search input is loaded from q param (with dashes) (0.416s)
✓ firefox on linux 4.4.0-101-generic - Search (non-auth) - Pressing g inside of search input *doesnt* go to github issues (0.98s)
✓ firefox on linux 4.4.0-101-generic - Search (non-auth) - Clicking on label search adds query parameter to the URL (1.02s)
✓ firefox on linux 4.4.0-101-generic - Search (non-auth) - Clicking on label search updates the search input (3.529s)
✓ firefox on linux 4.4.0-101-generic - Search (non-auth) - Search input is visible (0.742s)
✓ firefox on linux 4.4.0-101-generic - Search (non-auth) - Empty search input removes q param (3.709s)
✓ firefox on linux 4.4.0-101-generic - User Activity (auth) - We're at the right place (0.602s)
✓ firefox on linux 4.4.0-101-generic - User Activity (auth) - IssueListView renders (1.887s)
✓ firefox on linux 4.4.0-101-generic - User Activity (auth) - Trying to view someone else's activity fails (logged in) (0.336s)
✓ firefox on linux 4.4.0-101-generic - User Activity (non-auth) - Trying to view someone else's activity fails (logged out) (0.431s)
No unit test coverage for firefox on linux 4.4.0-101-generic
firefox on linux 4.4.0-101-generic: 80 passed, 1 failed

‣ Created remote session chrome 66.0.3359.139 on Linux (fd47d4cbcb716ed6d56c660d1f358c4e)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Comments form visible when logged in (0.357s)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Posting a comment (1.613s)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Posting an empty comment fails (2.281s)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Add a screenshot to a comment (5.319s)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Pressing 'g' inside of comment textarea *doesn't* go to github issue (2.342s)
✓ chrome 66.0.3359.139 on Linux - Comments (auth) - Pressing 'l' inside of comment textarea *doesn't* open the label editor box (0.411s)
✓ chrome 66.0.3359.139 on Linux - Comments (non-auth) - Comment form not visible for logged out users (10.202s)
✓ chrome 66.0.3359.139 on Linux - History navigation - Back button works from issues page (1.029s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - postMessaged dataURI preview (1.208s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - postMessaged blob preview (1.185s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - uploaded image file preview (1.235s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - postMessaged dataURI image doesn't upload before form submission (1.203s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - postMessaged blob image doesn't upload before form submission (1.18s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - uploaded image file doesn't upload before form submission (1.224s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - remove image upload button is shown (1.261s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - clicking remove image upload button removes preview (1.2s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - clicking remove image upload button removes image URL (1.21s)
✓ chrome 66.0.3359.139 on Linux - Image Uploads (non-auth) - double image select works (3.27s)
✓ chrome 66.0.3359.139 on Linux - Index - front page loads (0.404s)
✓ chrome 66.0.3359.139 on Linux - Index - reporter addon link is shown (0.416s)
✓ chrome 66.0.3359.139 on Linux - Index - form toggles open then closed (2.582s)
✓ chrome 66.0.3359.139 on Linux - Index - browse issues (needstriage) (0.522s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - FilterView renders (0.307s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - IssueListView renders (1.572s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - PaginationControlsView tests (0.922s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Pagination dropdown tests (0.951s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Pressing g goes to github issues (2.486s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Pressing g inside of search input *doesn't* go to github issues (0.513s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Loading issues page has default params in URL (0.379s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Loading partial params results in merge with defaults (0.309s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Dropdowns reflect state from URL (0.39s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Going back in history updates issue list and URL state (0.855s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Loading URL with stage param loads issues (0.326s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Clicking on a stage filter adds the correct param to the URL (0.409s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Toggling a stage filter doesn't leave the param in the URL (0.832s)
✓ chrome 66.0.3359.139 on Linux - Issue-list - Toggling between stage filters results in last param in URL (0.691s)
✓ chrome 66.0.3359.139 on Linux - Issues (auth) - Pressing 'l' opens the label editor box (0.358s)
✓ chrome 66.0.3359.139 on Linux - Issues - Issue page loads (0.365s)
✓ chrome 66.0.3359.139 on Linux - Issues - Issue comments load (0.314s)
✓ chrome 66.0.3359.139 on Linux - Issues - Pressing g goes to the github issue page (2.525s)
✓ chrome 66.0.3359.139 on Linux - Issues - NSFW images are blurred (0.281s)
✓ chrome 66.0.3359.139 on Linux - Issues - Clicking NSFW images toggles between blurry and not-blurry (0.493s)
✓ chrome 66.0.3359.139 on Linux - Labels (auth) - Label editor opens then closes (clicks) (0.539s)
✓ chrome 66.0.3359.139 on Linux - Labels (auth) - Label editor opens then closes (key events) (0.442s)
✓ chrome 66.0.3359.139 on Linux - Labels (auth) - Clicking outside label editor closes it (0.463s)
✓ chrome 66.0.3359.139 on Linux - Labels (auth) - Clicking close button actually closes it (0.36s)
✓ chrome 66.0.3359.139 on Linux - Milestones (auth) - Milestone editor opens then closes (clicks) (0.509s)
✓ chrome 66.0.3359.139 on Linux - Milestones (auth) - Milestone editor opens then closes (key events) (0.511s)
✓ chrome 66.0.3359.139 on Linux - Milestones (auth) - Clicking outside milestone editor closes it (0.45s)
✓ chrome 66.0.3359.139 on Linux - Milestones (auth) - Clicking close button actually closes it (0.327s)
✓ chrome 66.0.3359.139 on Linux - Milestones (non-auth) - Page loads without milestone set (0.235s)
✓ chrome 66.0.3359.139 on Linux - Milestones (non-auth) - Missing status error displays (0.238s)
✓ chrome 66.0.3359.139 on Linux - New Issue Page - new issue page loads (0.189s)
✓ chrome 66.0.3359.139 on Linux - Reporting (auth) - Report button shows name (0.169s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Submit buttons are disabled (0.265s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Wyciwyg bug workaround (0.169s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Report button shows via GitHub (0.176s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - URL validation (0.951s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Description validation (0.927s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - (optional) browser + os validation (0.668s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Image extension validation (0.294s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - Submits are enabled (0.81s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - problem_type param selects problem type (0.17s)
✓ chrome 66.0.3359.139 on Linux - Reporting (non-auth) - details param doesn't add info to description (0.155s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search/filter interaction (0.856s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Results are loaded from the query params (0.29s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search works by icon click (0.576s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search works by Return key (0.561s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search from the homepage (1.922s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search with a dash works (0.516s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - After search without results, suggested label appear and have a clickable URL. (2.895s)
✓ chrome 66.0.3359.139 on Linux - Search (auth) - Search input is loaded from q param (with dashes) (0.172s)
✓ chrome 66.0.3359.139 on Linux - Search (non-auth) - Pressing g inside of search input *doesnt* go to github issues (0.448s)
✓ chrome 66.0.3359.139 on Linux - Search (non-auth) - Clicking on label search adds query parameter to the URL (0.577s)
✓ chrome 66.0.3359.139 on Linux - Search (non-auth) - Clicking on label search updates the search input (2.578s)
✓ chrome 66.0.3359.139 on Linux - Search (non-auth) - Search input is visible (0.402s)
✓ chrome 66.0.3359.139 on Linux - Search (non-auth) - Empty search input removes q param (3.431s)
✓ chrome 66.0.3359.139 on Linux - User Activity (auth) - We're at the right place (0.241s)
✓ chrome 66.0.3359.139 on Linux - User Activity (auth) - IssueListView renders (1.463s)
✓ chrome 66.0.3359.139 on Linux - User Activity (auth) - Trying to view someone else's activity fails (logged in) (0.186s)
✓ chrome 66.0.3359.139 on Linux - User Activity (non-auth) - Trying to view someone else's activity fails (logged out) (0.15s)
No unit test coverage for chrome 66.0.3359.139 on Linux
chrome 66.0.3359.139 on Linux: 81 passed, 0 failed
TOTAL: tested 2 platforms, 161 passed, 1 failed
{ Error: One or more tests failed
    at /home/travis/build/webcompat/webcompat.com/node_modules/intern/lib/executors/Executor.js:400:45
    at /home/travis/build/webcompat/webcompat.com/node_modules/@dojo/core/async/Task.js:252:28
    at handler (/home/travis/build/webcompat/webcompat.com/node_modules/@dojo/core/async/ExtensiblePromise.js:146:37)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) reported: true }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webcompat@ test:js: `node ./tests/functional/_intern.js "--reporters=runner" "--firefoxBinary=/home/travis/firefox-58.0/firefox/firefox"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the webcompat@ test:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2018-04-30T21_07_23_402Z-debug.log

@miketaylr

This comment has been minimized.

@miketaylr
Copy link
Member Author

Interesting that the comments tests are being flaky.

@miketaylr

This comment has been minimized.

@miketaylr miketaylr force-pushed the issues/2288/1 branch 3 times, most recently from 52fe532 to 2a8758f Compare April 27, 2018 15:25
@miketaylr
Copy link
Member Author

lol
screen shot 2018-04-27 at 12 48 24 pm

@miketaylr miketaylr changed the title Issue #2288 [not ready for review] Fixes #2288: Refactor how we do form submission Apr 27, 2018
@miketaylr
Copy link
Member Author

OK! Tests are green. Annoying it took so much fiddling to get things to pass on Travis, while they pass locally.

Anyways,

this patch-set does the following things:

  1. Upgrade jQuery and Backbone to latest versions
  2. Refactor bugform.js image upload and form submission flow to be Deferred-based (jQuery's implementation of Promises)
  3. Fixes the bugs where if the server sent back a 4XX error, you were stuck
  4. Adds the notion of @mockable_report so we can mock out bug creation
  5. Adds functional tests for bug creation, with and without screenshots

@miketaylr miketaylr requested review from karlcow and Regaddi April 27, 2018 18:05
@miketaylr
Copy link
Member Author

r? @karlcow for Python bits
r? @Regaddi for JS bits

},
capabilities: {
"moz:firefoxOptions": {
args: ["-headless"],

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Member

@Regaddi Regaddi left a comment

Choose a reason for hiding this comment

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

Will test locally later.

.sleep(5000)
.execute(() => {
return document.querySelector("textarea").value;
})

This comment was marked as abuse.

formEl.appendChild(hiddenEl);
formEl.submit();
dfd.resolve();
return dfd.promise();

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Member

@karlcow karlcow left a comment

Choose a reason for hiding this comment

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

@miketaylr a lot of work in there. Thanks for working on this.

.gitignore Outdated
@@ -17,6 +17,7 @@ tmp/

# The data folder contains information that shouldn't live in version control.
data/*
tests/fixtures/api/issues/0.json

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

.gitignore Outdated
@@ -26,6 +27,7 @@ webcompat/static/js/build/
webcompat/static/js/dist/
webcompat/**/*.min.css
webcompat/static/css/dist/
!webcompat/**/vendor/*.min.js

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

@@ -382,7 +383,7 @@ def mockable_response(func):
"""Mock out API reponses with a decorator.

This allows us to send back fixture files when in TESTING mode, rather
than making API requests over the network. See /api/endponts.py
than making API requests over the network. See /api/endpoints.py

This comment was marked as abuse.


Note: unless you've created 0.json locally by running tests, navigating
there directly will 404. We don't check it into source control because
it can change depending on the test. But only tests should care abou this.

This comment was marked as abuse.


This allows us to test form submission, always returning a special
issue 0 (that doesn't exist). It loads fixture data from a "zero.json"
template, and merges in the reported title and body, saving it to "0.json".

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

class Mocked201Response:
"""Class to mock out the requests Reponse object that is created
when a new issue is created (or something close enough.
"""

This comment was marked as abuse.

there directly will 404. We don't check it into source control because
it can change depending on the test. But only tests should care abou this.
"""
class Mocked201Response:

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

Now we use jQuery Deferreds (Promises/A+ compatible) to handle
success and error conditions. If an image passes validation on the server,
the issue will be sumitted. If there's a problem, it won't be submitted
and the user will have to upload a new image and try again.
@miketaylr
Copy link
Member Author

OK, I made the easy changes. Will look at sinonjs for xhr mocking now.

@miketaylr miketaylr force-pushed the issues/2288/1 branch 2 times, most recently from 4ce1e11 to 90ecdef Compare April 30, 2018 20:21
@miketaylr
Copy link
Member Author

@karlcow I think we have 2 choices here: land as-is and file a follow up bug to find a better solution for serving fixture data from the server when in TESTING mode.

Or, remove the @mockable_report stuff (and the issue creation tests), and just land the refactored JS stuff. And then file a follow up bug to find a better solution for serving fixture data from the server when in TESTING mode. 😄

I'm happy either way, I defer to what you think is better, thanks.

@miketaylr
Copy link
Member Author

Um, except now all those tests are failing in Chrome. I think I'm just going to rip it out and file a follow up.

@miketaylr
Copy link
Member Author

This × firefox on linux 4.4.0-101-generic - Comments (auth) - Add a screenshot to a comment (5.67s) test is making me sad. I'm going to remove it and see what can be added in test_uploads.py.

@karlcow
Copy link
Member

karlcow commented Apr 30, 2018

🤗 for all the code. And courage as we say in French.

@miketaylr
Copy link
Member Author

r? @karlcow for aae62e6

@karlcow
Copy link
Member

karlcow commented May 1, 2018

@miketaylr so I was a bit surprised by the check_rv_format(self, rv), but I guess you did it for the purpose of being DRY. Maybe it's not the right way to do it, but this is working.

So +1

@miketaylr
Copy link
Member Author

@miketaylr so I was a bit surprised by the check_rv_format(self, rv), but I guess you did it for the purpose of being DRY. Maybe it's not the right way to do it, but this is working.

Yeah, feel free to make it more pythonic next time you touch the file :P

I'll change the formatting issues then merge, thanks!

@miketaylr miketaylr merged commit 475c5ab into master May 1, 2018
@miketaylr miketaylr deleted the issues/2288/1 branch May 1, 2018 15:21
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.

4 participants