From 9d3196334b217381cd3350fe865c518a614e7993 Mon Sep 17 00:00:00 2001 From: grnd-alt Date: Mon, 8 Jul 2024 11:09:08 +0200 Subject: [PATCH] feat: export skipped when file conflict is skipped Signed-off-by: grnd-alt --- cypress/components/ConflictPicker.cy.ts | 10 +++------- lib/components/ConflictPicker.vue | 6 ++---- lib/index.ts | 8 ++++++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cypress/components/ConflictPicker.cy.ts b/cypress/components/ConflictPicker.cy.ts index ef970a82..53417bf1 100644 --- a/cypress/components/ConflictPicker.cy.ts +++ b/cypress/components/ConflictPicker.cy.ts @@ -262,7 +262,7 @@ describe('ConflictPicker resolving', () => { mtime: new Date('2021-01-01T00:00:00.000Z'), }) - const onSubmit = cy.spy().as('onSubmitSpy') + const onSkip = cy.spy().as('onSkipSpy') const onCancel = cy.spy().as('onCancelSpy') cy.mount(ConflictPicker, { propsData: { @@ -271,7 +271,7 @@ describe('ConflictPicker resolving', () => { conflicts: images, }, listeners: { - submit: onSubmit, + skip: onSkip, cancel: onCancel, }, }) @@ -280,11 +280,7 @@ describe('ConflictPicker resolving', () => { cy.get('[data-cy-conflict-picker-fieldset]').should('have.length', 3) cy.get('[data-cy-conflict-picker-skip]').click() - cy.get('@onSubmitSpy').should('have.been.calledOnce').then((onSubmit) => { - const results = (onSubmit as unknown as sinon.SinonSpy).firstCall.args[0] - expect(results.selected).to.have.length(0) - expect(results.renamed).to.have.length(0) - }) + cy.get('@onSkipSpy').should('have.been.calledOnce') cy.get('@onCancelSpy').should('not.have.been.called') }) }) diff --git a/lib/components/ConflictPicker.vue b/lib/components/ConflictPicker.vue index 226b49ee..ae3f5271 100644 --- a/lib/components/ConflictPicker.vue +++ b/lib/components/ConflictPicker.vue @@ -286,10 +286,7 @@ export default defineComponent({ onSkip() { logger.debug('Conflict skipped. Ignoring all conflicting files') this.opened = false - this.$emit('submit', { - selected: [], - renamed: [], - } as ConflictResolutionResult) + this.$emit('skip') }, onSubmit() { @@ -344,6 +341,7 @@ export default defineComponent({ this.$emit('submit', { selected, renamed, + skipped: false, } as ConflictResolutionResult) }, diff --git a/lib/index.ts b/lib/index.ts index 8debfd90..9ae274e6 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -21,6 +21,7 @@ let _uploader: Uploader | null = null export type ConflictResolutionResult = { selected: T[], renamed: T[], + skipped: boolean, } /** * Get an Uploader instance @@ -104,6 +105,13 @@ export async function openConflictPicker( picker.$destroy() picker.$el?.parentNode?.removeChild(picker.$el) }, + skip() { + resolve({selected: [],renamed: [], skipped: true}) + + // Destroy the component + picker.$destroy() + picker.$el?.parentNode?.removeChild(picker.$el) + } }, }), })