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] Implement Nextcloud to Nextcloud Sharing tests. #99

Merged
merged 7 commits into from
Mar 21, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

bin/
ocm
./reva/
/reva
core
temp
server
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Docker images we use in development.

upstream: [Nextcloud Server Official](https://github.com/nextcloud/server)

branch: [v28.0.2](https://github.com/nextcloud/server/releases/tag/v28.0.2)
branch: [v27.1.7](https://github.com/nextcloud/server/releases/tag/v27.1.7)

## ownCloud version

Expand Down
1 change: 1 addition & 0 deletions cypress/ocm-test-suite/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
experimentalOriginDependencies: true,
},
video: true,
videoCompression: true,
Expand Down
35 changes: 35 additions & 0 deletions cypress/ocm-test-suite/cypress/e2e/share/nextcloud-v2-7.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { acceptShareV2_7, createShareV2_7, getRowForFileV2_7, renameFileV2_7 } from '../utils/nextcloud-v2-7'

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.7', () => {
it('Accept federated share from Nextcoud to Nextcloud', () => {
// share from Nextcloud 1.
cy.loginNextcloud('https://nextcloud1.docker', 'einstein', 'relativity')

renameFileV2_7('welcome.txt', 'nc1-to-nc2-share.txt')
createShareV2_7('nc1-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="nc1-to-nc2-share.txt"]', { timeout: 10000 }).should('be.visible')
})
})
})
53 changes: 53 additions & 0 deletions cypress/ocm-test-suite/cypress/e2e/utils/nextcloud-v2-7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export function acceptShareV2_7() {
cy.get('div[class="oc-dialog"]', { timeout: 10000 })
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.click()
}

export function createShareV2_7(fileName, username, domain) {
openSharingPanel(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('div[class="button-group"]').contains('Save share').click()

// TODO: check if it has been shared before with same user or not! (or reset share on both ends on each run for better developer experience, right now I have to manually clean and restart)
}

export function renameFileV2_7(fileName, newFileName) {
triggerActionInFileMenuV2_7(fileName, 'Rename')

// intercept the move so we can wait for it.
cy.intercept('MOVE', /\/remote.php\/dav\/files\//).as('moveFile')
getRowForFileV2_7(fileName).find('form').find('input').clear()
getRowForFileV2_7(fileName).find('form').find('input').type(`${newFileName}{enter}`)
cy.wait('@moveFile')
}

export function openSharingPanel(fileName) {
triggerActionForFileV2_7(fileName, 'Share')

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

export function triggerActionInFileMenuV2_7 (fileName, actionId) {
triggerActionForFileV2_7(fileName,'menu')
getRowForFileV2_7(fileName).find('*[class^="filename"]').find('*[class^="fileActionsMenu"]').find(`[data-action="${CSS.escape(actionId)}"]`).should('exist').click()
}

export const triggerActionForFileV2_7 = (filename, actionId) => getActionsForFileV2_7(filename).find(`[data-action="${CSS.escape(actionId)}"]`).should('exist').click()

export const getActionsForFileV2_7 = (filename) => getRowForFileV2_7(filename).find('*[class^="filename"]').find('*[class^="name"]').find('*[class^="fileactions"]')

export const getRowForFileV2_7 = (filename) => cy.get(`[data-file="${CSS.escape(filename)}"]`)
22 changes: 5 additions & 17 deletions cypress/ocm-test-suite/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
// ***********************************************************
// This example support/e2e.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
// code we only want run per test, so it shouldn't be run as part of
// the execution of cy.origin() as well
beforeEach(() => {
// ... code to run before each test ...
})