Skip to content

Commit

Permalink
fix: support launching electron browser from launchpad (#19781)
Browse files Browse the repository at this point in the history
* do not require path when launching browser

* fix type

* updated test

Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Zachary Williams <ZachJW34@gmail.com>
  • Loading branch information
3 people authored Jan 24, 2022
1 parent b5cafec commit 096c4eb
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/data-context/src/actions/ProjectActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class ProjectActions {
throw Error(`Cannot save preferences without currentProject.`)
}

this.api.insertProjectPreferencesToCache(this.ctx.lifecycleManager.projectTitle, { ...args })
this.api.insertProjectPreferencesToCache(this.ctx.lifecycleManager.projectTitle, args)
}

async codeGenSpec (codeGenCandidate: string, codeGenType: CodeGenType): Promise<NexusGenObjects['ScaffoldedFile']> {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ type Mutation {
setProjectIdInConfigFile(projectId: String!): Query

"""Save the projects preferences to cache"""
setProjectPreferences(browserPath: String!, testingType: TestingTypeEnum!): Query!
setProjectPreferences(testingType: TestingTypeEnum!): Query!

"""Save the prompt-shown state for this project"""
setPromptShown(slug: String!): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ export const mutation = mutationType({
description: 'Save the projects preferences to cache',
args: {
testingType: nonNull(TestingTypeEnum),
browserPath: nonNull(stringArg()),
},
async resolve (_, args, ctx) {
await ctx.actions.project.setProjectPreferences(args)
Expand Down
1 change: 0 additions & 1 deletion packages/launchpad/cypress/e2e/choose-a-browser.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ describe('Choose a Browser Page', () => {
cy.get('@launchButton').click()

cy.wait('@launchProject').then(({ request }) => {
expect(request?.body.variables.browserPath).to.contain('/test/chrome/path')
expect(request?.body.variables.testingType).to.eq('e2e')
})
})
Expand Down
9 changes: 4 additions & 5 deletions packages/launchpad/src/setup/OpenBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ mutation OpenBrowser_ClearTestingType {
`
gql`
mutation OpenBrowser_LaunchProject ($testingType: TestingTypeEnum!, $browserPath: String!) {
mutation OpenBrowser_LaunchProject ($testingType: TestingTypeEnum!) {
launchOpenProject {
id
}
# Removing for now until we decide what the behavior should be
# hideBrowserWindow
setProjectPreferences(testingType: $testingType, browserPath: $browserPath) {
setProjectPreferences(testingType: $testingType) {
currentProject {
id
title
Expand All @@ -73,12 +73,11 @@ mutation OpenBrowser_LaunchProject ($testingType: TestingTypeEnum!, $browserPath
const launchOpenProject = useMutation(OpenBrowser_LaunchProjectDocument)
const clearCurrentTestingType = useMutation(OpenBrowser_ClearTestingTypeDocument)
const launch = (browserPath?: string) => {
const launch = () => {
const testingType = query.data.value?.currentTestingType
if (browserPath && testingType) {
if (testingType) {
launchOpenProject.executeMutation({
browserPath,
testingType,
})
}
Expand Down
4 changes: 2 additions & 2 deletions packages/launchpad/src/setup/OpenBrowserList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<form
v-if="browsers"
@submit.prevent="emit('launch', props.gql?.currentBrowser?.path)"
@submit.prevent="emit('launch')"
>
<div
class="flex flex-wrap py-40px gap-24px justify-center"
Expand Down Expand Up @@ -130,7 +130,7 @@ const props = defineProps<{
const emit = defineEmits<{
(e: 'navigated-back'): void
(e: 'launch', value: string | undefined): void
(e: 'launch'): void
}>()
const { t } = useI18n()
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface Cache {
}

export interface Preferences {
browserPath: string | null
testingType: 'e2e' | 'component' | null
}

Expand Down

1 comment on commit 096c4eb

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 096c4eb Jan 24, 2022

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.0.0/circle-10.0-release-096c4eb880205536623eb82c182e1e7a91e2643c/cypress.tgz

Please sign in to comment.