mirror of
https://framagit.org/framasoft/framadate/framadate
synced 2026-01-23 02:14:06 +00:00
Add cypress
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
65c0691c7e
commit
d1cbab2b86
7 changed files with 1402 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -12,6 +12,7 @@ tpl_c/*
|
|||
!tpl_c/.gitkeep
|
||||
.php_cs.cache
|
||||
.zanata-cache/
|
||||
node_modules/
|
||||
|
||||
# Temp files
|
||||
*~
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
variables:
|
||||
TESTING_IMAGE: framasoft/framadate-ci:php-7.2
|
||||
TESTING_IMAGE: framasoft/framadate-ci:7.3-pdo_sqlite
|
||||
|
||||
image: ${TESTING_IMAGE}
|
||||
|
||||
|
|
@ -8,16 +8,18 @@ cache:
|
|||
paths:
|
||||
- vendor/
|
||||
|
||||
# Always install composer deps
|
||||
before_script:
|
||||
- composer install -o --no-interaction --no-progress --prefer-dist
|
||||
|
||||
stages:
|
||||
- test
|
||||
- e2e
|
||||
- deploy
|
||||
- beta
|
||||
- funky
|
||||
|
||||
# Run phpunit on all branches
|
||||
# Run phpunit on all branches for all PHP supported versions
|
||||
.test:
|
||||
stage: test
|
||||
script:
|
||||
|
|
@ -25,15 +27,59 @@ stages:
|
|||
|
||||
test:php:7.1:
|
||||
extends: .test
|
||||
image: framasoft/framadate-ci:php-7.1
|
||||
image: framasoft/framadate-ci:7.1-pdo_sqlite
|
||||
|
||||
test:php:7.2:
|
||||
extends: .test
|
||||
image: framasoft/framadate-ci:php-7.2
|
||||
image: framasoft/framadate-ci:7.2-pdo_sqlite
|
||||
|
||||
test:php:7.3:
|
||||
extends: .test
|
||||
image: framasoft/framadate-ci:php-7.3
|
||||
image: framasoft/framadate-ci:7.3-pdo_sqlite
|
||||
|
||||
test:php:7.4:
|
||||
extends: .test
|
||||
image: framasoft/framadate-ci:7.4-rc-pdo_sqlite
|
||||
allow_failure: true
|
||||
|
||||
# Run cypress on all branches, for all PHP supported versions
|
||||
.e2e-test:
|
||||
stage: e2e
|
||||
variables:
|
||||
APP_ENV: "test"
|
||||
POSTGRES_DB: "fd_test"
|
||||
POSTGRES_USER: "marmotte"
|
||||
POSTGRES_PASSWORD: "sleeping"
|
||||
FRAMADATE_DB_DRIVER: 'pdo_pgsql'
|
||||
FRAMADATE_DB_HOST: "postgres"
|
||||
FRAMADATE_DB_NAME: "${POSTGRES_DB}"
|
||||
FRAMADATE_DB_USER: "${POSTGRES_USER}"
|
||||
FRAMADATE_DB_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||
before_script:
|
||||
- yarn install
|
||||
- bin/doctrine migrations:migrate --no-interaction -vvv
|
||||
script:
|
||||
- php -S localhost:8080 &
|
||||
- if [ -z "$CYPRESS_KEY" ]; then npx cypress run; else npx cypress run --record --key $CYPRESS_KEY; fi
|
||||
services:
|
||||
- 'postgres:11'
|
||||
|
||||
e2e-test:php:7.1:
|
||||
extends: .e2e-test
|
||||
image: framasoft/framadate-ci:7.1-pdo_pgsql-cypress
|
||||
|
||||
e2e-test:php:7.2:
|
||||
extends: .e2e-test
|
||||
image: framasoft/framadate-ci:7.2-pdo_pgsql-cypress
|
||||
|
||||
e2e-test:php:7.3:
|
||||
extends: .e2e-test
|
||||
image: framasoft/framadate-ci:7.3-pdo_pgsql-cypress
|
||||
|
||||
e2e-test:php:7.4:
|
||||
extends: .e2e-test
|
||||
image: framasoft/framadate-ci:7.4-rc-pdo_pgsql-cypress
|
||||
allow_failure: true
|
||||
|
||||
# Run php-cs-fixer on all branches
|
||||
lint:
|
||||
|
|
@ -41,7 +87,7 @@ lint:
|
|||
script:
|
||||
- php vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
|
||||
|
||||
# Run doctrine migrations with MySQL
|
||||
# Run doctrine migrations with all MySQL supported versions
|
||||
.db:migration:mysql:
|
||||
stage: test
|
||||
variables:
|
||||
|
|
@ -53,8 +99,8 @@ lint:
|
|||
FRAMADATE_DB_NAME: "${MYSQL_DATABASE}"
|
||||
FRAMADATE_DB_USER: "root"
|
||||
FRAMADATE_DB_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
|
||||
image: framasoft/framadate-ci:7.3-pdo_mysql
|
||||
script:
|
||||
- docker-php-ext-install "${FRAMADATE_DB_DRIVER}"
|
||||
- bin/doctrine migrations:status -vvv
|
||||
- bin/doctrine migrations:migrate --no-interaction -vvv
|
||||
- bin/doctrine migrations:status -vvv
|
||||
|
|
@ -83,8 +129,8 @@ db:migration:mysql:8:
|
|||
FRAMADATE_DB_NAME: "${POSTGRES_DB}"
|
||||
FRAMADATE_DB_USER: "${POSTGRES_USER}"
|
||||
FRAMADATE_DB_PASSWORD: "${POSTGRES_PASSWORD}"
|
||||
image: framasoft/framadate-ci:7.3-pdo_pgsql
|
||||
script:
|
||||
- docker-php-ext-install "${FRAMADATE_DB_DRIVER}"
|
||||
- bin/doctrine migrations:status -vvv
|
||||
- bin/doctrine migrations:migrate --no-interaction -vvv
|
||||
- bin/doctrine migrations:status -vvv
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class PollService {
|
|||
list($poll_id, $admin_poll_id) = $this->createPoll($form);
|
||||
|
||||
// Send confirmation by mail if enabled
|
||||
if (!is_null($ids)) {
|
||||
if (!is_null($poll_id) && !is_null($admin_poll_id)) {
|
||||
// Everything went well
|
||||
$this->notificationService->sendPollCreationMails($form->admin_mail, $form->admin_name, $form->title, $poll_id, $admin_poll_id);
|
||||
|
||||
|
|
|
|||
8
cypress.json
Normal file
8
cypress.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"fixturesFolder": false,
|
||||
"pluginsFile": false,
|
||||
"supportFile": false,
|
||||
"integrationFolder": "tests/cypress/integration",
|
||||
"video": false,
|
||||
"projectId": "yxdfdk"
|
||||
}
|
||||
14
package.json
Normal file
14
package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"cypress": "^3.6.1",
|
||||
"faker": "^4.1.0"
|
||||
},
|
||||
"name": "framadate",
|
||||
"version": "1.2.0-alpha.1",
|
||||
"repository": "git@framagit.org:framasoft/framadate/framadate.git",
|
||||
"author": "Thomas Citharel <tcit@tcit.fr>",
|
||||
"license": "CECILL-B",
|
||||
"scripts": {
|
||||
"cypress": "cypress run"
|
||||
}
|
||||
}
|
||||
90
tests/cypress/integration/actions.spec.js
Normal file
90
tests/cypress/integration/actions.spec.js
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import faker from 'faker';
|
||||
|
||||
context('Actions', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit('http://localhost:8080');
|
||||
});
|
||||
|
||||
// https://on.cypress.io/interacting-with-elements
|
||||
|
||||
it('Access the pages from homepage', () => {
|
||||
// https://on.cypress.io/type
|
||||
|
||||
console.log(navigator.language);
|
||||
cy.contains('header h2', 'Créez vos propres sondages');
|
||||
cy.get('.home-choice').first()
|
||||
.find('.fa-calendar').click();
|
||||
|
||||
cy.url().should('include', 'create_poll.php?type=date');
|
||||
cy.contains('header h2', 'Poll creation (1 of 3)');
|
||||
|
||||
cy.go('back');
|
||||
|
||||
cy.get('.home-choice').eq(1)
|
||||
.find('.fa-th-list').click();
|
||||
|
||||
cy.url().should('include', 'create_poll.php?type=autre');
|
||||
cy.contains('header h2', 'Poll creation (1 of 3)');
|
||||
|
||||
cy.go('back');
|
||||
|
||||
cy.get('.home-choice').last()
|
||||
.find('.fa-search').click();
|
||||
|
||||
cy.url().should('include', 'find_polls.php');
|
||||
|
||||
cy.contains('main h3', 'Polls saved inside this browser');
|
||||
cy.contains('.alert.alert-info', 'There are no polls saved inside your browser yet');
|
||||
cy.contains('main h3', 'Send my polls by email')
|
||||
});
|
||||
|
||||
it('Changes language sucessfully', () => {
|
||||
cy.get('header select.form-control').select('Italiano').next().click();
|
||||
cy.contains('header h2', 'Crea il tuo sondaggio');
|
||||
});
|
||||
|
||||
it('Creates a poll sucessfully', () => {
|
||||
//const email = faker.internet.email();
|
||||
const name = faker.name.findName();
|
||||
const title = faker.lorem.sentence();
|
||||
|
||||
cy.get('.home-choice').first()
|
||||
.find('.fa-calendar').click();
|
||||
cy.url().should('include', 'create_poll.php?type=date');
|
||||
cy.contains('header h2', 'Poll creation (1 of 3)');
|
||||
|
||||
cy.get('input[name=name]').type(name);
|
||||
//cy.get('input[name=mail]').type(email);
|
||||
cy.get('input[name=title]').type(title);
|
||||
//cy.get('#formulaire').submit();
|
||||
cy.get('button[name=gotostep2]').click();
|
||||
|
||||
cy.url().should('include', 'create_date_poll.php');
|
||||
|
||||
cy.get('.input-group.date').first().click();
|
||||
// cy.wait(1000);
|
||||
cy.get('.datepicker.datepicker-dropdown .datepicker-days thead .datepicker-switch').click();
|
||||
cy.get('.datepicker.datepicker-dropdown .datepicker-months thead .datepicker-switch').click();
|
||||
cy.contains('.datepicker.datepicker-dropdown .datepicker-years span.year', '2020').click();
|
||||
cy.contains('.datepicker.datepicker-dropdown .datepicker-months span.month', 'Nov').click();
|
||||
cy.contains('.datepicker.datepicker-dropdown .datepicker-days td.day', '12').click();
|
||||
cy.get('input[name="days[]"]').first().should('have.value', '2020-11-12');
|
||||
cy.get('input[name="days[]"]').eq(1).type('2020-11-13').should('have.value', '2020-11-13');
|
||||
cy.get('button[name="choixheures"').click();
|
||||
|
||||
cy.contains('h4', 'List of options');
|
||||
cy.contains('.well.summary li:first-child', 'Thursday 12 November 2020');
|
||||
cy.contains('.well.summary li:last-child', 'Friday 13 November 2020');
|
||||
|
||||
cy.get('button[name="confirmation"]').click();
|
||||
|
||||
cy.url().should('include', 'adminstuds.php?poll=');
|
||||
cy.contains('#title-form h3', title);
|
||||
cy.contains('#name-form', name);
|
||||
//cy.contains('#email-form', email);
|
||||
|
||||
cy.contains('table.results .bg-primary.month', 'November 2020');
|
||||
cy.get('table.results .bg-primary.day').first().contains('Thu 12');
|
||||
cy.get('table.results .bg-primary.day').last().contains('Fri 13');
|
||||
})
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue