Adding minimal setup to run cypress tests

This commit is contained in:
Hannes Papenberg 2023-05-18 17:38:28 +02:00
parent 40420a4914
commit 5de0f2d32f
13 changed files with 1405 additions and 1112 deletions

View File

@ -9,7 +9,7 @@ steps:
- name: composer-cache - name: composer-cache
path: /tmp/composer-cache path: /tmp/composer-cache
commands: commands:
- composer install --no-progress --no-suggest - composer install --no-progress
- name: npm - name: npm
image: node:16-bullseye-slim image: node:16-bullseye-slim
@ -34,7 +34,7 @@ steps:
- npx cypress install - npx cypress install
- npx cypress verify - npx cypress verify
- vendor/bin/robo build - vendor/bin/robo build
- wget -o joomla.zip https://joomla.org/latest - curl https://joomla.org/latest -L --output joomla.zip
- name: phpmin-system-mysql - name: phpmin-system-mysql
depends_on: depends_on:
@ -45,52 +45,17 @@ steps:
path: /root/.cache/Cypress path: /root/.cache/Cypress
commands: commands:
- mkdir /tests/www/mysql/ - mkdir /tests/www/mysql/
- cp joomla.zip /tests/www/mysql/ - cp joomla.zip /tests/www/mysql/joomla.zip
- cp dist/pkg-weblinks-current.zip /tests/www/mysql/pkg-weblinks-current.zip
- cd /tests/www/mysql/ - cd /tests/www/mysql/
- unzip joomla.zip - unzip joomla.zip
- apache2ctl -D FOREGROUND & - apache2ctl -D FOREGROUND &
- chmod +rwx /root - chmod +rwx /root
- php installation/joomla.php install --verbose --site-name="Joomla CMS test" --admin-email=admin@example.org --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=mysqli --db-host=mysql --db-name=test_joomla --db-pass=joomla_ut --db-user=root --db-encryption=0 --db-prefix=mysql_ - php installation/joomla.php install --verbose --site-name="Joomla CMS test" --admin-email=admin@example.org --admin-username=ci-admin --admin-user="jane doe" --admin-password=joomla-17082005 --db-type=mysqli --db-host=mysql --db-name=test_joomla --db-pass=joomla_ut --db-user=root --db-encryption=0 --db-prefix=mysql_
- php cli/joomla.php config:set debug=true error_reporting=maximum
- php cli/joomla.php extension:install --path=/tests/www/mysql/pkg-weblinks-current.zip
- npx cypress run --browser=firefox --e2e --config baseUrl=http://localhost/mysql,screenshotsFolder=/drone/src/tests/cypress/output/screenshots - npx cypress run --browser=firefox --e2e --config baseUrl=http://localhost/mysql,screenshotsFolder=/drone/src/tests/cypress/output/screenshots
- name: weblinks-codeception-tests
image: joomlaprojects/docker-images:systemtests
commands:
- pwd
- composer install
- chmod a+x .drone/build.sh
- ./.drone/build.sh
- apache2ctl start
- service mysql start
- cd /tests/www
- export DISPLAY=:0
- Xvfb -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
- sleep 3
- fluxbox > /dev/null 2>&1 &
- vendor/bin/robo run:tests
- name: artifacts-codeception-tests
image: cschlosser/drone-ftps
depends_on: [ weblinks-codeception-tests ]
environment:
FTP_USERNAME:
from_secret: ftpusername
FTP_PASSWORD:
from_secret: ftppassword
PLUGIN_HOSTNAME: artifacts.joomla.org:21
PLUGIN_SRC_DIR: /tests/_output
PLUGIN_DEST_DIR: /
PLUGIN_SECURE: false
PLUGIN_EXCLUDE: ^\.git/$
commands:
- ls -l /drone/src/tests/_output
- export PLUGIN_DEST_DIR=$PLUGIN_DEST_DIR/$DRONE_REPO/$DRONE_BRANCH/$DRONE_PULL_REQUEST/system-tests/$DRONE_BUILD_NUMBER
- echo https://artifacts.joomla.org/drone$PLUGIN_DEST_DIR
- /bin/upload.sh
when:
status:
- failure
volumes: volumes:
- name: weblinks_cache - name: weblinks_cache
host: host:
@ -134,6 +99,6 @@ services:
--- ---
kind: signature kind: signature
hmac: bcc028d5d9601f1f3355862f17dd2434ba86f47634f0737877db534e49c8265b hmac: 75d22d8b741def46eb475a2fd9b50483b8c938e81de478ecacbf1bfd57782c5c
... ...

137
.gitignore vendored
View File

@ -1,64 +1,73 @@
# Builds # Builds
build build
releases releases
# OSX # OSX
.DS_Store .DS_Store
._* ._*
.Spotlight-V100 .Spotlight-V100
.Trashes .Trashes
# Windows # Windows
Thumbs.db Thumbs.db
Desktop.ini Desktop.ini
# PHPStorm # PHPStorm
.idea/ .idea/
# Sublime Text # Sublime Text
*.sublime* *.sublime*
# Eclipse # Eclipse
.buildpath .buildpath
.project .project
.settings .settings
# Temp files # Temp files
*.tmp *.tmp
*.bak *.bak
*.swp *.swp
*~.nib *~.nib
*~ *~
# Phing # Phing
build.properties build.properties
phing-latest.phar phing-latest.phar
# Github pages and Jekyll files # Github pages and Jekyll files
/_site/ /_site/
/Gemfile /Gemfile
/Gemfile.lock /Gemfile.lock
# composer # composer
composer.phar composer.phar
vendor/* vendor/*
# Robo # Robo
robo.phar robo.phar
RoboFile.ini RoboFile.ini
# Test related files # Test related files
tests/acceptance.suite.yml tests/acceptance.suite.yml
tests/*/*Tester.php tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php tests/_support/_generated/*TesterActions.php
tests/joomla* tests/joomla*
tests/_output* tests/_output*
selenium-server-standalone.jar selenium-server-standalone.jar
codecept.phar codecept.phar
selenium.log selenium.log
tests/cache tests/cache
# Package building related #cypress
/dist node_modules
jorobo.ini /tests/cypress/output/screenshots
!/tests/cypress/output/screenshots/.gitkeep
/tests/cypress/output/videos
!/tests/cypress/output/videos/.gitkeep
cypress.config.js
joomla
# Package building related
/dist
jorobo.ini

View File

@ -4,20 +4,19 @@
"license" : "GPL-2.0+", "license" : "GPL-2.0+",
"config": { "config": {
"platform": { "platform": {
"php": "7.2.0" "php": "7.2.5"
} }
}, },
"require" : { "require" : {
"php": ">=7.2" "php": ">=7.2.5|~8"
}, },
"require-dev": { "require-dev": {
"behat/gherkin": "^4.4.1", "behat/gherkin": "^4.4.1",
"codeception/codeception": "^4.1", "codeception/codeception": "^4.1",
"consolidation/robo": "^1.0.0",
"fzaninotto/faker": "^1.6", "fzaninotto/faker": "^1.6",
"joomla-projects/joomla-browser": "^4.0", "joomla-projects/joomla-browser": "^4.0",
"joomla-projects/joomla-testing-robo": "~1.0", "joomla-projects/joomla-testing-robo": "~1.0",
"joomla-projects/jorobo": "^0.7.6", "joomla-projects/jorobo": "dev-develop",
"joomla-projects/selenium-server-standalone": "^3.14", "joomla-projects/selenium-server-standalone": "^3.14",
"phpunit/phpunit": "^5.7.27", "phpunit/phpunit": "^5.7.27",
"codeception/module-filesystem": "^1.0", "codeception/module-filesystem": "^1.0",

2000
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,69 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.5" method="upgrade"> <extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name> <name>com_weblinks</name>
<author>Joomla! Project</author> <element>com_weblinks</element>
<creationDate>##DATE##</creationDate> <author>Joomla! Project</author>
<copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright> <creationDate>##DATE##</creationDate>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> <copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright>
<authorEmail>admin@joomla.org</authorEmail> <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorUrl>www.joomla.org</authorUrl> <authorEmail>admin@joomla.org</authorEmail>
<version>##VERSION##</version> <authorUrl>www.joomla.org</authorUrl>
<description>COM_WEBLINKS_XML_DESCRIPTION</description> <version>##VERSION##</version>
<scriptfile>script.php</scriptfile> <description>COM_WEBLINKS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Component\Weblinks</namespace> <scriptfile>script.php</scriptfile>
<namespace path="src">Joomla\Component\Weblinks</namespace>
<install>
<sql> <install>
<file charset="utf8" driver="mysql">sql/install.mysql.sql</file> <sql>
<file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file> <file charset="utf8" driver="mysql">sql/install.mysql.sql</file>
</sql> <file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file>
</install> </sql>
<uninstall> </install>
<sql> <uninstall>
<file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file> <sql>
<file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file> <file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file>
</sql> <file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file>
</uninstall> </sql>
<update> </uninstall>
<schemas> <update>
<schemapath type="mysql">sql/updates/mysql</schemapath> <schemas>
<schemapath type="postgresql">sql/updates/postgresql</schemapath> <schemapath type="mysql">sql/updates/mysql</schemapath>
</schemas> <schemapath type="postgresql">sql/updates/postgresql</schemapath>
</update> </schemas>
</update>
<media folder="media/com_weblinks" destination="com_weblinks">
##MEDIA_FILES## <media folder="media/com_weblinks" destination="com_weblinks">
</media> ##MEDIA_FILES##
</media>
<files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES## <files folder="components/com_weblinks">
</files> ##FRONTEND_COMPONENT_FILES##
<languages folder="language"> </files>
##FRONTEND_LANGUAGE_FILES## <languages folder="language">
</languages> ##FRONTEND_LANGUAGE_FILES##
<administration> </languages>
<menu img="class:weblinks">com_weblinks</menu> <administration>
<submenu> <menu img="class:weblinks">com_weblinks</menu>
<!-- <submenu>
Note that all & must be escaped to &amp; for the file to be valid <!--
XML and be parsed by the installer Note that all & must be escaped to &amp; for the file to be valid
--> XML and be parsed by the installer
<menu link="option=com_weblinks" view="links" img="class:weblinks" -->
alt="Weblinks/Links">com_weblinks_links</menu> <menu link="option=com_weblinks" view="links" img="class:weblinks"
<menu link="option=com_categories&amp;extension=com_weblinks" alt="Weblinks/Links">com_weblinks_links</menu>
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu> <menu link="option=com_categories&amp;extension=com_weblinks"
<menu link="option=com_fields&amp;view=fields&amp;context=com_weblinks.weblink" view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
alt="Weblinks/Fields">com_weblinks_fields</menu> <menu link="option=com_fields&amp;view=fields&amp;context=com_weblinks.weblink"
<menu link="option=com_fields&amp;view=groups&amp;context=com_weblinks.weblink" alt="Weblinks/Fields">com_weblinks_fields</menu>
alt="Weblinks/Field Groups">com_weblinks_field_groups</menu> <menu link="option=com_fields&amp;view=groups&amp;context=com_weblinks.weblink"
</submenu> alt="Weblinks/Field Groups">com_weblinks_field_groups</menu>
<files folder="administrator/components/com_weblinks"> </submenu>
##BACKEND_COMPONENT_FILES## <files folder="administrator/components/com_weblinks">
</files> ##BACKEND_COMPONENT_FILES##
<languages folder="administrator/language"> </files>
##BACKEND_LANGUAGE_FILES## <languages folder="administrator/language">
</languages> ##BACKEND_LANGUAGE_FILES##
</administration> </languages>
</extension> </administration>
</extension>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.5" client="site" method="upgrade"> <extension type="module" version="3.5" client="site" method="upgrade">
<name>mod_weblinks</name> <name>mod_weblinks</name>
<element>mod_weblinks</element>
<author>Joomla! Project</author> <author>Joomla! Project</author>
<creationDate>##DATE##</creationDate> <creationDate>##DATE##</creationDate>
<copyright>Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.</copyright> <copyright>Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.</copyright>

View File

@ -0,0 +1,12 @@
module.exports = {
plugins: [
'cypress',
],
env: {
mocha: true,
'cypress/globals': true,
},
rules: {
strict: 'off',
},
};

View File

View File

@ -0,0 +1,11 @@
// type definitions for Cypress object "cy"
// <reference types="cypress" />
describe('Install Joomla and Weblinks package', () => {
it('Install Joomla and Weblinks package', function () {
cy.doAdministratorLogin(Cypress.env('username'), Cypress.env('password'))
cy.disableStatistics()
cy.setErrorReportingToDevelopment()
cy.doAdministratorLogout()
})
})

View File

View File

View File

@ -0,0 +1,129 @@
Cypress.Commands.add('createContentCategory', (title) => {
cy.visit('administrator/index.php?option=com_categories&view=categories&extension=com_content')
cy.contains('h1', 'Articles: Categories').should('exist')
cy.clickToolbarButton('New')
cy.get('#jform_title').should('exist').type(title)
cy.clickToolbarButton('Save & Close')
// TODO Still need to implement this. Quick fix: we need to refactor the test
//$testCategory = [
// 'title' => $title,
// 'extension' => 'com_content',
//];
//$this->seeInDatabase('categories', $testCategory);
})
Cypress.Commands.add('createField', (type, title) => {
cy.visit('administrator/index.php?option=com_fields&view=fields&context=com_content.article')
cy.clickToolbarButton('New')
cy.get('#jform_title').type(title)
cy.get('#jform_type').select(type)
cy.clickToolbarButton('Save & Close')
cy.get('#system-message-container').contains('Field saved').should('exist')
})
Cypress.Commands.add('trashField', (title, message) => {
cy.visit('administrator/index.php?option=com_fields&view=fields&context=com_content.article')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Action')
cy.clickToolbarButton('Trash')
cy.get('#system-message-container').contains(message).should('exist')
})
Cypress.Commands.add('deleteField', (title, message) => {
cy.visit('administrator/index.php?option=com_fields&view=fields&context=com_content.article')
cy.searchForItem()
cy.get('.js-stools-btn-filter').click()
cy.intercept('index.php*').as('setTrashed')
cy.get('#filter_state').select('Trashed')
cy.wait('@setTrashed')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Empty trash')
cy.get('#system-message-container').contains(message).should('exist')
})
Cypress.Commands.add('createArticle', (articleDetails) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.intercept('index.php?option=com_content&view=article*').as('article_edit')
cy.clickToolbarButton('New')
cy.wait('@article_edit')
cy.get('#jform_title').clear().type(articleDetails.title)
cy.get('#jform_alias').clear().type(articleDetails.alias)
cy.intercept('index.php?option=com_content&view=articles').as('article_list')
cy.clickToolbarButton('Save & Close')
cy.wait('@article_list')
cy.get('#system-message-container').contains('Article saved.').should('exist')
})
Cypress.Commands.add('featureArticle', (title) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Action')
cy.intercept('index.php?option=com_content&view=articles').as('article_feature')
cy.clickToolbarButton('feature')
cy.wait('@article_feature')
cy.get('#system-message-container').contains('Article featured.').should('exist')
})
Cypress.Commands.add('setArticleAccessLevel', (title, accessLevel) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.searchForItem(title)
cy.checkAllResults()
cy.intercept('index.php?option=com_content&view=article*').as('article_access')
cy.get('a').contains(title).click()
cy.wait('@article_access')
cy.get('#jform_access').select(accessLevel)
cy.intercept('index.php?option=com_content&view=article*').as('article_list')
cy.clickToolbarButton('Save & Close')
cy.wait('@article_list')
cy.get('td').contains(accessLevel).should('exist')
})
Cypress.Commands.add('unPublishArticle', (title) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Action')
cy.intercept('index.php?option=com_content&view=articles').as('article_unpublish')
cy.clickToolbarButton('unpublish')
cy.wait('@article_unpublish')
})
Cypress.Commands.add('publishArticle', (title) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Action')
cy.intercept('index.php?option=com_content&view=articles').as('article_publish')
cy.clickToolbarButton('publish')
cy.wait('@article_publish')
})
Cypress.Commands.add('trashArticle', (title) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.searchForItem(title)
cy.checkAllResults()
cy.clickToolbarButton('Action')
cy.intercept('index.php?option=com_content&view=articles').as('article_trash')
cy.clickToolbarButton('trash')
cy.wait('@article_trash')
})
Cypress.Commands.add('deleteArticle', (title) => {
cy.visit('administrator/index.php?option=com_content&view=articles')
cy.setFilter('published', 'Trashed')
cy.searchForItem(title)
cy.checkAllResults()
cy.on("window:confirm", (s) => {
return true;
});
cy.intercept('index.php?option=com_content&view=articles').as('article_delete')
cy.clickToolbarButton('empty trash');
cy.wait('@article_delete')
cy.wait('@article_delete')
})

View File

@ -0,0 +1,34 @@
// ***********************************************************
// 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
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
import 'joomla-cypress'
// Alternatively you can use CommonJS syntax:
// require('./commands')
before(function() {
const {registerCommands} = require('../../../node_modules/joomla-cypress/src/index.js')
registerCommands()
Cypress.on('uncaught:exception', (err, runnable) => {
console.log("err :" + err)
console.log("runnable :" + runnable)
return false
})
})