Skip to content

Commit 8162687

Browse files
author
Blue F
authored
fix: Loading of specs with % in the filename (#18877)
1 parent 3817e50 commit 8162687

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed

packages/driver/cypress/integration/e2e/rerun_spec.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44

55
// store these on our outer top window
66
// so they are globally preserved
7-
if (window.top.hasRunOnce == null) {
8-
window.top.hasRunOnce = false
9-
}
10-
11-
if (window.top.previousHash == null) {
12-
window.top.previousHash = window.top.location.hash
7+
if (window.top.runCount == null) {
8+
window.top.runCount = 0
139
}
1410

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

27-
// 1st time around
28-
window.top.hasRunOnce = true
29-
30-
// cause a rerun event to occur
31-
// by changing the hash
32-
let { hash } = window.top.location
33-
34-
window.top.location.hash = `${hash}?rerun`
24+
// cause a rerun event to occur by triggering a hash change
25+
window.top.dispatchEvent(new Event('hashchange'))
26+
} else if (window.top.runCount === 2) {
27+
// Second time, do nothing, with mocha events still disabled
3528
} else {
36-
if (window.top.location.hash === window.top.previousHash) {
37-
// 3rd time around
38-
// let the mocha end events fire if they're supposed to
39-
Cypress.config('isTextTerminal', isTextTerminal)
40-
}
41-
42-
window.top.location.hash = window.top.previousHash
29+
// 3rd time around
30+
// let the mocha end events fire if they're supposed to
31+
Cypress.config('isTextTerminal', isTextTerminal)
4332
}
4433
})
4534
})

packages/runner-shared/src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export abstract class BaseStore {
4242
}
4343

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

4747
if (foundSpec) {
4848
this.spec = foundSpec

packages/runner/src/iframe/iframes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export default class Iframes extends Component {
151151
// jQuery is a better fit for managing these iframes, since they need to get
152152
// wiped out and reset on re-runs and the snapshots are from dom we don't control
153153
_loadIframes (specPath) {
154-
const specSrc = `/${this.props.config.namespace}/iframes/${specPath}`
154+
const specSrc = `/${this.props.config.namespace}/iframes/${encodeURIComponent(specPath)}`
155155
const $container = $(this.refs.container).empty()
156156
const $autIframe = this.autIframe.create(this.props.config).appendTo($container)
157157

packages/server/lib/routes-e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const createRoutesE2E = ({
2323
// this could be just a regular .js file or a .coffee file
2424
routesE2E.get('/__cypress/tests', (req, res, next) => {
2525
// slice out the cache buster
26-
const test = CacheBuster.strip(req.query.p)
26+
const test = decodeURIComponent(CacheBuster.strip(req.query.p))
2727

2828
specController.handle(test, req, res, config, next, onError)
2929
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it('passes', () => {
2+
expect(1).to.equal(1)
3+
})

system-tests/test/specs_spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,14 @@ describe('e2e specs', () => {
4040
expectedExitCode: 0,
4141
})
4242
})
43+
44+
it('handles specs with special characters in the file name', function () {
45+
const project = Fixtures.projectPath('spec-name-special-characters')
46+
47+
return systemTests.exec(this, {
48+
project,
49+
snapshot: false,
50+
expectedExitCode: 0,
51+
})
52+
})
4353
})

0 commit comments

Comments
 (0)