Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Loading of specs with % in the filename #18877

Merged
merged 4 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
})
})
})