Skip to content

Commit

Permalink
Correct settings.py & tags.py selenium tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 authored and josaphatim committed Sep 30, 2024
1 parent 6e7caa1 commit 17a07d1
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 172 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ DEFAULT_SETTING_UNREAD_EXCLUDE_WORDPRESS=false
DEFAULT_SETTING_WORDPRESS_SINCE='-1 week'
DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB=false
DEFAULT_SETTING_GITHUB_LIMIT=20
DEFAULT_SETTING_GITHUB_SINCE='-1 weeks'
DEFAULT_SETTING_GITHUB_SINCE='-1 week'
DEFAULT_SETTING_INLINE_MESSAGE=false
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=1
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=false
DEFAULT_SETTING_ENABLE_SIEVE_FILTER=false


Expand Down Expand Up @@ -199,7 +199,7 @@ WORDPRESS_CLIENT_URI=
RECAPTCHA_SECRET=
RECAPTCHA_SITE_KEY=

CYPHT_MODULES="core,contacts,local_contacts,ldap_contacts,gmail_contacts,feeds,jmap,imap,smtp,account,idle_timer,desktop_notifications,calendar,themes,nux,developer,profiles,imap_folders,sievefilters"
CYPHT_MODULES="core,contacts,local_contacts,ldap_contacts,gmail_contacts,feeds,jmap,imap,smtp,account,idle_timer,desktop_notifications,calendar,themes,nux,developer,profiles,imap_folders,sievefilters,tags"

#LoginPage
FANCY_LOGIN=false
Expand Down
8 changes: 4 additions & 4 deletions .github/tests/.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DEFAULT_SMTP_NO_AUTH=

USER_CONFIG_TYPE=DB
USER_SETTINGS_DIR=/tmp
ATTACHMENT_DIR=/tmp
ATTACHMENT_DIR=

ADMIN_USERS=

Expand Down Expand Up @@ -123,9 +123,9 @@ DEFAULT_SETTING_UNREAD_EXCLUDE_WORDPRESS=false
DEFAULT_SETTING_WORDPRESS_SINCE='-1 week'
DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB=false
DEFAULT_SETTING_GITHUB_LIMIT=20
DEFAULT_SETTING_GITHUB_SINCE='-1 weeks'
DEFAULT_SETTING_GITHUB_SINCE='-1 week'
DEFAULT_SETTING_INLINE_MESSAGE=false
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=1
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=false
DEFAULT_SETTING_ENABLE_SIEVE_FILTER=false


Expand Down Expand Up @@ -182,4 +182,4 @@ WORDPRESS_CLIENT_URI=

RECAPTCHA_SECRET=
RECAPTCHA_SITE_KEY=
CYPHT_MODULES="core,contacts,local_contacts,feeds,imap,smtp,account,idle_timer,calendar,themes,nux,history,saved_searches,advanced_search,profiles,inline_message,imap_folders,keyboard_shortcuts,tags"
CYPHT_MODULES="core,contacts,local_contacts,ldap_contacts,gmail_contacts,feeds,jmap,imap,smtp,account,idle_timer,desktop_notifications,calendar,themes,nux,developer,history,profiles,imap_folders,sievefilters,tags,pgp,inline_message,keyboard_shortcuts,github,wordpress"
6 changes: 6 additions & 0 deletions .github/tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ setup_cypht() {
sed -i 's/mysql/sqlite/' tests/phpunit/mocks.php
sed -i "s/'host'/'socket'/" tests/phpunit/mocks.php
fi

sed -i "s|ATTACHMENT_DIR=.*|ATTACHMENT_DIR=$(pwd)/hm3/attachments|" .env
php scripts/config_gen.php
}

# Create and populate database for phpunit tests
Expand Down Expand Up @@ -132,6 +135,9 @@ setup_site() {
STATUS_ERROR
exit 1
fi
STATUS_TITLE "Setup required Directories"
mkdir -p "$(pwd)/hm3/attachments"
STATUS_DONE
}

##### UI END #####
Expand Down
135 changes: 67 additions & 68 deletions .github/workflows/Test-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,78 @@ on:
workflow_dispatch:

jobs:
Test-phpunit:
name: PHPUNIT (PHP-${{ matrix.php-versions }} && DB-${{ matrix.database }})
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.1']
database: ['mysql', 'postgres', 'sqlite']

env:
PHP_V: ${{ matrix.php-versions }}
DB: ${{ matrix.database }}
TEST_ARG: 'phpunit'

services:
mysql:
image: mysql:latest
env:
MYSQL_ROOT_PASSWORD: cypht_test
MYSQL_DATABASE: cypht_test
MYSQL_USER: cypht_test
MYSQL_PASSWORD: cypht_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

postgresql:
image: postgres:latest
env:
POSTGRES_USER: cypht_test
POSTGRES_PASSWORD: cypht_test
POSTGRES_DB: cypht_test
ports:
- 5432:5432
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: "System Install Dependencies"
run: sudo apt-get install -y mysql-client postgresql-client sqlite3 libsodium-dev

- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Set up PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: pdo, sodium, sqlite, pdo_mysql, pdo_pgsql, memcached, redis, gd, gnupg
tools: phpunit, composer
ini-values: cgi.fix_pathinfo=1
env:
fail-fast: true

- name: "Script: setup.sh"
run: bash .github/tests/setup.sh

- name: "Composer Install Dependencies"
run: |
composer install
composer require --dev php-coveralls/php-coveralls
php scripts/config_gen.php
- name: "Script: test.sh"
run: bash .github/tests/test.sh
# Test-phpunit:
# name: PHPUNIT (PHP-${{ matrix.php-versions }} && DB-${{ matrix.database }})
# runs-on: ubuntu-latest

# strategy:
# matrix:
# php-versions: ['8.1']
# database: ['mysql', 'postgres', 'sqlite']

# env:
# PHP_V: ${{ matrix.php-versions }}
# DB: ${{ matrix.database }}
# TEST_ARG: 'phpunit'

# services:
# mysql:
# image: mysql:latest
# env:
# MYSQL_ROOT_PASSWORD: cypht_test
# MYSQL_DATABASE: cypht_test
# MYSQL_USER: cypht_test
# MYSQL_PASSWORD: cypht_test
# ports:
# - 3306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

# postgresql:
# image: postgres:latest
# env:
# POSTGRES_USER: cypht_test
# POSTGRES_PASSWORD: cypht_test
# POSTGRES_DB: cypht_test
# ports:
# - 5432:5432
# options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3

# steps:
# - name: "System Install Dependencies"
# run: sudo apt-get install -y mysql-client postgresql-client sqlite3 libsodium-dev

# - name: "Checkout code"
# uses: actions/checkout@v4
# with:
# fetch-depth: 0

# - name: "Set up PHP"
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.php-versions }}
# extensions: pdo, sodium, sqlite, pdo_mysql, pdo_pgsql, memcached, redis, gd, gnupg
# tools: phpunit, composer
# ini-values: cgi.fix_pathinfo=1
# env:
# fail-fast: true

# - name: "Script: setup.sh"
# run: bash .github/tests/setup.sh

# - name: "Composer Install Dependencies"
# run: |
# composer install
# composer require --dev php-coveralls/php-coveralls
# php scripts/config_gen.php

# - name: "Script: test.sh"
# run: bash .github/tests/test.sh


Test-selenium:
name: SELENIUM (PHP-${{ matrix.php-versions }} && DB-${{ matrix.database }})
runs-on: ubuntu-latest
needs: Test-phpunit
# needs: Test-phpunit

strategy:
matrix:
Expand Down Expand Up @@ -133,7 +133,6 @@ jobs:
- name: "Composer Install Dependencies"
run: |
composer install
php scripts/config_gen.php
- name: "Script: setup.sh"
run: bash .github/tests/setup.sh
Expand Down
2 changes: 1 addition & 1 deletion .travis/.env
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ DEFAULT_SETTING_UNREAD_EXCLUDE_GITHUB=false
DEFAULT_SETTING_GITHUB_LIMIT=20
DEFAULT_SETTING_GITHUB_SINCE='-1 weeks'
DEFAULT_SETTING_INLINE_MESSAGE=false
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=1
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=false
DEFAULT_SETTING_ENABLE_SIEVE_FILTER=false


Expand Down
4 changes: 2 additions & 2 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@
| Handles page layout, login/logout, and the default settings pages. This set
| is required.
*/
'modules' => explode(',', env('CYPHT_MODULES','core,contacts,local_contacts,feeds,imap,smtp,account,idle_timer,calendar,themes,nux,developer,history,saved_searches,advanced_search,highlights,profiles,inline_message,imap_folders,keyboard_shortcuts')),
'modules' => explode(',', env('CYPHT_MODULES','core,contacts,local_contacts,feeds,imap,smtp,account,idle_timer,calendar,themes,nux,developer,history,saved_searches,advanced_search,highlights,profiles,inline_message,imap_folders,keyboard_shortcuts,tags')),
// 'modules' => [
// /*
// | ----
Expand Down Expand Up @@ -1295,7 +1295,7 @@
| Enable keyboard shortcuts
| Defaults to false
*/
'default_setting_enable_keyboard_shortcuts' => env('DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS', 1),
'default_setting_enable_keyboard_shortcuts' => env('DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS', false),

/*
|
Expand Down
2 changes: 1 addition & 1 deletion lib/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function define_default_constants($config) {
define('DEFAULT_GITHUB_SINCE', $config->get('default_setting_github_since', '-1 week'));
define('DEFAULT_INLINE_MESSAGE', $config->get('default_setting_inline_message', false));
define('DEFAULT_INLINE_MESSAGE_STYLE', $config->get('default_setting_inline_message_style', 'right'));
define('DEFAULT_ENABLE_KEYBOARD_SHORTCUTS', $config->get('default_setting_enable_keyboard_shortcuts', 1));
define('DEFAULT_ENABLE_KEYBOARD_SHORTCUTS', false);
define('DEFAULT_ENABLE_SIEVE_FILTER', $config->get('default_setting_enable_sieve_filter', false));
}

Expand Down
13 changes: 4 additions & 9 deletions modules/keyboard_shortcuts/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ var ks_follow_link = function(target) {
};

var ks_redirect = function(target) {
document.location.href = target;
Hm_Utils.redirect(target);
};

var ks_select_all = function() {
Hm_Message_List.toggle_rows();
};
}; 

var ks_select_msg = function() {
var focused = $(document.activeElement);
$('input', focused).each(function() {
if ($(this).prop('checked')) {
$(this).prop('checked', false);
$(this).prop('checked', false); 
}
else {
$(this).prop('checked', true);
Expand Down Expand Up @@ -153,13 +153,8 @@ var Keyboard_Actions = {
};

$(function() {

if (typeof shortcuts != 'undefined') {
$(document).on('keydown', ':not(input)', function(e) { return Keyboard_Shortcuts.check(e, shortcuts); });
}
if (hm_page_name() == 'shortcuts') {
$('.reset_shortcut').on("click", function() {
Hm_Utils.redirect('?page=shortcuts');
});
}
});

2 changes: 1 addition & 1 deletion modules/ldap_contacts/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ protected function output() {
$auths = $this->get('ldap_contacts_auth', array());
if (count($connections) > 0) {
$res = '<tr><td data-target=".ldap_settings" colspan="2" class="settings_subtitle cursor-pointer border-bottom p-2">'.
'<i class="bi bi-people-fill"></i>'.
'<i class="bi bi-people-fill fs-5 me-2"></i>'.
$this->trans('LDAP Addressbooks').'</td></tr>';
foreach ($connections as $name => $con) {
$user = '';
Expand Down
3 changes: 3 additions & 0 deletions modules/smtp/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@ class Hm_Output_attachment_setting extends Hm_Output_Module {
protected function output() {
$size_in_kbs = 0;
$num_chunks = 0;
if (!is_dir($this->get('attachment_dir'))) {
return;
}
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->get('attachment_dir')));
$files = array();

Expand Down
18 changes: 10 additions & 8 deletions tests/selenium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class WebTest:
def __init__(self, cap=None):
self.read_ini()
self.driver = get_driver(cap)
# Change the window size to make sure all elements are visible
current_size = self.driver.get_window_size()
new_height = 5000
self.driver.set_window_size(current_size['width'], new_height)
self.browser = False
if 'browserName' in self.driver.capabilities:
self.browser = self.driver.capabilities['browserName'].lower()
Expand All @@ -34,14 +38,12 @@ def read_ini(self):
self.modules = []
self.servers = 1
self.auth_type = ''
config_files = glob.glob('../../config/*.php')
for file_path in config_files:
result = subprocess.run(['php', 'get_config.php'], stdout=subprocess.PIPE)
config_dict = json.loads(result.stdout.decode())
if 'modules' in config_dict and isinstance(config_dict['modules'], list):
self.modules += config_dict['modules']
if 'auth_type' in config_dict:
self.auth_type = config_dict['auth_type']
result = subprocess.run(['php', 'get_config.php'], stdout=subprocess.PIPE)
config_dict = json.loads(result.stdout.decode())
if 'modules' in config_dict and isinstance(config_dict['modules'], list):
self.modules += config_dict['modules']
if 'auth_type' in config_dict:
self.auth_type = config_dict['auth_type']

def load(self):
print(" - loading site")
Expand Down
11 changes: 10 additions & 1 deletion tests/selenium/get_config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?php

define('APP_PATH', dirname(dirname(dirname(__FILE__))).'/');

require '../../vendor/autoload.php';
require '../../lib/environment.php';
require '../../lib/framework.php';
$environment = Hm_Environment::getInstance();
$environment->load();

/* get config object */
$config = new Hm_Site_Config_File();
/* set the default since and per_source values */
$environment->define_default_constants($config);
$config = merge_config_files('../../config');

echo json_encode($config);
Loading

0 comments on commit 17a07d1

Please sign in to comment.