From be3e9ed1dcd2b638e851165e5c741d153118a6d8 Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Sat, 18 May 2019 15:12:31 -0400 Subject: [PATCH] add multipart/form-data test --- .../4_form_submissions_spec.coffee.js | 123 ++++++++++++++++++ .../test/e2e/4_form_submissions_spec.coffee | 20 ++- .../integration/form_submission_spec.coffee | 10 ++ 3 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 packages/server/__snapshots__/4_form_submissions_spec.coffee.js diff --git a/packages/server/__snapshots__/4_form_submissions_spec.coffee.js b/packages/server/__snapshots__/4_form_submissions_spec.coffee.js new file mode 100644 index 000000000000..6f94edb6be21 --- /dev/null +++ b/packages/server/__snapshots__/4_form_submissions_spec.coffee.js @@ -0,0 +1,123 @@ +exports['e2e
submissions passes with http on localhost 1'] = ` + +==================================================================================================== + + (Run Starting) + + ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ Cypress: 1.2.3 │ + │ Browser: FooBrowser 88 │ + │ Specs: 1 found (form_submission_spec.coffee) │ + │ Searched: cypress/integration/form_submission_spec.coffee │ + └────────────────────────────────────────────────────────────────────────────────────────────────┘ + + +──────────────────────────────────────────────────────────────────────────────────────────────────── + + Running: form_submission_spec.coffee... (1 of 1) + + + submissions + ✓ can submit a form correctly + ✓ can submit a multipart/form-data form correctly + + + 2 passing + + + (Results) + + ┌───────────────────────────────────────────┐ + │ Tests: 2 │ + │ Passing: 2 │ + │ Failing: 0 │ + │ Pending: 0 │ + │ Skipped: 0 │ + │ Screenshots: 0 │ + │ Video: true │ + │ Duration: X seconds │ + │ Spec Ran: form_submission_spec.coffee │ + └───────────────────────────────────────────┘ + + + (Video) + + - Started processing: Compressing to 32 CRF + - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + + +==================================================================================================== + + (Run Finished) + + + Spec Tests Passing Failing Pending Skipped + ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ ✔ form_submission_spec.coffee XX:XX 2 2 - - - │ + └────────────────────────────────────────────────────────────────────────────────────────────────┘ + All specs passed! XX:XX 2 2 - - - + + +` + +exports['e2e submissions passes with https on localhost 1'] = ` + +==================================================================================================== + + (Run Starting) + + ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ Cypress: 1.2.3 │ + │ Browser: FooBrowser 88 │ + │ Specs: 1 found (form_submission_spec.coffee) │ + │ Searched: cypress/integration/form_submission_spec.coffee │ + └────────────────────────────────────────────────────────────────────────────────────────────────┘ + + +──────────────────────────────────────────────────────────────────────────────────────────────────── + + Running: form_submission_spec.coffee... (1 of 1) + + + submissions + ✓ can submit a form correctly + ✓ can submit a multipart/form-data form correctly + + + 2 passing + + + (Results) + + ┌───────────────────────────────────────────┐ + │ Tests: 2 │ + │ Passing: 2 │ + │ Failing: 0 │ + │ Pending: 0 │ + │ Skipped: 0 │ + │ Screenshots: 0 │ + │ Video: true │ + │ Duration: X seconds │ + │ Spec Ran: form_submission_spec.coffee │ + └───────────────────────────────────────────┘ + + + (Video) + + - Started processing: Compressing to 32 CRF + - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + + +==================================================================================================== + + (Run Finished) + + + Spec Tests Passing Failing Pending Skipped + ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ + │ ✔ form_submission_spec.coffee XX:XX 2 2 - - - │ + └────────────────────────────────────────────────────────────────────────────────────────────────┘ + All specs passed! XX:XX 2 2 - - - + + +` diff --git a/packages/server/test/e2e/4_form_submissions_spec.coffee b/packages/server/test/e2e/4_form_submissions_spec.coffee index 6050ee8d5b5a..036fa7e3f8ad 100644 --- a/packages/server/test/e2e/4_form_submissions_spec.coffee +++ b/packages/server/test/e2e/4_form_submissions_spec.coffee @@ -1,21 +1,31 @@ bodyParser = require("body-parser") e2e = require("../support/helpers/e2e") -HTTPS_PORT = 11112 -HTTP_PORT = 11113 +HTTPS_PORT = 11443 +HTTP_PORT = 11180 + +getFormHtml = (formAttrs) => + "
" onServer = (app) => - app.use(bodyParser.urlencoded()) + app.use(bodyParser.text({ + type: '*/*' ## parse any content-type + })) app.get "/", (req, res) => res .type('html') - .send('
') + .send(getFormHtml()) + + app.get "/multipart-form-data", (req, res) => + res + .type('html') + .send(getFormHtml('enctype="multipart/form-data"')) app.post "/dump-body", (req, res) => res .type('html') - .send(JSON.stringify(req.body)) + .send(req.body) describe "e2e
submissions", -> e2e.setup({ diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/form_submission_spec.coffee b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/form_submission_spec.coffee index 141233f82db2..dcedd09011c1 100644 --- a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/form_submission_spec.coffee +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/form_submission_spec.coffee @@ -7,4 +7,14 @@ describe " submissions", => .get("input[type=submit]") .click() .document() + .contains('hello+world') + + it "can submit a multipart/form-data form correctly", => + cy + .visit("/multipart-form-data") + .get("input[type=text]") + .type("hello world") + .get("input[type=submit]") + .click() + .document() .contains('hello world')