mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-26 17:09:11 -06:00
fix(unify): null binary field on editor blocks launchpad from opening (#20920)
This commit is contained in:
@@ -249,6 +249,10 @@ describe('App: Settings', () => {
|
||||
binary: '/usr/bin/well-known',
|
||||
name: 'Well known editor',
|
||||
},
|
||||
{
|
||||
id: 'null-binary-editor',
|
||||
name: 'Null binary editor',
|
||||
},
|
||||
]
|
||||
|
||||
ctx.coreData.localSettings.preferences.preferredEditorBinary = undefined
|
||||
@@ -306,6 +310,23 @@ describe('App: Settings', () => {
|
||||
|
||||
cy.get('[data-cy="custom-editor"]').should('not.exist')
|
||||
})
|
||||
|
||||
it('handles null binary field in editor', () => {
|
||||
cy.contains('Choose your editor...').click()
|
||||
cy.contains('Null binary editor').click()
|
||||
cy.withRetryableCtx((ctx) => {
|
||||
expect((ctx.actions.localSettings.setPreferences as SinonStub).lastCall.lastArg).to.include('{"preferredEditorBinary":null')
|
||||
})
|
||||
|
||||
// navigate away and come back
|
||||
// preferred editor selected from dropdown should have been persisted
|
||||
cy.visitApp()
|
||||
cy.get('[href="#/settings"]').click()
|
||||
cy.wait(200)
|
||||
cy.get('[data-cy="Device Settings"]').click()
|
||||
|
||||
cy.get('[data-cy="custom-editor"]').should('not.exist')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ const { t } = useI18n()
|
||||
|
||||
const setPreferredBinaryEditor = useMutation(ExternalEditorSettings_SetPreferredEditorBinaryDocument)
|
||||
|
||||
function handleChoseEditor (binary: string) {
|
||||
function handleChoseEditor (binary: string | null) {
|
||||
setPreferredBinaryEditor.executeMutation({ value: JSON.stringify({ preferredEditorBinary: binary }) })
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ type Editor = ChooseExternalEditorFragment['localSettings']['availableEditors'][
|
||||
type EditorType = 'found' | 'custom'
|
||||
|
||||
const selectedWellKnownEditor: Editor | undefined = props.gql.localSettings.availableEditors.find((editor) => {
|
||||
return editor.binary === props.gql.localSettings.preferences.preferredEditorBinary
|
||||
return editor.binary && editor.binary === props.gql.localSettings.preferences.preferredEditorBinary
|
||||
})
|
||||
|
||||
const customBinary = ref<string>(
|
||||
@@ -144,7 +144,7 @@ const selectedEditor = ref<Editor | undefined>(
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'choseEditor', binary: string): void
|
||||
(e: 'choseEditor', binary: string | null): void
|
||||
}>()
|
||||
|
||||
watch(customBinary, (val) => {
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
>
|
||||
<ChooseExternalEditor
|
||||
:gql="props.gql"
|
||||
@chose-editor="val => preferredEditor = val"
|
||||
@chose-editor="val => preferredEditor = val ?? ''"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -467,7 +467,7 @@ type DevState {
|
||||
"""Represents an editor on the local machine"""
|
||||
type Editor {
|
||||
"""Binary that opens the editor"""
|
||||
binary: String!
|
||||
binary: String
|
||||
id: String!
|
||||
|
||||
"""name of editor"""
|
||||
|
||||
@@ -10,7 +10,7 @@ export const Editor = objectType({
|
||||
description: 'name of editor',
|
||||
})
|
||||
|
||||
t.nonNull.string('binary', {
|
||||
t.string('binary', {
|
||||
description: 'Binary that opens the editor',
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export interface Editor {
|
||||
id: string
|
||||
binary: string
|
||||
binary?: string | null | undefined
|
||||
name: string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user