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 25, 2024
1 parent 6e7caa1 commit 6a4e7ca
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 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 @@ -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"
5 changes: 5 additions & 0 deletions .github/tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ 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
}

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

##### UI END #####
Expand Down
134 changes: 67 additions & 67 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
2 changes: 1 addition & 1 deletion 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
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
14 changes: 6 additions & 8 deletions tests/selenium/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,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);
7 changes: 2 additions & 5 deletions tests/selenium/runall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
PYTHON=$(command -v python3)
rm -rf __pycache__/

#for suite in login.py folder_list.py pages.py profiles.py settings.py servers.py send.py inline_msg.py search.py keyboard_shortcuts.py
#for suite in login.py folder_list.py pages.py profiles.py settings.py servers.py send.py inline_msg.py search.py
# for suite in login.py folder_list.py pages.py servers.py settings.py send.py inline_msg.py search.py tags.py
for suite in login.py folder_list.py pages.py servers.py profiles.py send.py search.py
# for suite in pages.py servers.py settings.py send.py inline_msg.py search.py
#inline_msg.py keyboard_shortcuts.py
for suite in settings.py folder_list.py pages.py servers.py profiles.py send.py search.py tags.py
do
export TEST_SUITE="$suite"
"$PYTHON" -u ./$suite
Expand Down
Loading

0 comments on commit 6a4e7ca

Please sign in to comment.