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

[OCM][Test Suite][Cypress] add Nextcloud v28 tests #113

Merged
merged 7 commits into from
Mar 27, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createShareV28, renameFileV28 } from '../utils/nextcloud-v28'

before(() => {
// makes custom commands available to all subsequent cy.origin('url')
// calls in this spec. put it in your support file to make them available to
// all specs
cy.origin('https://nextcloud4.docker', () => {
Cypress.require('../../support/commands')
})
})

describe('Native federated sharing functionality for Nextcloud v2.8', () => {
it('Accept federated share from Nextcloud to Nextcloud', () => {
// share from Nextcloud 3.
cy.loginNextcloud('https://nextcloud3.docker', 'yashar', 'pmh')

renameFileV28('welcome.txt', 'nc3-to-nc4-share.txt')
createShareV28('nc3-to-nc4-share.txt', 'madeline', 'nextcloud4.docker')

// accept share from Nextcloud 2.
cy.origin('https://nextcloud4.docker', () => {
cy.loginNextcloud('/', 'madeline', 'oleary')

cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()

// TODO: verify share received: 1. check for file name existence, 2. check if it can be downloaded, 3. compare checksum to the original file to make sure it is the same file.
// 1. check for filename existence.
cy.get('[data-file="nc3-to-nc4-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createShare, renameFile } from '../utils/owncloud'

before(() => {
// makes custom commands available to all subsequent cy.origin('url')
// calls in this spec. put it in your support file to make them available to
// all specs
cy.origin('https://nextcloud3.docker', () => {
Cypress.require('../../support/commands')
})
})

describe('Native federated sharing functionality for ownCloud', () => {
it('Accept federated share from ownCloud to Nextcloudn v2.8', () => {
// share from ownCloud 1.
cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')

// renameFile('welcome.txt', 'oc1-to-oc2-share.txt')
createShare('oc1-to-oc2-share.txt', 'yashar', 'nextcloud3.docker')

// accept share from Nextloud 1.
cy.origin('https://nextcloud3.docker', () => {
cy.loginNextcloud('/', 'yashar', 'pmh')

cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()

// TODO: verify share received: 1. check for file name existence, 2. check if it can be downloaded, 3. compare checksum to the original file to make sure it is the same file.
// 1. check for filename existence.
cy.get('[data-file="oc1-to-oc2-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createShareV27, renameFileV27 } from '../utils/nextcloud-v27'

before(() => {
// makes custom commands available to all subsequent cy.origin('url')
// calls in this spec. put it in your support file to make them available to
// all specs
cy.origin('https://nextcloud3.docker', () => {
Cypress.require('../../support/commands')
})
})

describe('Native federated sharing functionality for Nextcloud v2.7', () => {
it('Accept federated share from Nextcloud to Nextcloud', () => {
// share from Nextcloud 1.
cy.loginNextcloud('https://nextcloud1.docker', 'einstein', 'relativity')

// renameFileV27('welcome.txt', 'nc1-to-nc2-share.txt')
createShareV27('nc1-to-nc2-share.txt', 'yashar', 'nextcloud3.docker')

// accept share from Nextcloud 3.
cy.origin('https://nextcloud3.docker', () => {
cy.loginNextcloud('/', 'yashar', 'pmh')

cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()

// TODO: verify share received: 1. check for file name existence, 2. check if it can be downloaded, 3. compare checksum to the original file to make sure it is the same file.
// 1. check for filename existence.
cy.get('[data-file="nc1-to-nc2-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createShareV28, renameFileV28 } from '../utils/nextcloud-v28'

before(() => {
// makes custom commands available to all subsequent cy.origin('url')
// calls in this spec. put it in your support file to make them available to
// all specs
cy.origin('https://nextcloud2.docker', () => {
Cypress.require('../../support/commands')
})
})

describe('Native federated sharing functionality for Nextcloud v2.8', () => {
it('Accept federated share from Nextcloud 28 to Nextcloud 27', () => {
// share from Nextcloud 4.
cy.loginNextcloud('https://nextcloud4.docker', 'madeline', 'oleary')

renameFileV28('welcome.txt', 'nc4-to-nc2-share.txt')
createShareV28('nc4-to-nc2-share.txt', 'michiel', 'nextcloud2.docker')

// accept share from Nextcloud 2.
cy.origin('https://nextcloud2.docker', () => {
cy.loginNextcloud('/', 'michiel', 'dejong')

cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()

// TODO: verify share received: 1. check for file name existence, 2. check if it can be downloaded, 3. compare checksum to the original file to make sure it is the same file.
// 1. check for filename existence.
cy.get('[data-file="nc4-to-nc2-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createShareV28, renameFileV28 } from '../utils/nextcloud-v28'

before(() => {
// makes custom commands available to all subsequent cy.origin('url')
// calls in this spec. put it in your support file to make them available to
// all specs
cy.origin('https://owncloud2.docker', () => {
Cypress.require('../../support/commands')
})
})

describe('Native federated sharing functionality for Nextcloud v2.8', () => {
it('Accept federated share from Nextcloud to Nextcloud', () => {
// share from Nextcloud 3.
cy.loginNextcloud('https://nextcloud3.docker', 'yashar', 'pmh')

renameFileV28('welcome.txt', 'nc3-to-nc4-share.txt')
createShareV28('nc3-to-nc4-share.txt', 'mahdi', 'owncloud2.docker')

// accept share from Nextcloud 2.
cy.origin('https://owncloud2.docker', () => {
cy.loginOwncloud('/', 'mahdi', 'baghbani')

cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()

// TODO: verify share received: 1. check for file name existence, 2. check if it can be downloaded, 3. compare checksum to the original file to make sure it is the same file.
// 1. check for filename existence.
cy.get('[data-file="nc3-to-nc4-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
4 changes: 2 additions & 2 deletions cypress/ocm-test-suite/cypress/e2e/utils/nextcloud-v27.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function acceptShareV27() {
}

export function createShareV27(fileName, username, domain) {
openSharingPanel(fileName)
openSharingPanelV27(fileName)

cy.get('#app-sidebar-vue').within(() => {
cy.get('#sharing-search-input').clear()
Expand All @@ -33,7 +33,7 @@ export function renameFileV27(fileName, newFileName) {
cy.wait('@moveFile')
}

export function openSharingPanel(fileName) {
export function openSharingPanelV27(fileName) {
triggerActionForFileV27(fileName, 'Share')

cy.get('#app-sidebar-vue')
Expand Down
84 changes: 84 additions & 0 deletions cypress/ocm-test-suite/cypress/e2e/utils/nextcloud-v28.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export function acceptShareV28() {
cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()
}

export function createShareV28(fileName, username, domain) {
openSharingPanelV28(fileName)

cy.get('#app-sidebar-vue').within(() => {
cy.get('#sharing-search-input').clear()
cy.intercept({ times: 1, method: 'GET', url: '**/apps/files_sharing/api/v1/sharees?*' }).as('userSearch')
cy.get('#sharing-search-input').type(username + '@' + domain)
cy.wait('@userSearch')
})

// ensure selecting remote [sharetype="6"] instead of email!
cy.get(`[user="${username}"]`).click()

// cy.get('[data-cy-files-sharing-share-editor-action="save"]').click({ scrollBehavior: 'nearest' })
cy.get('*[class^="sharingTabDetailsView"]').find('*[class^="sharingTabDetailsView__footer"]').find('*[class^="button-group"]').find('*[class^="button-vue button-vue--text-only button-vue--vue-primary"]').click()

// HACK: Save the share and then update it, as permissions changes are currently not saved for new share.
// updateShareV28(fileName, 0) // @MahdiBaghbani: not sure about this yet.
}

export function updateShareV28(fileName, index) {
openSharingPanelV28(fileName)

cy.get('#app-sidebar-vue').within(() => {
cy.get('[data-cy-files-sharing-share-actions]').eq(index).click()
cy.get('[data-cy-files-sharing-share-permissions-bundle="custom"]').click()

cy.get('[data-cy-files-sharing-share-permissions-checkbox="download"]').find('input').as('downloadCheckbox')
// Force:true because the checkbox is hidden by the pretty UI.
cy.get('@downloadCheckbox').check({ force: true, scrollBehavior: 'nearest' })

cy.get('[data-cy-files-sharing-share-permissions-checkbox="read"]').find('input').as('readCheckbox')
// Force:true because the checkbox is hidden by the pretty UI.
cy.get('@readCheckbox').check({ force: true, scrollBehavior: 'nearest' })

cy.get('[data-cy-files-sharing-share-permissions-checkbox="update"]').find('input').as('updateCheckbox')
// Force:true because the checkbox is hidden by the pretty UI.
cy.get('@updateCheckbox').check({ force: true, scrollBehavior: 'nearest' })

cy.get('[data-cy-files-sharing-share-permissions-checkbox="delete"]').find('input').as('deleteCheckbox')
// Force:true because the checkbox is hidden by the pretty UI.
cy.get('@deleteCheckbox').check({ force: true, scrollBehavior: 'nearest' })

cy.get('[data-cy-files-sharing-share-editor-action="save"]').click({ scrollBehavior: 'nearest' })
})
}

export const renameFileV28 = (fileName, newFileName) => {
getRowForFileV28(fileName)
triggerActionForFileV28(fileName, 'rename')

// intercept the move so we can wait for it.
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
getRowForFileV28(fileName).find('[data-cy-files-list-row-name] input').clear()
getRowForFileV28(fileName).find('[data-cy-files-list-row-name] input').type(`${newFileName}{enter}`)
cy.wait('@moveFile')
}

export function openSharingPanelV28(fileName) {
triggerActionForFileV28(fileName, 'details')

cy.get('#app-sidebar-vue')
.get('[aria-controls="tab-sharing"]')
.click()
}

export const triggerActionForFileV28 = (filename, actionId) => {
getActionButtonForFileV28(filename).click()
cy.get(`[data-cy-files-list-row-action="${CSS.escape(actionId)}"] > button`).should('exist').click()
}

export const getActionButtonForFileV28 = (filename) => getActionsForFileV28(filename).find('button[aria-label="Actions"]')

export const getActionsForFileV28 = (filename) => getRowForFileV28(filename).find('[data-cy-files-list-row-actions]')

export const getRowForFileV28 = (filename) => cy.get(`[data-cy-files-list-row-name="${CSS.escape(filename)}"]`)
4 changes: 2 additions & 2 deletions docker/scripts/init-nextcloud-ocm-test-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sed -i "8 i\ 1 => 'nc1.docker'," /var/www/html/config
sed -i "9 i\ 2 => 'nc2.docker'," /var/www/html/config/config.php
sed -i "10 i\ 3 => 'nextcloud1.docker'," /var/www/html/config/config.php
sed -i "11 i\ 4 => 'nextcloud2.docker'," /var/www/html/config/config.php
sed -i "12 i\ 3 => 'nextcloud3.docker'," /var/www/html/config/config.php
sed -i "13 i\ 4 => 'nextcloud4.docker'," /var/www/html/config/config.php
sed -i "12 i\ 5 => 'nextcloud3.docker'," /var/www/html/config/config.php
sed -i "13 i\ 6 => 'nextcloud4.docker'," /var/www/html/config/config.php

# php console.php app:enable sciencemesh
2 changes: 2 additions & 0 deletions docker/scripts/init-nextcloud-sciencemesh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ sed -i "8 i\ 1 => 'nc1.docker'," /var/www/html/config
sed -i "9 i\ 2 => 'nc2.docker'," /var/www/html/config/config.php
sed -i "10 i\ 3 => 'nextcloud1.docker'," /var/www/html/config/config.php
sed -i "11 i\ 4 => 'nextcloud2.docker'," /var/www/html/config/config.php
sed -i "12 i\ 5 => 'nextcloud3.docker'," /var/www/html/config/config.php
sed -i "13 i\ 6 => 'nextcloud4.docker'," /var/www/html/config/config.php

php console.php app:enable sciencemesh
4 changes: 2 additions & 2 deletions docker/scripts/init-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ sed -i "8 i\ 1 => 'nc1.docker'," /var/www/html/config
sed -i "9 i\ 2 => 'nc2.docker'," /var/www/html/config/config.php
sed -i "10 i\ 3 => 'nextcloud1.docker'," /var/www/html/config/config.php
sed -i "11 i\ 4 => 'nextcloud2.docker'," /var/www/html/config/config.php
sed -i "12 i\ 3 => 'nextcloud3.docker'," /var/www/html/config/config.php
sed -i "13 i\ 4 => 'nextcloud4.docker'," /var/www/html/config/config.php
sed -i "12 i\ 5 => 'nextcloud3.docker'," /var/www/html/config/config.php
sed -i "13 i\ 6 => 'nextcloud4.docker'," /var/www/html/config/config.php
Loading