Skip to content

Commit

Permalink
feat: handle assistant sync task
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Feb 27, 2024
1 parent 9d7db56 commit 10ebf2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
15 changes: 9 additions & 6 deletions cypress/e2e/Assistant.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ describe('Assistant', () => {
cy.getContent()
.click({ force: true })

cy.get('.floating-menu')
cy.get('[data-cy="assistantMenu"]')
.should('be.visible')

cy.get('.floating-menu')
cy.get('[data-cy="assistantMenu"]')
.click()

cy.get('.action-item__popper ul').children().should(($children) => {
Expand All @@ -46,22 +46,25 @@ describe('Assistant', () => {

cy.getContent()
.click({ force: true })
cy.get('.floating-menu')
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('.action-item__popper ul li').first()
.click()

cy.get('.assistant-modal--content #assistant-input')
cy.get('.assistant-modal--content #input-prompt')
.should('be.visible')

cy.get('.assistant-modal--content #assistant-input')
cy.get('.assistant-modal--content #input-prompt')
.type('Hello World')
cy.get('.assistant-modal--content .submit-button')
.click()

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000)

cy.get('.assistant-modal--content .close-button')
.click()
cy.get('.floating-menu')
cy.get('[data-cy="assistantMenu"]')
.click()
cy.get('.action-item__popper ul li').last()
.click()
Expand Down
9 changes: 5 additions & 4 deletions src/components/Assistant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
:editor="$editor"
:tippy-options="floatingOptions()"
:should-show="floatingShow"
class="floating-menu">
class="floating-menu"
data-cy="assistantMenu">
<NcActions :title="t('text', 'Nextcloud Assistant')" :type="'secondary'">
<template #icon>
<CreationIcon :size="20" class="icon" />
Expand Down Expand Up @@ -214,7 +215,7 @@ export default {
},
computed: {
showAssistant() {
return !this.$isRichWorkspace && !this.$isPublic && window?.OCA?.TpAssistant?.openAssistantForm
return !this.$isRichWorkspace && !this.$isPublic && window?.OCA?.TPAssistant?.openAssistantForm
},
identifier() {
return 'text-file:' + this.$file.fileId
Expand Down Expand Up @@ -281,7 +282,7 @@ export default {
this.selection = state.doc.textBetween(from, to, ' ')
},
async openAssistantForm(taskType = null) {
await window.OCA.TpAssistant.openAssistantForm(
await window.OCA.TPAssistant.openAssistantForm(
{
appId: 'text',
identifier: this.identifier,
Expand Down Expand Up @@ -326,7 +327,7 @@ export default {
this.displayTranslate = false
},
async openResult(task) {
window.OCA?.TpAssistant.openAssistantResult(task)
window.OCA?.TPAssistant.openAssistantResult(task)
},
async insertResult(task) {
this.$editor.commands.insertContent(task.output)
Expand Down

0 comments on commit 10ebf2e

Please sign in to comment.