From b06b41f7ebed0b44e8d2f2b374813541f213d163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 5 Dec 2023 23:13:15 +0100 Subject: [PATCH] fix: Get proper rich object for card actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- cypress/e2e/cardFeatures.js | 48 ++++++++++++++++++++++++ src/components/card/CardSidebar.vue | 10 ----- src/components/cards/CardMenuEntries.vue | 14 ++++++- 3 files changed, 61 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/cardFeatures.js b/cypress/e2e/cardFeatures.js index ee5de838f..60344ec05 100644 --- a/cypress/e2e/cardFeatures.js +++ b/cypress/e2e/cardFeatures.js @@ -252,4 +252,52 @@ describe('Card', function() { }) + describe('Card actions', () => { + beforeEach(function() { + cy.login(user) + useModal(false).then(() => { + cy.visit(`/apps/deck/#/board/${boardId}`) + }) + }) + + it('Custom card actions', () => { + const myAction = { + label: 'Test action', + icon: 'icon-user', + callback(card) { + console.log('Called callback', card) + }, + } + cy.spy(myAction, 'callback').as('myAction.callback') + + cy.window().then(win => { + win.OCA.Deck.registerCardAction(myAction) + }) + + cy.get('.card:contains("Hello world")').should('be.visible').click() + cy.get('#app-sidebar-vue') + .find('.ProseMirror h1').contains('Hello world').should('be.visible') + + cy.get('.app-sidebar-header .action-item__menutoggle').click() + cy.get('.v-popper__popper button:contains("Test action")').click() + + cy.get('@myAction.callback') + .should('be.called') + .its('firstCall.args.0') + .as('args') + + cy.url().then(url => { + const cardId = url.split('/').pop() + cy.get('@args').should('have.property', 'name', 'Hello world') + cy.get('@args').should('have.property', 'stackname', 'TestList') + cy.get('@args').should('have.property', 'boardname', 'MyTestBoard') + cy.get('@args').its('link').then((url) => { + expect(url.split('/').pop() === cardId).to.be.true + cy.visit(url) + cy.get('#app-sidebar-vue') + .find('.ProseMirror h1').contains('Hello world').should('be.visible') + }) + }) + }) + }) }) diff --git a/src/components/card/CardSidebar.vue b/src/components/card/CardSidebar.vue index 6b4988cca..cef0f8450 100644 --- a/src/components/card/CardSidebar.vue +++ b/src/components/card/CardSidebar.vue @@ -83,7 +83,6 @@