Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] test(open-pdf): open pdf with richdocuments via file-action #3666

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ jobs:
ref: ${{ matrix.server-versions }}
path: apps/viewer

- name: Checkout files_pdfviewer
uses: actions/checkout@v3
with:
repository: nextcloud/files_pdfviewer
ref: ${{ matrix.server-versions }}
path: apps/files_pdfviewer

- name: Checkout ${{ env.APP_NAME }}
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -100,6 +107,7 @@ jobs:
php occ config:system:set force_language --value en
php occ app:enable --force testing
php occ app:enable --force viewer
php occ app:enable --force files_pdfviewer
php occ app:enable --force richdocuments
php occ app:list
php occ config:system:set trusted_domains 1 --value="172.17.0.1"
Expand Down
84 changes: 63 additions & 21 deletions cypress/e2e/open.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,14 @@ describe('Open existing office files', function() {
cy.get('#main-menu #menu-file > a').click()
cy.get('#main-menu #menu-shareas > a').should('be.visible').click()
})
cy.verifyOpen(filename)

cy.get('#app-sidebar-vue')
.should('be.visible')
cy.get('.app-sidebar-header__mainname')
.should('be.visible')
.should('contain.text', filename)
// FIXME: wait for sidebar tab content
// FIXME: validate sharing tab
cy.screenshot('share-sidebar_' + filename)

// Validate closing
cy.get('@loleafletframe').within(() => {
cy.get('#closebutton').click()
})
cy.get('#viewer', { timeout: 5000 }).should('not.exist')
cy.closeDocument()
})

it('Notebookbar UI: Open ' + filename + ' the viewer on file click', function() {
Expand All @@ -90,27 +83,76 @@ describe('Open existing office files', function() {
cy.waitForCollabora()

cy.screenshot('open-file_' + filename)

// Share action
cy.get('@loleafletframe').within(() => {
cy.get('button.icon-nextcloud-sidebar').click()
})

cy.get('#app-sidebar-vue')
.should('be.visible')
cy.get('.app-sidebar-header__mainname')
.should('be.visible')
.should('contain.text', filename)
cy.verifyOpen(filename)
// FIXME: wait for sidebar tab content
// FIXME: validate sharing tab
cy.screenshot('share-sidebar_' + filename)

// Validate closing
cy.get('@loleafletframe').within(() => {
cy.get('#closebutton').click()
})
cy.get('#viewer', { timeout: 5000 }).should('not.exist')
cy.closeDocument()
})

})
})

describe('Open PDF with richdocuments', () => {
let randUser

before(() => {
cy.createRandomUser().then((user) => {
randUser = user

cy.login(user)
cy.uploadFile(user, 'document.pdf', 'application/pdf', '/document.pdf')
})
})

beforeEach(() => {
cy.login(randUser)
cy.visit('/apps/files')
})

// Verify that clicking on the file uses the files PDF viewer
// and NOT richdocuments
it('Open PDF with files PDF viewer', () => {
cy.get('[data-cy-files-list-row-name="document.pdf"]').click()
cy.waitForViewer()

// Verify Collabora is not being used
cy.get('[data-cy="coolframe"]').should('not.exist')

// Verify the files PDF viewer is being used
cy.get('.viewer__file--active')
.its('0.contentDocument')
.its('body').should('not.be.empty')
.as('pdfViewer')

cy.get('@pdfViewer').find('.pdfViewer').should('exist')
})

// Verify that using the file action 'Edit with Nextcloud Office'
// opens the file using richdocuments
it('Open PDF with richdocuments', () => {
cy.get('[data-cy-files-list-row-name="document.pdf"]').as('pdf')
cy.get('@pdf').find('.action-items').as('actions')

cy.get('@actions').find('.action-item__menutoggle').click()
cy.get('.action-button__longtext').contains('Edit with Nextcloud Office').click()

// Wait for Collabora to open
cy.waitForViewer()
cy.waitForCollabora()

// Verify that the correct file is open
cy.get('@loleafletframe').within(() => {
cy.get('button.icon-nextcloud-sidebar').click()
})
cy.verifyOpen('document.pdf')

// Make sure we can close the document
cy.closeDocument()
})
})
Binary file added cypress/fixtures/document.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ Cypress.Commands.add('inputCollaboraGuestName', (guestName = 'cloud') => {
cy.get('[data-cy="guestNameSubmit"]').click()
})

Cypress.Commands.add('closeDocument', () => {
cy.get('@loleafletframe').within(() => {
cy.get('#closebutton').click()
})

cy.get('#viewer', { timeout: 5000 }).should('not.exist')
})

Cypress.Commands.add('verifyOpen', (filename) => {
cy.get('#app-sidebar-vue')
.should('be.visible')
cy.get('.app-sidebar-header__mainname')
.should('be.visible')
.should('contain.text', filename)
})

Cypress.Commands.add('uploadSystemTemplate', () => {
cy.login(new User('admin', 'admin'))
cy.visit('/settings/admin/richdocuments')
Expand Down
Loading