tmp Tests fix
This commit is contained in:
parent
22fe6d6818
commit
36b9aa296b
|
@ -510,4 +510,9 @@ custom-*.*
|
|||
*.txt
|
||||
|
||||
sw.js
|
||||
!/server/resources/src/sw.js
|
||||
!/server/resources/src/sw.js
|
||||
|
||||
/server/cypress/screenshots
|
||||
!/server/cypress/screenshots/.gitkeep
|
||||
/server/cypress/videos
|
||||
!/server/cypress/videos/.gitkeep
|
|
@ -669,13 +669,17 @@ class translations
|
|||
public function __construct()
|
||||
{
|
||||
$this->client_languages = $this->client_languages();
|
||||
foreach($this->client_languages as $language){
|
||||
if(in_array($language, $this->loaded_languages) && $this->language == null) {
|
||||
$this->language = $language;
|
||||
if(isset($_COOKIE["forceLanguage"]) && in_array($_COOKIE["forceLanguage"], $this->$loaded_languages)){
|
||||
$this->language = $_COOKIE["forceLanguage"];
|
||||
} else {
|
||||
foreach($this->client_languages as $language){
|
||||
if(in_array($language, $this->loaded_languages) && $this->language == null) {
|
||||
$this->language = $language;
|
||||
}
|
||||
}
|
||||
if($this->language == null) {
|
||||
$this->language = "en";
|
||||
}
|
||||
}
|
||||
if($this->language == null) {
|
||||
$this->language = "en";
|
||||
}
|
||||
$file_infos = pathinfo(array_reverse(debug_backtrace())[0]['file']);
|
||||
if(strpos($file_infos['dirname'], 'resources') !== false) {
|
||||
|
|
|
@ -5,6 +5,11 @@ describe("Installation", () => {
|
|||
cy.visit("/");
|
||||
cy.get(".button").click();
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
cy.setCookie("forceLanguage", "en");
|
||||
})
|
||||
|
||||
it('Write wrong DB pwd and user', function () {
|
||||
cy.get("input[name='dbname']")
|
||||
.clear()
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
module.exports = (on, config) => {
|
||||
on('before:browser:launch', (browser = {}, launchOptions) => {
|
||||
//console.log(launchOptions) // print all current args
|
||||
|
||||
if (browser.family === 'chromium' && browser.name !== 'electron') {
|
||||
launchOptions.preferences.default.intl = { accept_languages: "en" }
|
||||
}
|
||||
|
||||
if (browser.family === 'firefox') {
|
||||
launchOptions.preferences['intl.accept_languages'] = 'en'
|
||||
}
|
||||
|
||||
if (browser.name === 'electron') {
|
||||
launchOptions.args.push('--lang=en')
|
||||
launchOptions.preferences.darkTheme = true
|
||||
}
|
||||
|
||||
return launchOptions
|
||||
})
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
Cypress.Commands.add("login", (username="admin", password="correcthorsebatterystaple") => {
|
||||
cy.server().route('GET', '/resources/ajax/ajax_*').as('ajax');
|
||||
cy.visit("/");
|
||||
cy.getCookie('acceptCookies')
|
||||
.then((c) => {
|
||||
if(c == undefined) cy.get(".acceptcookies").click({force: true})
|
||||
})
|
||||
cy.get("input[name='name']")
|
||||
.clear()
|
||||
.type(username)
|
||||
.should('have.value', username)
|
||||
|
||||
cy.get("input[name='password']")
|
||||
.clear()
|
||||
.type(password)
|
||||
.should('have.value', password)
|
||||
|
||||
cy.get("input[name='login']").click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("getApiKey", (username="admin", password="correcthorsebatterystaple") => {
|
||||
cy.request({ method: 'POST', url: '/api.php/login', form: true, body: { username: username, password: password }})
|
||||
.then((response) => {
|
||||
expect(response.status).to.eq(200)
|
||||
expect(response.body).to.have.property('apiKey')
|
||||
console.log(response.body)
|
||||
return response.body.apiKey
|
||||
})
|
||||
})
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@ -1,17 +1,32 @@
|
|||
// ***********************************************************
|
||||
// This example support/index.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
|
||||
// ***********************************************************
|
||||
//TODO: login remember me and better language support
|
||||
Cypress.Commands.add("login", (username="admin", password="correcthorsebatterystaple") => {
|
||||
cy.setCookie("forceLanguage", "en");
|
||||
cy.reload()
|
||||
cy.server().route('GET', '/resources/ajax/ajax_*').as('ajax');
|
||||
cy.visit("/");
|
||||
cy.getCookie('acceptCookies')
|
||||
.then((c) => {
|
||||
if(c == undefined) cy.get(".acceptcookies").click({force: true})
|
||||
})
|
||||
cy.get("input[name='name']")
|
||||
.clear()
|
||||
.type(username)
|
||||
.should('have.value', username)
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
cy.get("input[name='password']")
|
||||
.clear()
|
||||
.type(password)
|
||||
.should('have.value', password)
|
||||
|
||||
cy.get("input[name='login']").click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add("getApiKey", (username="admin", password="correcthorsebatterystaple") => {
|
||||
cy.request({ method: 'POST', url: '/api.php/login', form: true, body: { username: username, password: password }})
|
||||
.then((response) => {
|
||||
expect(response.status).to.eq(200)
|
||||
expect(response.body).to.have.property('apiKey')
|
||||
console.log(response.body)
|
||||
return response.body.apiKey
|
||||
})
|
||||
})
|
|
@ -39,7 +39,9 @@ foreach($client_languages as $tmp_language){
|
|||
$language = $tmp_language;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_COOKIE["forceLanguage"]) && in_array($_COOKIE["forceLanguage"], $loaded_languages)){
|
||||
$language = $_COOKIE["forceLanguage"];
|
||||
}
|
||||
if (file_exists("translations/".$language.".php")) {
|
||||
$loaded_translations = include "translations/".$language.".php";
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue