Skip to content

Commit

Permalink
Merge branch 'develop' into issue-29034
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed May 7, 2024
2 parents 4b76635 + b31740c commit 85ff34a
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 9 deletions.
1 change: 0 additions & 1 deletion .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,6 @@ jobs:

check-ts:
<<: *defaults
resource_class: small
steps:
- restore_cached_workspace
- install-required-node
Expand Down
3 changes: 2 additions & 1 deletion cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.9.0

_Released 5/7/2024 (PENDING)_
_Released 5/7/2024_

**Features:**

Expand All @@ -12,6 +12,7 @@ _Released 5/7/2024 (PENDING)_
- Fixed an issue where Cypress was unable to search for files using digits. Fixes [#29034](https://github.com/cypress-io/cypress/issues/29034).
- Fixed a bug where promises rejected with `undefined` were failing inside `cy.origin()`. Addresses [#23937](https://github.com/cypress-io/cypress/issues/23937).
- We now pass the same default Chromium flags to Electron as we do to Chrome. As a result of this change, the application under test's `navigator.webdriver` property will now correctly be `true` when testing in Electron. Fixes [#27939](https://github.com/cypress-io/cypress/issues/27939).
- Fixed network issues in requests using fetch for users where Cypress is run behind a proxy that performs HTTPS decryption (common among corporate proxies). Fixes [#29171](https://github.com/cypress-io/cypress/issues/29171).
- Fixed an issue where extra windows weren't being closed between specs in Firefox causing potential issues in subsequent specs. Fixes [#29473](https://github.com/cypress-io/cypress/issues/29473).

**Misc:**
Expand Down
4 changes: 0 additions & 4 deletions cli/test/lib/tasks/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,6 @@ describe('lib/tasks/download', function () {
})

context('architecture detection', () => {
beforeEach(() => {
sinon.stub(os, 'arch')
})

context('Apple Silicon/M1', () => {
function nockDarwinArm64 () {
return nock('https://download.cypress.io')
Expand Down
3 changes: 3 additions & 0 deletions cli/test/spec_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ sinon.stub = function (obj, method) {

beforeEach(function () {
sinon.stub(os, 'platform')
sinon.stub(os, 'arch')
sinon.stub(os, 'release')
sinon.stub(util, 'getOsVersionAsync').resolves('Foo-OsVersion')

os.arch.returns('x64')
})

afterEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress",
"version": "13.8.1",
"version": "13.9.0",
"description": "Cypress is a next generation front end testing tool built for the modern web",
"private": true,
"scripts": {
Expand Down
9 changes: 7 additions & 2 deletions packages/network/test/support/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ export interface AsyncServer {
listenAsync: (port) => Promise<void>
}

function createExpressApp () {
function createExpressApp (requestCallback: (req) => void) {
const app: express.Application = express()

app.get('/get', (req, res) => {
if (requestCallback) requestCallback(req)

res.send('It worked!')
})

app.get('/empty-response', (req, res) => {
if (requestCallback) requestCallback(req)

// ERR_EMPTY_RESPONSE in Chrome
setTimeout(() => res.connection.destroy(), 100)
})
Expand All @@ -45,10 +49,11 @@ export class Servers {
wsServer: any
wssServer: any
caCertificatePath: string
lastRequestHeaders: any

start (httpPort: number, httpsPort: number) {
return Promise.join(
createExpressApp(),
createExpressApp((req) => this.lastRequestHeaders = req.headers),
getCAInformation(),
)
.spread((app: Express.Application, [serverCertificateKeys, caCertificatePath]: [serverCertificateKeys: string[], caCertificatePath: string]) => {
Expand Down
27 changes: 27 additions & 0 deletions packages/network/test/unit/agent_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@ describe('lib/agent', function () {
})
})

it('HTTP pages are requested with correct host header when loaded via fetch', function () {
return this.fetch(`http://localhost:${HTTP_PORT}/get`)
.then(() => {
expect(this.servers.lastRequestHeaders).to.include({
host: `localhost:${HTTP_PORT}`,
})
})
})

it('HTTPS pages can be loaded', function () {
return this.request({
url: `https://localhost:${HTTPS_PORT}/get`,
Expand Down Expand Up @@ -255,6 +264,15 @@ describe('lib/agent', function () {
})
})

it('HTTPS pages are requested with correct host header when loaded via fetch', function () {
return this.fetch(`https://localhost:${HTTPS_PORT}/get`)
.then(() => {
expect(this.servers.lastRequestHeaders).to.include({
host: 'localhost',
})
})
})

it('HTTPS pages can be loaded via fetch with no explicit port', function () {
return this.fetch(`https://localhost/get`)
.then((response) => response.text())
Expand All @@ -269,6 +287,15 @@ describe('lib/agent', function () {
})
})

it('HTTPS pages requested with correct host header when loaded via fetch with no explicit port', function () {
return this.fetch(`https://localhost/get`)
.then(() => {
expect(this.servers.lastRequestHeaders).to.include({
host: 'localhost',
})
})
})

it('HTTP errors are catchable', function () {
return this.request({
url: `http://localhost:${HTTP_PORT}/empty-response`,
Expand Down
13 changes: 13 additions & 0 deletions patches/mocha-junit-reporter+2.2.0.dev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/node_modules/mocha-junit-reporter/index.js b/node_modules/mocha-junit-reporter/index.js
index fbbed2e..de27092 100644
--- a/node_modules/mocha-junit-reporter/index.js
+++ b/node_modules/mocha-junit-reporter/index.js
@@ -366,7 +366,7 @@ MochaJUnitReporter.prototype.getTestcaseData = function(test, err) {
message = '';
}
var failureMessage = err.stack || message;
- if (!Base.hideDiff && err.expected !== undefined) {
+ if (!Base.hideDiff && err.expected !== undefined && mocha6plus) {
var oldUseColors = Base.useColors;
Base.useColors = false;
failureMessage += "\n" + Base.generateDiff(err.actual, err.expected);
15 changes: 15 additions & 0 deletions patches/node-fetch+2.7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/node_modules/node-fetch/lib/index.js b/node_modules/node-fetch/lib/index.js
index 567ff5d..c7e2bd9 100644
--- a/node_modules/node-fetch/lib/index.js
+++ b/node_modules/node-fetch/lib/index.js
@@ -1449,7 +1449,9 @@ function fetch(url, opts) {
const request = new Request(url, opts);
const options = getNodeRequestOptions(request);

- const send = (options.protocol === 'https:' ? https : http).request;
+ const isHttps = options.protocol === 'https:';
+ options.defaultPort = (isHttps ? 443 : 80);
+ const send = (isHttps ? https : http).request;
const signal = request.signal;

let response = null;

0 comments on commit 85ff34a

Please sign in to comment.