Skip to content

feat(app): remove __vite__ route and default to unified runner #18909

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

Merged
merged 5 commits into from
Nov 15, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/app/cypress/e2e/integration/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ describe('Navigation', () => {
cy.wait('@OpenExternal').then((interception: Interception) => {
expect(interception.request.body.variables.url).to.equal('https://on.cypress.io/writing-first-test?utm_medium=Docs+Menu&utm_content=First+Test')
})

cy.get('[href="#/runs"]').click()
cy.contains(defaultMessages.runs.connect.title).should('be.visible')
})
})
2 changes: 1 addition & 1 deletion packages/data-context/src/sources/HtmlDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class HtmlDataSource {
return html
}

return this.ctx.fs.readFile(getPathToDist('app'), 'utf8')
return this.ctx.fs.readFile(getPathToDist('app', 'index.html'), 'utf8')
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/driver/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { defineConfig } from 'cypress'

export default defineConfig({
'projectId': 'ypt4pf',
'baseUrl': 'http://localhost:3500',
'e2e': {
'baseUrl': 'http://localhost:3500',
},
'testFiles': '**/*',
'hosts': {
'*.foobar.com': '127.0.0.1',
Expand Down
4 changes: 4 additions & 0 deletions packages/server/lib/project_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const multipleForwardSlashesRe = /[^:\/\/](\/{2,})/g
const backSlashesRe = /\\/g

const normalizeSpecUrl = (browserUrl: string, specUrl: string) => {
if (process.env.LAUNCHPAD) {
return browserUrl
}

const replacer = (match: string) => match.replace('//', '/')

return [
Expand Down
39 changes: 26 additions & 13 deletions packages/server/lib/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ export const createCommonRoutes = ({
target: `http://localhost:${process.env.CYPRESS_INTERNAL_VITE_APP_PORT}/`,
})

router.get('/__vite__/', (req, res) => {
ctx.html.appHtml().then((html) => res.send(html)).catch((e) => res.status(500).send({ stack: e.stack }))
})

// TODO: can namespace this onto a "unified" route like __app-unified__
// make sure to update the generated routes inside of vite.config.ts
router.get('/__vite__/*', (req, res) => {
Expand Down Expand Up @@ -146,15 +142,32 @@ export const createCommonRoutes = ({
router.get(clientRoute, (req, res) => {
debug('Serving Cypress front-end by requested URL:', req.url)

runner.serve(req, res, testingType === 'e2e' ? 'runner' : 'runner-ct', {
config,
testingType,
getSpec,
getCurrentBrowser,
getRemoteState,
specsStore,
exit,
})
if (process.env.LAUNCHPAD) {
ctx.html.appHtml()
.then((html) => res.send(html))
.catch((e) => res.status(500).send({ stack: e.stack }))
} else {
runner.serve(req, res, testingType === 'e2e' ? 'runner' : 'runner-ct', {
config,
testingType,
getSpec,
getCurrentBrowser,
getRemoteState,
specsStore,
exit,
})
}
})

// serve static assets from the dist'd Vite app
router.get([
`${clientRoute}assets/*`,
`${clientRoute}shiki/*`,
], (req, res) => {
debug('proxying static assets %s, params[0] %s', req.url, req.params[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this

const pathToFile = getPathToDist('app', 'assets', req.params[0])

return send(req, pathToFile).pipe(res)
})

router.all('*', (req, res) => {
Expand Down