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
path: /tmp/composer-cache
commands:
- composer install --no-progress --no-suggest
- composer install --no-progress
- name: npm
image: node:16-bullseye-slim
@ -34,7 +34,7 @@ steps:
- npx cypress install
- npx cypress verify
- 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
depends_on:
@ -45,52 +45,17 @@ steps:
path: /root/.cache/Cypress
commands:
- 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/
- unzip joomla.zip
- apache2ctl -D FOREGROUND &
- 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 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
- 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:
- name: weblinks_cache
host:
@ -134,6 +99,6 @@ services:
---
kind: signature
hmac: bcc028d5d9601f1f3355862f17dd2434ba86f47634f0737877db534e49c8265b
hmac: 75d22d8b741def46eb475a2fd9b50483b8c938e81de478ecacbf1bfd57782c5c
...

137
.gitignore vendored
View File

@ -1,64 +1,73 @@
# Builds
build
releases
# OSX
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini
# PHPStorm
.idea/
# Sublime Text
*.sublime*
# Eclipse
.buildpath
.project
.settings
# Temp files
*.tmp
*.bak
*.swp
*~.nib
*~
# Phing
build.properties
phing-latest.phar
# Github pages and Jekyll files
/_site/
/Gemfile
/Gemfile.lock
# composer
composer.phar
vendor/*
# Robo
robo.phar
RoboFile.ini
# Test related files
tests/acceptance.suite.yml
tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php
tests/joomla*
tests/_output*
selenium-server-standalone.jar
codecept.phar
selenium.log
tests/cache
# Package building related
/dist
jorobo.ini
# Builds
build
releases
# OSX
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini
# PHPStorm
.idea/
# Sublime Text
*.sublime*
# Eclipse
.buildpath
.project
.settings
# Temp files
*.tmp
*.bak
*.swp
*~.nib
*~
# Phing
build.properties
phing-latest.phar
# Github pages and Jekyll files
/_site/
/Gemfile
/Gemfile.lock
# composer
composer.phar
vendor/*
# Robo
robo.phar
RoboFile.ini
# Test related files
tests/acceptance.suite.yml
tests/*/*Tester.php
tests/_support/_generated/*TesterActions.php
tests/joomla*
tests/_output*
selenium-server-standalone.jar
codecept.phar
selenium.log
tests/cache
#cypress
node_modules
/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+",
"config": {
"platform": {
"php": "7.2.0"
"php": "7.2.5"
}
},
"require" : {
"php": ">=7.2"
"php": ">=7.2.5|~8"
},
"require-dev": {
"behat/gherkin": "^4.4.1",
"codeception/codeception": "^4.1",
"consolidation/robo": "^1.0.0",
"fzaninotto/faker": "^1.6",
"joomla-projects/joomla-browser": "^4.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",
"phpunit/phpunit": "^5.7.27",
"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"?>
<extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>##VERSION##</version>
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<namespace path="src">Joomla\Component\Weblinks</namespace>
<install>
<sql>
<file charset="utf8" driver="mysql">sql/install.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
<schemapath type="postgresql">sql/updates/postgresql</schemapath>
</schemas>
</update>
<media folder="media/com_weblinks" destination="com_weblinks">
##MEDIA_FILES##
</media>
<files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES##
</files>
<languages folder="language">
##FRONTEND_LANGUAGE_FILES##
</languages>
<administration>
<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
-->
<menu link="option=com_weblinks" view="links" img="class:weblinks"
alt="Weblinks/Links">com_weblinks_links</menu>
<menu link="option=com_categories&amp;extension=com_weblinks"
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
<menu link="option=com_fields&amp;view=fields&amp;context=com_weblinks.weblink"
alt="Weblinks/Fields">com_weblinks_fields</menu>
<menu link="option=com_fields&amp;view=groups&amp;context=com_weblinks.weblink"
alt="Weblinks/Field Groups">com_weblinks_field_groups</menu>
</submenu>
<files folder="administrator/components/com_weblinks">
##BACKEND_COMPONENT_FILES##
</files>
<languages folder="administrator/language">
##BACKEND_LANGUAGE_FILES##
</languages>
</administration>
</extension>
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.5" method="upgrade">
<name>com_weblinks</name>
<element>com_weblinks</element>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<copyright>(C) 2005 - ##YEAR## Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>##VERSION##</version>
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<namespace path="src">Joomla\Component\Weblinks</namespace>
<install>
<sql>
<file charset="utf8" driver="mysql">sql/install.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/install.postgresql.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file charset="utf8" driver="mysql">sql/uninstall.mysql.sql</file>
<file charset="utf8" driver="postgresql">sql/uninstall.postgresql.sql</file>
</sql>
</uninstall>
<update>
<schemas>
<schemapath type="mysql">sql/updates/mysql</schemapath>
<schemapath type="postgresql">sql/updates/postgresql</schemapath>
</schemas>
</update>
<media folder="media/com_weblinks" destination="com_weblinks">
##MEDIA_FILES##
</media>
<files folder="components/com_weblinks">
##FRONTEND_COMPONENT_FILES##
</files>
<languages folder="language">
##FRONTEND_LANGUAGE_FILES##
</languages>
<administration>
<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
-->
<menu link="option=com_weblinks" view="links" img="class:weblinks"
alt="Weblinks/Links">com_weblinks_links</menu>
<menu link="option=com_categories&amp;extension=com_weblinks"
view="categories" img="class:weblinks-cat" alt="Weblinks/Categories">com_weblinks_categories</menu>
<menu link="option=com_fields&amp;view=fields&amp;context=com_weblinks.weblink"
alt="Weblinks/Fields">com_weblinks_fields</menu>
<menu link="option=com_fields&amp;view=groups&amp;context=com_weblinks.weblink"
alt="Weblinks/Field Groups">com_weblinks_field_groups</menu>
</submenu>
<files folder="administrator/components/com_weblinks">
##BACKEND_COMPONENT_FILES##
</files>
<languages folder="administrator/language">
##BACKEND_LANGUAGE_FILES##
</languages>
</administration>
</extension>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.5" client="site" method="upgrade">
<name>mod_weblinks</name>
<element>mod_weblinks</element>
<author>Joomla! Project</author>
<creationDate>##DATE##</creationDate>
<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
})
})