Skip to content

Commit 116fe64

Browse files
lmiller1990elevatebartBarthélémy Ledoux
authored
fix: encodeURI to correctly load specs with white space (#16416)
* fix: encodeURI to correctly load specs with white space * fix the tests * allow refresh page when spaes are in the path Co-authored-by: ElevateBart <[email protected]> Co-authored-by: Barthélémy Ledoux <[email protected]>
1 parent 30d781f commit 116fe64

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

npm/webpack-dev-server/src/loader.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const makeImport = (file: Cypress.Cypress['spec'], filename: string, chunkName:
1717
const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : ''
1818

1919
return `"${filename}": {
20-
shouldLoad: () => document.location.pathname.includes("${file.absolute}"),
20+
shouldLoad: () => document.location.pathname.includes("${encodeURI(file.absolute)}"),
2121
load: () => import("${file.absolute}" ${magicComments}),
2222
chunkName: "${chunkName}",
2323
}`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react'
2+
import { mount } from '@cypress/react'
3+
import RunnerCt from '../../src/app/RunnerCt'
4+
import '@packages/runner/src/main.scss'
5+
import { makeState, fakeConfig, FakeEventManager } from './utils'
6+
7+
describe('Spec File with Whitespace', () => {
8+
it('renders RunnerCt', () => {
9+
mount(
10+
<RunnerCt
11+
state={makeState()}
12+
// @ts-ignore - this is difficult to stub. Real one breaks things.
13+
eventManager={new FakeEventManager()}
14+
config={fakeConfig}
15+
/>,
16+
)
17+
18+
// ensures that the spec was executed
19+
cy.get('h2').contains('No spec selected.')
20+
})
21+
})

packages/runner-ct/cypress/component/utils.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ export const getPort = (href: string) => {
1616

1717
return port
1818
}
19+
20+
export class FakeEventManager {
21+
on (evt: string) {}
22+
}

packages/runner-ct/src/lib/state.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export default class State {
293293
}
294294

295295
@action updateSpecByUrl (specUrl) {
296-
const foundSpec = _.find(this.specs, { name: specUrl })
296+
const foundSpec = _.find(this.specs, { name: decodeURI(specUrl) })
297297

298298
if (foundSpec) {
299299
this.spec = foundSpec

0 commit comments

Comments
 (0)