diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index cbb7f30bc0d..f2ae311e3ab 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -41,6 +41,13 @@ jobs: ref: ${{ matrix.server-versions }} path: apps/viewer + - name: Checkout assistant + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + with: + repository: nextcloud/assistant + ref: 'main' + path: apps/assistant + - name: Checkout app uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: @@ -69,6 +76,13 @@ jobs: npm ci TESTING=true npm run build --if-present + - name: Install dependencies & build assistant + working-directory: apps/assistant + run: | + composer install --no-dev + npm ci + npm run build + - name: Save context uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 with: @@ -142,6 +156,8 @@ jobs: php occ user:add --password-from-env user2 php occ app:enable viewer php occ app:enable text + php occ app:enable assistant + php occ app:enable testing php occ app:list php occ background:cron php occ config:system:set session_keepalive --value=false --type=boolean diff --git a/cypress/e2e/Assistant.spec.js b/cypress/e2e/Assistant.spec.js new file mode 100644 index 00000000000..b34e6b2b89a --- /dev/null +++ b/cypress/e2e/Assistant.spec.js @@ -0,0 +1,76 @@ +import { initUserAndFiles, randUser } from '../utils/index.js' + +const currentUser = randUser() + +const fileName = 'empty.md' + +describe('Assistant', () => { + before(() => { + initUserAndFiles(currentUser, fileName) + }) + + beforeEach(() => { + cy.login(currentUser) + cy.visit('/apps/files') + }) + + it('See assistant button', () => { + cy.isolateTest({ + sourceFile: fileName, + }) + cy.openFile(fileName, { force: true }) + + cy.getContent() + .click({ force: true }) + + cy.get('[data-cy="assistantMenu"]') + .should('be.visible') + + cy.get('[data-cy="assistantMenu"]') + .click() + + cy.get('.action-item__popper ul').children().should(($children) => { + const entries = $children.find('button').map((i, el) => el.innerText).get() + expect(entries.length).to.be.greaterThan(0) + expect('Free prompt').to.be.oneOf(entries) + expect('Translate').to.be.oneOf(entries) + expect('Show assistant results').to.be.oneOf(entries) + }) + }) + + it('Send free prompt request', () => { + cy.isolateTest({ + sourceFile: fileName, + }) + cy.openFile(fileName, { force: true }) + + cy.getContent() + .click({ force: true }) + cy.get('[data-cy="assistantMenu"]') + .click() + cy.get('.action-item__popper ul li').first() + .click() + + cy.get('.assistant-modal--content #input-prompt') + .should('be.visible') + + 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('[data-cy="assistantMenu"]') + .click() + cy.get('.action-item__popper ul li').last() + .click() + + cy.get('.modal-container__content .task-list') + .should('be.visible') + .should('contain', 'Hello World') + }) +}) diff --git a/cypress/entrypoint.sh b/cypress/entrypoint.sh index 8efe3d36d7c..64339e376aa 100644 --- a/cypress/entrypoint.sh +++ b/cypress/entrypoint.sh @@ -19,8 +19,10 @@ if [ $? -eq 0 ]; then php /var/www/html/occ user:add --password-from-env user2 php /var/www/html/occ app:enable viewer php /var/www/html/occ app:enable text + php /var/www/html/occ app:enable assistant + php /var/www/html/occ app:enable testing php /var/www/html/occ app:list " fi -exec $@ \ No newline at end of file +exec $@ diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7fdf15251a7..41f60adb579 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -41,7 +41,7 @@ use OCA\Text\Middleware\SessionMiddleware; use OCA\Text\Notification\Notifier; use OCA\Text\Service\ConfigService; -use OCA\TPAssistant\Event\BeforeAssistantNotificationEvent; +use OCA\TpAssistant\Event\BeforeAssistantNotificationEvent; use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; diff --git a/lib/Listeners/BeforeAssistantNotificationListener.php b/lib/Listeners/BeforeAssistantNotificationListener.php index 8dce9f16b47..49553f9e83a 100644 --- a/lib/Listeners/BeforeAssistantNotificationListener.php +++ b/lib/Listeners/BeforeAssistantNotificationListener.php @@ -3,7 +3,7 @@ namespace OCA\Text\Listeners; use OCA\Text\AppInfo\Application; -use OCA\TPAssistant\Event\BeforeAssistantNotificationEvent; +use OCA\TpAssistant\Event\BeforeAssistantNotificationEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IURLGenerator; diff --git a/src/components/Assistant.vue b/src/components/Assistant.vue index af1f77d8958..81e749eadc3 100644 --- a/src/components/Assistant.vue +++ b/src/components/Assistant.vue @@ -24,7 +24,8 @@ :editor="$editor" :tippy-options="floatingOptions()" :should-show="floatingShow" - class="floating-menu"> + class="floating-menu" + data-cy="assistantMenu">