mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-26 00:50:41 -05:00
fix: run-all-specs opens in new tab rather than new browser (#25074)
This commit is contained in:
@@ -147,7 +147,7 @@ describe('Cypress In Cypress CT', { viewportWidth: 1500, defaultCommandTimeout:
|
||||
expect(ctx.actions.browser.setActiveBrowserById).to.have.been.calledWith(browserId)
|
||||
expect(genId).to.eql('firefox-firefox-stable')
|
||||
expect(ctx.actions.project.launchProject).to.have.been.calledWith(
|
||||
ctx.coreData.currentTestingType, undefined, o.sinon.match(new RegExp('cypress\-in\-cypress\/src\/TestComponent\.spec\.jsx$')),
|
||||
ctx.coreData.currentTestingType, { shouldLaunchNewTab: false }, o.sinon.match(new RegExp('cypress\-in\-cypress\/src\/TestComponent\.spec\.jsx$')),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,9 +45,10 @@ describe('run-all-specs', () => {
|
||||
|
||||
cy.waitForSpecToFinish({ passCount: 2 })
|
||||
|
||||
cy.withCtx((ctx, { specs }) => {
|
||||
cy.withCtx((ctx, { specs, RUN_ALL_SPECS_KEY }) => {
|
||||
expect(ctx.actions.project.launchProject).to.have.been.calledWith('e2e', { shouldLaunchNewTab: true }, RUN_ALL_SPECS_KEY)
|
||||
expect(ctx.project.runAllSpecs).to.include.members(specs.map((spec) => spec.relative))
|
||||
}, { specs: subDirectorySpecs })
|
||||
}, { specs: subDirectorySpecs, RUN_ALL_SPECS_KEY })
|
||||
|
||||
for (const spec of subDirectorySpecs) {
|
||||
cy.get('.runnable-title').contains(spec.name)
|
||||
@@ -100,10 +101,9 @@ describe('run-all-specs', () => {
|
||||
|
||||
clickRunAllSpecs('all')
|
||||
|
||||
cy.withCtx((ctx, { specs, runAllSpecsKey }) => {
|
||||
expect(ctx.actions.project.launchProject).to.have.been.calledWith('e2e', undefined, runAllSpecsKey)
|
||||
cy.withCtx((ctx, { specs }) => {
|
||||
expect(ctx.project.runAllSpecs).to.include.members(specs.map((spec) => spec.relative))
|
||||
}, { specs: Object.values(ALL_SPECS), runAllSpecsKey: RUN_ALL_SPECS_KEY })
|
||||
}, { specs: Object.values(ALL_SPECS) })
|
||||
|
||||
cy.waitForSpecToFinish({ passCount: 6 })
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('App Top Nav Workflows', () => {
|
||||
expect(ctx.actions.browser.setActiveBrowserById).to.have.been.calledWith(browserId)
|
||||
expect(genId).to.eql('edge-chromium-stable')
|
||||
expect(ctx.actions.project.launchProject).to.have.been.calledWith(
|
||||
ctx.coreData.currentTestingType, undefined, undefined,
|
||||
ctx.coreData.currentTestingType, { shouldLaunchNewTab: false }, undefined,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -22,7 +22,7 @@ query RunAllSpecsData {
|
||||
gql`
|
||||
mutation RunAllSpecs ($specPath: String!, $runAllSpecs: [String!]!) {
|
||||
setRunAllSpecs(runAllSpecs: $runAllSpecs)
|
||||
launchOpenProject(specPath: $specPath) {
|
||||
launchOpenProject(specPath: $specPath, shouldLaunchNewTab: true) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface ProjectApiShape {
|
||||
* order for CT to startup
|
||||
*/
|
||||
openProjectCreate(args: InitializeProjectOptions, options: OpenProjectLaunchOptions): Promise<unknown>
|
||||
launchProject(browser: FoundBrowser, spec: Cypress.Spec, options?: OpenProjectLaunchOpts): Promise<void>
|
||||
launchProject(browser: FoundBrowser, spec: Cypress.Spec, options?: Partial<OpenProjectLaunchOpts>): Promise<void>
|
||||
insertProjectToCache(projectRoot: string): Promise<void>
|
||||
removeProjectFromCache(projectRoot: string): Promise<void>
|
||||
getProjectRootsFromCache(): Promise<ProjectShape[]>
|
||||
@@ -46,6 +46,8 @@ export interface ProjectApiShape {
|
||||
emitter: EventEmitter
|
||||
}
|
||||
isListening: (url: string) => Promise<void>
|
||||
resetBrowserTabsForNextTest(shouldKeepTabOpen: boolean): Promise<void>
|
||||
resetServer(): void
|
||||
}
|
||||
|
||||
export interface FindSpecs<T> {
|
||||
@@ -228,7 +230,7 @@ export class ProjectActions {
|
||||
}
|
||||
}
|
||||
|
||||
async launchProject (testingType: Cypress.TestingType | null, options?: OpenProjectLaunchOpts, specPath?: string | null) {
|
||||
async launchProject (testingType: Cypress.TestingType | null, options?: Partial<OpenProjectLaunchOpts>, specPath?: string | null) {
|
||||
if (!this.ctx.currentProject) {
|
||||
return null
|
||||
}
|
||||
@@ -261,6 +263,12 @@ export class ProjectActions {
|
||||
specType: testingType === 'e2e' ? 'integration' : 'component',
|
||||
}
|
||||
|
||||
// Used for run-all-specs feature
|
||||
if (options?.shouldLaunchNewTab) {
|
||||
await this.api.resetBrowserTabsForNextTest(true)
|
||||
this.api.resetServer()
|
||||
}
|
||||
|
||||
await this.api.launchProject(browser, activeSpec ?? emptySpec, options)
|
||||
|
||||
return
|
||||
|
||||
@@ -1255,7 +1255,7 @@ type Mutation {
|
||||
internal_clearProjectPreferencesCache(projectTitle: String!): Boolean
|
||||
|
||||
"""Launches project from open_project global singleton"""
|
||||
launchOpenProject(specPath: String): CurrentProject
|
||||
launchOpenProject(shouldLaunchNewTab: Boolean, specPath: String): CurrentProject
|
||||
|
||||
"""Sets the active browser"""
|
||||
launchpadSetBrowser(
|
||||
|
||||
@@ -294,10 +294,11 @@ export const mutation = mutationType({
|
||||
type: CurrentProject,
|
||||
description: 'Launches project from open_project global singleton',
|
||||
args: {
|
||||
shouldLaunchNewTab: booleanArg(),
|
||||
specPath: stringArg(),
|
||||
},
|
||||
resolve: async (_, args, ctx) => {
|
||||
await ctx.actions.project.launchProject(ctx.coreData.currentTestingType, undefined, args.specPath)
|
||||
await ctx.actions.project.launchProject(ctx.coreData.currentTestingType, { shouldLaunchNewTab: args.shouldLaunchNewTab ?? false }, args.specPath)
|
||||
|
||||
return ctx.lifecycleManager
|
||||
},
|
||||
|
||||
@@ -155,6 +155,12 @@ export function makeDataContext (options: MakeDataContextOptions): DataContext {
|
||||
return devServer
|
||||
},
|
||||
isListening,
|
||||
resetBrowserTabsForNextTest (shouldKeepTabOpen: boolean) {
|
||||
return openProject.resetBrowserTabsForNextTest(shouldKeepTabOpen)
|
||||
},
|
||||
resetServer () {
|
||||
return openProject.getProject()?.server.reset()
|
||||
},
|
||||
},
|
||||
electronApi: {
|
||||
openExternal (url: string) {
|
||||
|
||||
Reference in New Issue
Block a user