Skip to content

Commit

Permalink
Move API system tests to cypress (joomla#40135)
Browse files Browse the repository at this point in the history
* tests

* api

* artiucles crud

* banners

* contact

* media

* media

* Remove codeception

* cs

* more traces of codeception

* readd certs

* dependencies

* more deps

* secret

* cs

* better doc

* write

* config workaround

* cs

* revert

* prepare db for api tests

* variable

* revert pool

* end connections

* no limit

* cs

* prefix

* Update tests/cypress/drone-system-run.sh

* run specific specs in drone

* Update tests/README.md

Co-authored-by: Brian Teeman <[email protected]>

* Update tests/cypress/integration/api/com_media/Files.cy.js

Co-authored-by: Brian Teeman <[email protected]>

* Update tests/cypress/integration/api/com_media/Files.cy.js

Co-authored-by: Brian Teeman <[email protected]>

* postgres

* media on postgres

* sign

* cs

* remove more traces

* basic api tests

* cleanup

* path

* run recursive specs

* chmod images folder

* path to cms

* correct dependencies and better cleanup

* cleaner deps

* Update tests/cypress/drone-system-run.sh

Co-authored-by: Brian Teeman <[email protected]>

* missing fields

* stabilize cleanup

* cs

* secret in install test

* order of tests

* optimize cleanup

* cs

* cache the connection

* revert connection cache

* docs

* Rename cypress to system

* lint

* simplification and docs

* docs

* better cleanup

* move

* merge conflict

* remove redundant connect

---------

Co-authored-by: Brian Teeman <[email protected]>
  • Loading branch information
laoneo and brianteeman authored Mar 20, 2023
1 parent d3ba9d5 commit 7611824
Show file tree
Hide file tree
Showing 102 changed files with 1,716 additions and 9,546 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ services:
before_test:
# Run openldap docker image
- ps: docker pull bitnami/openldap:2.6.3
- ps: docker run --rm --name openldap --publish 1389:1389 --publish 1636:1636 -v ${pwd}\tests\Codeception\_data\certs:/certificates --env LDAP_ADMIN_USERNAME=admin --env LDAP_ADMIN_PASSWORD=adminpassword --env LDAP_USERS=customuser --env LDAP_PASSWORDS=custompassword --env LDAP_ENABLE_TLS=yes --env LDAP_TLS_CERT_FILE=/certificates/openldap.crt --env LDAP_TLS_KEY_FILE=/certificates/openldap.key --env LDAP_TLS_CA_FILE=/certificates/CA.crt --env BITNAMI_DEBUG=true --env LDAP_CONFIG_ADMIN_ENABLED=yes --env LDAP_CONFIG_ADMIN_USERNAME=admin --env LDAP_CONFIG_ADMIN_PASSWORD=configpassword -d bitnami/openldap:2.6.3
- ps: docker run --rm --name openldap --publish 1389:1389 --publish 1636:1636 -v ${pwd}\tests\certs:/certificates --env LDAP_ADMIN_USERNAME=admin --env LDAP_ADMIN_PASSWORD=adminpassword --env LDAP_USERS=customuser --env LDAP_PASSWORDS=custompassword --env LDAP_ENABLE_TLS=yes --env LDAP_TLS_CERT_FILE=/certificates/openldap.crt --env LDAP_TLS_KEY_FILE=/certificates/openldap.key --env LDAP_TLS_CA_FILE=/certificates/CA.crt --env BITNAMI_DEBUG=true --env LDAP_CONFIG_ADMIN_ENABLED=yes --env LDAP_CONFIG_ADMIN_USERNAME=admin --env LDAP_CONFIG_ADMIN_PASSWORD=configpassword -d bitnami/openldap:2.6.3
# Database setup for MySQL via PowerShell tools
- >
"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql" -u root -p"Password12!" -e "CREATE DATABASE IF NOT EXISTS test_joomla;"
Expand Down
72 changes: 14 additions & 58 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ steps:
- name: certificates
path: /certificates
commands:
- cp -v tests/Codeception/_data/certs/* /certificates/
- cp -v tests/certs/* /certificates/

- name: composer
image: joomlaprojects/docker-images:php8.2
Expand Down Expand Up @@ -179,6 +179,7 @@ steps:
image: node:current-alpine
commands:
- npm run lint:js
- npm run lint:testjs

- name: prepare_system_tests
depends_on:
Expand All @@ -188,75 +189,33 @@ steps:
- name: cypress-cache
path: /root/.cache/Cypress
commands:
- sed -i 's/tests\\/Codeception\\/_output/\\/drone\\/src\\/tests\\/cypress\\/output/' codeception.yml
- mv cypress.config.dist.js cypress.config.js
- php libraries/vendor/bin/codecept build
- npx cypress install
- npx cypress verify

- name: phpmin-api-mysql
depends_on:
- prepare_system_tests
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-api-run.sh "$(pwd)" mysql mysqli mysql jos_

- name: phpmin-api-postgres
depends_on:
- prepare_system_tests
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-api-run.sh "$(pwd)" postgres pgsql postgres jos_

- name: phpmax-api-mysql
depends_on:
- phpmin-api-mysql
- phpmin-api-postgres
image: joomlaprojects/docker-images:systemtests8.1
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-api-run.sh "$(pwd)" mysqlphpmax mysqli mysql phpmax_

- name: phpmax-api-postgres
depends_on:
- phpmin-api-mysql
- phpmin-api-postgres
image: joomlaprojects/docker-images:systemtests8.1
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-api-run.sh "$(pwd)" postgresphpmax pgsql postgres phpmax_

- name: phpmin-system-mysql
depends_on:
- phpmax-api-mysql
- phpmax-api-postgres
- prepare_system_tests
image: joomlaprojects/docker-images:cypress
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cmysql mysqli mysql
- bash tests/System/drone-system-run.sh "$(pwd)" cmysql mysqli mysql

- name: phpmin-system-postgres
depends_on:
- phpmax-api-mysql
- phpmax-api-postgres
- prepare_system_tests
image: joomlaprojects/docker-images:cypress
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cpostgres pgsql postgres
- bash tests/System/drone-system-run.sh "$(pwd)" cpostgres pgsql postgres

- name: phpmax-system-mysql
depends_on:
Expand All @@ -269,7 +228,7 @@ steps:
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cmysqlmax mysqli mysql
- bash tests/System/drone-system-run.sh "$(pwd)" cmysqlmax mysqli mysql

- name: phpmax-system-postgres
depends_on:
Expand All @@ -282,7 +241,7 @@ steps:
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cpostgresmax pgsql postgres
- bash tests/System/drone-system-run.sh "$(pwd)" cpostgresmax pgsql postgres

- name: phpmin-system-mysql8
depends_on:
Expand All @@ -295,19 +254,20 @@ steps:
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cmysql8 mysqli mysql8
- bash tests/System/drone-system-run.sh "$(pwd)" cmysql8 mysqli mysql8

- name: phpmax-system-mysql8
depends_on:
- phpmin-system-mysql8
- phpmax-system-mysql
- phpmax-system-postgres
image: joomlaprojects/docker-images:cypress8.1
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/cypress/drone-system-run.sh "$(pwd)" cmysql8max mysqli mysql8
- bash tests/System/drone-system-run.sh "$(pwd)" cmysql8max mysqli mysql8

- name: artifacts-system-tests
image: joomlaprojects/docker-images:packager
Expand All @@ -318,10 +278,6 @@ steps:
- phpmin-system-mysql
- phpmin-system-mysql8
- phpmin-system-postgres
- phpmax-api-mysql
- phpmax-api-postgres
- phpmin-api-mysql
- phpmin-api-postgres
environment:
FTP_USERNAME:
from_secret: ftpusername
Expand All @@ -334,7 +290,7 @@ steps:
- echo https://ci.joomla.org$PLUGIN_DEST_DIR
- rclone config create artifacts ftp host ci.joomla.org user $FTP_USERNAME port 21 pass $FTP_PASSWORD
- rclone mkdir artifacts:$PLUGIN_DEST_DIR
- rclone copy tests/cypress/output/ artifacts:$PLUGIN_DEST_DIR
- rclone copy tests/System/output/ artifacts:$PLUGIN_DEST_DIR
- 'curl -X POST "https://api.github.com/repos/$DRONE_REPO/statuses/$DRONE_COMMIT" -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" -d "{\"state\":\"failure\", \"context\": \"Artifacts from Failure\", \"description\": \"You can find artifacts from the failure of the build here:\", \"target_url\": \"https://ci.joomla.org$PLUGIN_DEST_DIR\"}" > /dev/null'
when:
status:
Expand Down Expand Up @@ -497,6 +453,6 @@ trigger:

---
kind: signature
hmac: bc89776fce23d7ca29c126a409bdd18297409fecdffe3cd0b196273e4511b6c8
hmac: 3457679ef0cd23bde8dd9900016aba663a279aa0c32049c8e37db56676cadd38

...
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ libraries/src/Updater/* @rdeutz @zero-24

# Automated Testing
tests/* @hackwar
tests/Codeception/* @rdeutz
tests/javascript/* @rdeutz
tests/Unit/* @rdeutz
.appveyor.yml @rdeutz @hackwar
.drone.yml @rdeutz @hackwar
codeception.yml @rdeutz @hackwar
phpunit.xml.dist @rdeutz @hackwar
phpunit-pgsql.xml.dist @rdeutz @hackwar

Expand Down
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@

# Test Related Files
/phpunit.xml
selenium.log
composer.phar
/test-install
/.phpunit.result.cache
/tests/Codeception/acceptance.suite.yml
/tests/Codeception/_output/
/tests/Codeception/api.suite.yml


# Vendor directory handling
Expand Down Expand Up @@ -103,10 +99,10 @@ RoboFile.ini
/media/com_media/css/mediamanager.min.css.map

#cypress
/tests/cypress/output/screenshots
!/tests/cypress/output/screenshots/.gitkeep
/tests/cypress/output/videos
!/tests/cypress/output/videos/.gitkeep
/tests/System/output/screenshots
!/tests/System/output/screenshots/.gitkeep
/tests/System/output/videos
!/tests/System/output/videos/.gitkeep
cypress.config.js

# WebAuthn FIDO metadata cache
Expand Down
4 changes: 4 additions & 0 deletions api/components/com_content/src/View/Articles/JsonapiView.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public function displayItem($item = null)
*/
protected function prepareItem($item)
{
if (!$item) {
return $item;
}

$item->text = $item->introtext . ' ' . $item->fulltext;

// Process the content plugins.
Expand Down
17 changes: 15 additions & 2 deletions build/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,22 @@
},
"overrides": [
{
"files": ["tests/**/*.cy.js"],
"files": ["tests/**/*.js"],
"rules": {
"no-undef": ["off"]
"no-undef": ["off"],
"import/no-extraneous-dependencies": ["off"]
}
},
{
"files": ["tests/System/support/index.js"],
"rules": {
"no-console": ["off"]
}
},
{
"files": ["tests/System/support/commands/db.js","tests/System/plugins/index.js"],
"rules": {
"no-useless-escape": ["off"]
}
}
]
Expand Down
2 changes: 0 additions & 2 deletions build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ function clean_composer(string $dir)
'appveyor-phpunit.xml',
'build',
'build.xml',
'codeception.yml',
'CODE_OF_CONDUCT.md',
'composer.json',
'composer.lock',
Expand All @@ -412,7 +411,6 @@ function clean_composer(string $dir)
'README.md',
'renovate.json',
'ruleset.xml',
'selenium.log',
'tests',
];

Expand Down
20 changes: 0 additions & 20 deletions codeception.yml

This file was deleted.

32 changes: 12 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"joomla/ldap": "~2.0.0",
"joomla/oauth1": "^2.0.1",
"joomla/oauth2": "^2.0.1",
"joomla/registry": "^2.0.2",
"joomla/registry": "^2.0.4",
"joomla/router": "^2.0.1",
"joomla/session": "^2.0.2",
"joomla/string": "^2.0.1",
Expand All @@ -73,16 +73,16 @@
"google/recaptcha": "^1.2.4",
"laminas/laminas-diactoros": "^2.4.1",
"paragonie/sodium_compat": "^1.19",
"phpmailer/phpmailer": "^6.7.1",
"phpmailer/phpmailer": "^6.8.0",
"psr/link": "~1.0.0",
"symfony/console": "^5.4.19",
"symfony/error-handler": "^5.4.19",
"symfony/ldap": "^5.4.19",
"symfony/options-resolver": "^5.4.19",
"symfony/console": "^5.4.21",
"symfony/error-handler": "^5.4.21",
"symfony/ldap": "^5.4.21",
"symfony/options-resolver": "^5.4.21",
"symfony/polyfill-mbstring": "^1.27.0",
"symfony/polyfill-php73": "^1.27",
"symfony/web-link": "^5.4.19",
"symfony/yaml": "^5.4.19",
"symfony/web-link": "^5.4.21",
"symfony/yaml": "^5.4.21",
"typo3/phar-stream-wrapper": "^3.1.7",
"wamania/php-stemmer": "^2.2",
"maximebf/debugbar": "dev-master",
Expand All @@ -99,25 +99,17 @@
"lcobucci/jwt": "^3.4.6",
"web-token/signature-pack": "^2.2.11",
"phpseclib/bcmath_compat": "^2.0.1",
"jfcherng/php-diff": "^6.10.10",
"jfcherng/php-diff": "^6.10.11",
"voku/portable-utf8": "6.0.12 as 5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5.32",
"phpunit/phpunit": "^8.5.33",
"friendsofphp/php-cs-fixer": "^3.4.0",
"squizlabs/php_codesniffer": "^3.7.1",
"joomla-projects/joomla-browser": "~4.0.0",
"codeception/codeception": "^4.2.2",
"squizlabs/php_codesniffer": "^3.7.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"joomla/mediawiki": "^1.0.0",
"joomla/test": "^2.0.2",
"codeception/module-asserts": "^1.3.1",
"codeception/module-db": "^1.2",
"codeception/module-rest": "^1.4.2",
"codeception/module-webdriver": "^1.4.1",
"codeception/module-phpbrowser": "^1.0.3",
"hoa/console": "^3.17.05.02",
"phan/phan": "^5.4.1"
"phan/phan": "^5.4.2"
},
"replace": {
"paragonie/random_compat": "9.99.99"
Expand Down
Loading

0 comments on commit 7611824

Please sign in to comment.