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

Test/nightwatch v3 #889

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ vendor/
js/*
build/
.php-cs-fixer.cache
.vscode/
logs/
tests_output
90 changes: 90 additions & 0 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

// _ _ _ _ _ _ _
// | \ | |(_) | | | | | | | |
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
// __/ |
// |___/

module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ['tests/nightwatch'],

// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: ['nightwatch/page-objects'],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: ['nightwatch/custom-commands'],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
custom_assertions_path: ['nightwatch/custom-assertions'],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
plugins: [],

// See https://nightwatchjs.org/guide/concepts/test-globals.html
globals_path: '',

webdriver: {},

test_workers: {
enabled: true
},

test_settings: {
default: {
disable_error_log: false,
launch_url: 'http://stable26.local/index.php',
globals: {
adminLogin: 'admin',
adminPwd: 'admin',
},
screenshots: {
enabled: false,
path: 'screens',
on_failure: true
},

desiredCapabilities: {
browserName: 'firefox'
},

webdriver: {
start_process: true,
server_path: ''
},

},

firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [
// '-headless',
// '-verbose'
]
}
}
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// very verbose geckodriver logs
// '-vv'
]
}
},

},

};
38 changes: 38 additions & 0 deletions nightwatch/custom-commands/groupfolders/currentNames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
async function getGroupfolderName(browser, index) {
return await browser.getText({
selector: 'tbody tr td:nth-child(1) a',
index,
})
}
/**
* class-based custom-command in Nightwatch. The command name is the filename
*
* Usage:
* browser.currentNames()
* Goes to the groupfolders page and returns the list of created groupfolders names
* The browser object is available via this.api.
*
* For more information on working with custom-commands see:
* https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
*
*/
module.exports = class CurrentNames {

async command() {
this.api.navigateTo(`${this.api.launchUrl}/settings/admin/groupfolders`)
this.api
.waitForElementVisible('#groupfolders-wrapper')
.assert.elementPresent('table')
try {
const groupfolders = await this.api.findElements('tbody tr td:nth-child(1) a')
const gfNamesPromises = await groupfolders.map((_gf, i) => {
return getGroupfolderName(this.api, i)
})
return await Promise.all(gfNamesPromises)
} catch (err) {
console.debug('currentNames error ', err)
return []
}
}

}
25 changes: 25 additions & 0 deletions nightwatch/custom-commands/loginAs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* A non-class-based custom-command in Nightwatch. The command name is the filename.
*
* Usage:
* browser.loginAs(role, browser)
* This command is not used yet used in any of the examples.
*
* For more information on working with custom-commands see:
* https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
*
*/

module.exports = {
command(role) {
const login = role === 'admin' ? this.globals.adminLogin : ''
const pwd = role === 'admin' ? this.globals.adminPwd : ''
this.navigateTo(this.launchUrl)
this
.waitForElementVisible('body')
.setValue('input#user', login)
.setValue('input#password', pwd)
.click('button[type=submit]')
.waitForElementPresent('a#nextcloud')
},
}
10 changes: 10 additions & 0 deletions nightwatch/custom-commands/workspace/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
command(spaceName) {
this
.click('div.icon-add')
.assert.elementPresent('input[type=text]')
.setValue('input[type=text]', spaceName)
.click('button[type=submit]')
.waitForElementPresent('ul.app-navigation__list li')
},
}
29 changes: 29 additions & 0 deletions nightwatch/custom-commands/workspace/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* function style Nightwatch command
* goes to /apps/workspace/workspace/spaceName and clicks 'Delete workspace' icon
*
* @param {string} spaceName workspace name
*/
module.exports = {
async command(spaceName) {
this
.navigateTo(`${this.launchUrl}/apps/workspace/workspace/${spaceName}`)
.waitForElementPresent('ul.app-navigation__list')
const toggleMenuBtn = await this.findElements('button.action-item__menutoggle')
await this.click(toggleMenuBtn[1], function(result) {
console.debug('Click result', result)
})
this.waitForElementPresent('ul[role=menu]')
.within('ul[role=menu]').click('span.icon-delete', function(result) {
console.debug('Click result', result)
})
this.waitForElementPresent('.modal__content')
const deleteBtn = await this.findElements('.remove-space-actions button')
await this.pause(3000)
console.debug('deleteBtn ', deleteBtn[1])
this.click(deleteBtn[1], function(result) {
console.debug('Click result', result)
})
this.waitForElementNotPresent('.modal__content')
},
}
Loading