Skip to content

Commit

Permalink
fix: Loading of specs with % in the filename (#18877)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blue F committed Nov 17, 2021
1 parent 3817e50 commit 8162687
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 25 deletions.
33 changes: 11 additions & 22 deletions packages/driver/cypress/integration/e2e/rerun_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@

// store these on our outer top window
// so they are globally preserved
if (window.top.hasRunOnce == null) {
window.top.hasRunOnce = false
}

if (window.top.previousHash == null) {
window.top.previousHash = window.top.location.hash
if (window.top.runCount == null) {
window.top.runCount = 0
}

const isTextTerminal = Cypress.config('isTextTerminal')
Expand All @@ -20,26 +16,19 @@ describe('rerun state bugs', () => {
// but we get the hashchange coverage for free on this.
it('stores viewport globally and does not hang on re-runs', () => {
cy.viewport(500, 500).then(() => {
if (!window.top.hasRunOnce) {
window.top.runCount++
if (window.top.runCount === 1) {
// turn off mocha events for a second
Cypress.config('isTextTerminal', false)

// 1st time around
window.top.hasRunOnce = true

// cause a rerun event to occur
// by changing the hash
let { hash } = window.top.location

window.top.location.hash = `${hash}?rerun`
// cause a rerun event to occur by triggering a hash change
window.top.dispatchEvent(new Event('hashchange'))
} else if (window.top.runCount === 2) {
// Second time, do nothing, with mocha events still disabled
} else {
if (window.top.location.hash === window.top.previousHash) {
// 3rd time around
// let the mocha end events fire if they're supposed to
Cypress.config('isTextTerminal', isTextTerminal)
}

window.top.location.hash = window.top.previousHash
// 3rd time around
// let the mocha end events fire if they're supposed to
Cypress.config('isTextTerminal', isTextTerminal)
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/runner-shared/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export abstract class BaseStore {
}

@action updateSpecByUrl (specUrl: string) {
const foundSpec = this.specs.find((x) => x.name === decodeURI(specUrl))
const foundSpec = this.specs.find((x) => x.name === specUrl)

if (foundSpec) {
this.spec = foundSpec
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/iframe/iframes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class Iframes extends Component {
// jQuery is a better fit for managing these iframes, since they need to get
// wiped out and reset on re-runs and the snapshots are from dom we don't control
_loadIframes (specPath) {
const specSrc = `/${this.props.config.namespace}/iframes/${specPath}`
const specSrc = `/${this.props.config.namespace}/iframes/${encodeURIComponent(specPath)}`
const $container = $(this.refs.container).empty()
const $autIframe = this.autIframe.create(this.props.config).appendTo($container)

Expand Down
2 changes: 1 addition & 1 deletion packages/server/lib/routes-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createRoutesE2E = ({
// this could be just a regular .js file or a .coffee file
routesE2E.get('/__cypress/tests', (req, res, next) => {
// slice out the cache buster
const test = CacheBuster.strip(req.query.p)
const test = decodeURIComponent(CacheBuster.strip(req.query.p))

specController.handle(test, req, res, config, next, onError)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it('passes', () => {
expect(1).to.equal(1)
})
10 changes: 10 additions & 0 deletions system-tests/test/specs_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ describe('e2e specs', () => {
expectedExitCode: 0,
})
})

it('handles specs with special characters in the file name', function () {
const project = Fixtures.projectPath('spec-name-special-characters')

return systemTests.exec(this, {
project,
snapshot: false,
expectedExitCode: 0,
})
})
})

3 comments on commit 8162687

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8162687 Nov 17, 2021

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/circle-develop-81626870bf1c2860f707e54989675314cc416ba0/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8162687 Nov 17, 2021

Choose a reason for hiding this comment

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

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/appveyor-develop-81626870bf1c2860f707e54989675314cc416ba0/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 8162687 Nov 17, 2021

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.0.1/circle-develop-81626870bf1c2860f707e54989675314cc416ba0/cypress.tgz

Please sign in to comment.