Add 'settings/' from commit '230545a4a75b0611988fbcea51336a6c316d6a3d'

git-subtree-dir: settings
git-subtree-mainline: c26f7b390a
git-subtree-split: 230545a4a7
This commit is contained in:
A.Unger
2020-09-18 12:43:43 +02:00
140 changed files with 28757 additions and 0 deletions
@@ -0,0 +1,57 @@
Feature: Set user specific settings
As a user
I want to set user specific settings
So that I can customize my OCIS experience to my liking
Background:
Given these users have been created with default attributes:
| username |
| user1 |
| user2 |
Scenario: Check the default settings
Given user "user1" has logged in using the webUI
And the user browses to the settings page
Then the setting "Language" should have value "Please select"
When the user browses to the files page
Then the files menu should be listed in language "English"
Scenario: changing the language
Given user "user1" has logged in using the webUI
And the user browses to the settings page
When the user changes the language to "Deutsch"
Then the setting "Language" should have value "Deutsch"
When the user browses to the files page
And the user reloads the current page of the webUI
Then the files menu should be listed in language "Deutsch"
Scenario: changing the language only affects one user
Given user "user2" has logged in using the webUI
And the user browses to the settings page
When the user changes the language to "Español"
Then the setting "Language" should have value "Español"
When the user browses to the files page
And the user reloads the current page of the webUI
Then the files menu should be listed in language "Español"
When the user re-logs in as "user1" using the webUI
And the user reloads the current page of the webUI
Then the files menu should be listed in language "English"
Scenario: Check the accounts menu when the language is changed
Given user "user2" has logged in using the webUI
And the user browses to the settings page
When the user changes the language to "Deutsch"
And the user reloads the current page of the webUI
Then the setting "Language" should have value "Deutsch"
And the account menu should be listed in language "Deutsch"
When the user changes the language to "Français"
Then the account menu should be listed in language "Français"
Scenario: Check the files table header menu when the language is changed
Given user "user2" has logged in using the webUI
And the user browses to the settings page
When the user changes the language to "Deutsch"
Then the setting "Language" should have value "Deutsch"
When the user browses to the files page
And the user reloads the current page of the webUI
Then the files header should be displayed in language "Deutsch"
@@ -0,0 +1,96 @@
const filesMenu = {
English: [
'All files',
'Shared with me',
'Shared with others',
'Trash bin'
],
Deutsch: [
'Alle Dateien',
'Mit mir geteilt',
'Mit anderen geteilt',
'Papierkorb'
],
Español: [
'Todos los archivos',
'Compartido conmigo',
'Compartido con otros',
'Papelera de reciclaje'
],
Français: [
'Tous les fichiers',
'Partagé avec moi',
'Partagé avec autres',
'Corbeille'
]
}
const accountMenu = {
English: [
'Manage your account',
'Log out'
],
Deutsch: [
'Verwalten Sie Ihr Benutzerkonto',
'Abmelden'
],
Español: [
'Administra tu cuenta',
'Salir'
],
Français: [
'Modifier votre compte',
'Se déconnecter'
]
}
const filesListHeaderMenu = {
English: [
'Name',
'Size',
'Updated',
'Actions'
],
Deutsch: [
'Name',
'Größe',
'Erneuert',
'Aktionen'
],
Español: [
'Nombre',
'Tamaño',
'Actualizado',
'Acciones'
],
Français: [
'Nom',
'Taille',
'Modifié',
'Actions'
]
}
exports.getFilesMenuForLanguage = function (language) {
const menuList = filesMenu[language]
if (menuList === undefined) {
throw new Error(`Menu for language ${language} is not available`)
}
return menuList
}
exports.getUserMenuForLanguage = function (language) {
const menuList = accountMenu[language]
if (menuList === undefined) {
throw new Error(`Menu for language ${language} is not available`)
}
return menuList
}
exports.getFilesHeaderMenuForLanguage = function (language) {
const menuList = filesListHeaderMenu[language]
if (menuList === undefined) {
throw new Error(`Menu for language ${language} is not available`)
}
return menuList
}
@@ -0,0 +1,85 @@
module.exports = {
commands: {
getMenuList: async function () {
const menu = []
await this.isVisible('@openNavigationBtn', (res) => {
if (res.value) {
this.click('@openNavigationBtn')
}
})
await this.waitForElementVisible('@fileSidebarNavItem')
await this.api
.elements('@fileSidebarNavItem', result => {
result.value.map(item => {
this.api.elementIdText(item.ELEMENT, res => {
menu.push(res.value)
})
})
})
return menu
},
getUserMenu: async function () {
const menu = []
await this
.waitForElementVisible('@userMenuBtn')
.click('@userMenuBtn')
.waitForElementVisible('@userMenuContainer')
await this.api
.elements('@userMenuItem', result => {
result.value.map(item => {
this.api.elementIdText(item.ELEMENT, res => {
menu.push(res.value)
})
})
})
await this
.waitForElementVisible('@userMenuBtn')
.click('@userMenuBtn')
.waitForElementNotVisible('@userMenuContainer')
return menu
},
getFileHeaderItems: async function () {
const menu = []
await this.waitForElementVisible('@fileTableHeaderItems')
await this.api
.elements('@fileTableHeaderItems', result => {
result.value.map(item => {
this.api.elementIdText(item.ELEMENT, res => {
menu.push(res.value)
})
})
})
return menu
}
},
elements: {
pageHeader: {
selector: '.oc-page-title'
},
languageValue: {
selector: "//button[@id='single-choice-toggle-profile-language']",
locateStrategy: 'xpath'
},
fileSidebarNavItem: {
selector: '.oc-sidebar-nav-item'
},
openNavigationBtn: {
selector: '//button[@aria-label="Open navigation menu"]',
locateStrategy: 'xpath'
},
userMenuBtn: {
selector: '#_userMenuButton'
},
userMenuItem: {
selector: '#account-info-container li'
},
userMenuContainer: {
selector: '#account-info-container'
},
fileTableHeaderItems: {
selector: '//*[@id="files-table-header"]//span[not(*) and not(ancestor::label)]',
locateStrategy: 'xpath'
}
}
}
@@ -0,0 +1,79 @@
const { client } = require('nightwatch-api')
const util = require('util')
module.exports = {
url: function () {
return this.api.launchUrl + '/#/settings'
},
commands: {
navigateAndWaitTillLoaded: async function () {
const url = this.url()
await await this.navigate(url)
while (true) {
let found = false
await this.waitForElementVisible('@pageHeader', 2000, 500, false)
await this.api
.elements('@pageHeader', result => {
if (result.value.length) {
found = true
}
})
if (found) {
break
}
await client.refresh()
}
return this.waitForElementVisible('@pageHeader')
},
getSettingsValue: async function (key) {
let output
switch (key) {
case 'Language':
await this.waitForElementVisible('@languageValue')
.getText('@languageValue', (result) => {
output = result.value
})
break
default:
throw new Error('failed to find the setting')
}
return output
},
changeSettings: async function (key, value) {
const selectXpath = util.format(this.elements.languageSelect.selector, value)
switch (key) {
case 'Language':
await this.waitForElementVisible('@languageValue')
.click('@languageValue')
.useXpath()
.waitForElementVisible(this.elements.languageDropdown.selector)
.click(selectXpath)
.waitForElementNotVisible(this.elements.languageDropdown.selector)
.useCss()
break
default:
throw new Error('failed to find the setting')
}
}
},
elements: {
pageHeader: {
selector: '.oc-page-title'
},
languageValue: {
selector: "//label[.='Language']/..//button[starts-with(@id, 'single-choice-toggle')]",
locateStrategy: 'xpath'
},
languageDropdown: {
selector: "//label[.='Language']/..//div[starts-with(@id, 'single-choice-drop')]",
locateStrategy: 'xpath'
},
languageSelect: {
selector: "//label[.='Language']/..//div[starts-with(@id, 'single-choice-drop')]//label[normalize-space()='%s']",
locateStrategy: 'xpath'
}
}
}
@@ -0,0 +1,55 @@
const assert = require('assert')
const path = require('path')
const fs = require('fs-extra')
const { client } = require('nightwatch-api')
const { Given, When, Then, After } = require('cucumber')
const languageHelper = require('../helpers/language')
Given('the user browses to the settings page', function () {
return client.page.settingsPage().navigateAndWaitTillLoaded()
})
Then('the setting {string} should have value {string}', async function (setting, result) {
const actual = await client.page.settingsPage().getSettingsValue(setting)
assert.strictEqual(actual, result, 'The setting value doesnt matches to ' + result)
})
When('the user changes the language to {string}', async function (value) {
await client.page.settingsPage().changeSettings('Language', value)
})
Then('the files menu should be listed in language {string}', async function (language) {
const menu = await client.page.filesPageSettingsContext().getMenuList()
const expected = languageHelper.getFilesMenuForLanguage(language)
assert.deepEqual(menu, expected, 'the menu list were not same')
})
Then('the account menu should be listed in language {string}', async function (language) {
const menu = await client.page.filesPageSettingsContext().getUserMenu()
const expected = languageHelper.getUserMenuForLanguage(language)
assert.deepEqual(menu, expected, 'the menu list were not same')
})
Then('the files header should be displayed in language {string}', async function (language) {
const items = await client.page.filesPageSettingsContext().getFileHeaderItems()
const expected = languageHelper.getFilesHeaderMenuForLanguage(language)
assert.deepEqual(items, expected, 'the menu list were not same')
})
After(async function () {
const directory = path.join(client.globals.settings_store, 'values')
try {
console.log('Elements')
fs.readdirSync(directory).map(element => {
console.log(element)
})
} catch (err) {
console.log('Error while reading the settings values from file system... ')
}
try {
fs.emptyDirSync(directory)
} catch (err) {
console.log('Error while clearing settings values from file system')
console.log('No settings may have been changed by the tests')
}
})