Skip to content

Commit

Permalink
Merge branch 'master' into cat17_noGoals
Browse files Browse the repository at this point in the history
  • Loading branch information
wiese committed Nov 22, 2017
2 parents ec6acf2 + 722436c commit 9ed26e2
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 45 deletions.
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@

User facing application for the [Wikimedia Deutschland](https://wikimedia.de) fundraising.

We moved the Donation Context into [it's own git repository](https://github.com/wmde/fundraising-donations).

The easiest way to get a working installation of the application is to use [Vagrant](https://www.vagrantup.com/).
Just get a clone of our git repository and run `vagrant up` in it. Then `vagrant ssh` into it and go to `/vagrant`, where you will be able to run the full test suite. (Excluding a handful of payment provider system tests).

* [Installation](#installation)
* [Configuration](#configuration)
* [Running the application](#running-the-application)
* [Running the tests](#running-the-tests)
* [Skins](#skins)
* [Deployment](#deployment)
* [Project structure](#project-structure)

## Installation

The easiest way to get a working installation of the application is to use [Vagrant](https://www.vagrantup.com/).
Just get a clone of our git repository and run `vagrant up` in it. Then `vagrant ssh` into it and go to `/vagrant`,
where you will be able to run the full test suite. (Excluding a handful of payment provider system tests).

### Using Vagrant

Get a copy of the code and make sure you have [Vagrant](https://www.vagrantup.com/) installed.
Expand Down Expand Up @@ -89,7 +95,7 @@ The "add donation" form can then be found at http://localhost:8000/index.php

## Running the tests

## Full CI run
### Full CI run

composer ci

Expand All @@ -101,7 +107,7 @@ For style checks only

composer cs ; npm run cs

## PHP
### PHP

For tests only

Expand All @@ -115,7 +121,7 @@ For one context only

vendor/bin/phpunit contexts/DonationContext/

### phpstan
#### phpstan

Static code analysis can be performed via [phpstan](https://github.com/phpstan/phpstan/), either via

Expand All @@ -129,7 +135,7 @@ while dev-dependencies are present, or via
in the absence of dev-dependencies (i.e. to simulate the vendor/ code on production).
These tasks are also performed during the [travis](.travis.yml) runs.

## JS
### JS

For a full JS CI run

Expand All @@ -146,14 +152,14 @@ If you want to debug problems in the Redux data flow, set the following variable

Actions and their resulting state will be logged.

## Editing skins
## Skins

If skin assets where changed, you will need to run

npm run build-assets
npm run copy-assets

Also see [skins/README.md](skins/README.md)
For more information on skins, including how to change which one is used, see [skins/README.md](skins/README.md).

## Deployment

Expand All @@ -171,6 +177,9 @@ This codebase follows a modified version of [The Clean Architecture](https://8th
combined with a partial application of [Domain Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design).
The high level structure is represented by [this diagram](https://commons.wikimedia.org/wiki/File:Clean_Architecture_%2B_DDD,_full_application.svg).

We moved the Donation Context into [it's own git repository](https://github.com/wmde/fundraising-donations) as first step
into putting each Bounded Context into a dedicated git repository.

### Production code layout

* `src/`: framework agnostic code not belonging to any Bounded Context
Expand Down Expand Up @@ -222,10 +231,10 @@ persistence, you should use `TestEnvironment` defined in `tests/TestEnvironment.
<table>
<tr>
<th></th>
<th>Database (in memory)</th>
<th>Top level factory</th>
<th>Network</th>
<th>Framework (Silex)</th>
<th>Network & Disk</th>
<th>Top level factory</th>
<th>Database and disk</th>
</tr>
<tr>
<th>Unit</th>
Expand All @@ -236,17 +245,17 @@ persistence, you should use `TestEnvironment` defined in `tests/TestEnvironment.
</tr>
<tr>
<th>Integration</th>
<td>If needed</td>
<td>Discouraged</td>
<td>No</td>
<td>Read only</td>
<td>No</td>
<td>Discouraged</td>
<td>Yes</td>
</tr>
<tr>
<th>EdgeToEdge</th>
<td>No</td>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
<td>Read only</td>
</tr>
<tr>
<th>System</th>
Expand Down
4 changes: 2 additions & 2 deletions skins/cat17/src/app/lib/form_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ var objectAssign = require( 'object-assign' ),
};
this.hiddenElement.val( germanFloatFromMixedAmountFormatter( formContent.amount ) );
if ( formContent.isCustomAmount ) {
this.inputElement.parent().addClass('filled');
this.inputElement.parent().addClass( 'filled' );
this.selectElement.prop( 'checked', false );
this.inputElement.val( formContent.amount );
} else {
this.inputElement.parent().removeClass('filled');
this.inputElement.parent().removeClass( 'filled' );
this.selectElement.val( [ formContent.amount ] );
this.inputElement.val( '' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var objectAssign = require( 'object-assign' ),
this.fieldset.find( '.info-text' ).removeClass( 'opened' );

// fieldsets may contain fields of more than one name (cp. intervalType vs periode), avoid false matches (hidden)
var field = this.fieldset.find( '[value="' + value + '"]:not(.hidden)' );
var field = this.fieldset.find( '.wrap-input [value="' + value + '"]:not(.hidden)' );
var wrapper = field.parents( '.wrap-field' );
var infoText = wrapper.find( '.info-text' );

Expand Down
10 changes: 5 additions & 5 deletions skins/cat17/src/app/lib/view_handler/display_payment_summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ var objectAssign = require( 'object-assign' ),
return;
}

if( state.accountNumber && state.bankCode ) {
this.paymentElement.prepend (
this.getBankAccountSummary( 'Kontonummer', state.accountNumber, 'Bankleitzahl', state.bankCode )
)
} else if( state.iban && state.bic ) {
if( state.iban && state.bic ) {
this.paymentElement.prepend (
this.getBankAccountSummary( 'IBAN', state.iban, 'BIC', state.bic )
);
} else if( state.accountNumber && state.bankCode ) {
this.paymentElement.prepend (
this.getBankAccountSummary( 'Kontonummer', state.accountNumber, 'Bankleitzahl', state.bankCode )
)
}
},
updateMembershipSummary: function ( state ) {
Expand Down
30 changes: 25 additions & 5 deletions skins/cat17/src/app/tests/test_form_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,22 @@ test( 'Rendering the amount component with custom amount clears selection and se
selectElement = createSpyingElement(),
hiddenElement = createSpyingElement(),
store = {},
component = formComponents.createAmountComponent( store, textElement, selectElement, hiddenElement );
parent = {
addClass: sinon.spy()
}
;

textElement.parent = function () {
return parent;
};

var component = formComponents.createAmountComponent( store, textElement, selectElement, hiddenElement );

component.render( { amount: '23,00', isCustomAmount: true } );

t.ok( textElement.val.calledOnce, 'value is set once' );
t.ok( textElement.val.calledWith( '23,00' ) );
t.ok( parent.addClass.withArgs( 'filled' ).calledOnce );
t.ok( selectElement.val.callCount === 0, 'select element value is not set' );
t.ok( selectElement.prop.calledOnce, 'property was set' );
t.ok( selectElement.prop.calledWith( 'checked', false ), 'check property was removed' );
Expand All @@ -166,15 +176,25 @@ test( 'Rendering the amount component with custom amount clears selection and se

test( 'Rendering the amount component with non-custom amount sets the hidden field and clears the text field', function ( t ) {
var textElement = createSpyingElement(),
selectElement = createSpyingElement(),
hiddenElement = createSpyingElement(),
store = {},
component = formComponents.createAmountComponent( store, textElement, selectElement, hiddenElement );
selectElement = createSpyingElement(),
hiddenElement = createSpyingElement(),
store = {},
parent = {
removeClass: sinon.stub()
}
;

textElement.parent = function () {
return parent;
};

var component = formComponents.createAmountComponent( store, textElement, selectElement, hiddenElement );

component.render( { amount: '50,00', isCustomAmount: false } );

t.ok( textElement.val.calledOnce, 'value is cleared' );
t.ok( textElement.val.calledWith( '' ) );
t.ok( parent.removeClass.withArgs( 'filled' ).calledOnce );
t.ok( selectElement.val.calledOnce, 'select element value is set' );
t.ok( selectElement.val.calledWith( [ '50,00' ] ), 'select element value is set' ); // needs to be array for selects
t.ok( hiddenElement.val.calledOnce, 'hidden element value is set' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

var test = require( 'tape' ),
sinon = require( 'sinon' ),
SuboptionDisplayHandler = require( '../../lib/view_handler/display_field_suboptions' )
;

test( 'Current field is selected and infotext opened, others unselected and not opened', function ( t ) {
var allWrappers = {
removeClass: sinon.spy()
},
allInfoTexts = {
removeClass: sinon.spy()
},
activeInfoText = {
addClass: sinon.spy(),
prop: sinon.stub().withArgs( 'scrollHeight' ).returns( 472 )
},
activeWrapper = {
find: sinon.stub().withArgs( '.info-text' ).returns( activeInfoText ),
addClass: sinon.spy()
},
activeField = {
parents: sinon.stub().withArgs( '.wrap-field' ).returns( activeWrapper )
},
fieldset = {
find: sinon.stub(),
css: sinon.spy()
}
;

fieldset.find.withArgs( '.wrap-field' ).returns( allWrappers );
fieldset.find.withArgs( '.info-text' ).returns( allInfoTexts );
fieldset.find.withArgs( '.wrap-input [value="PPL"]:not(.hidden)' ).returns( activeField );

var handler = SuboptionDisplayHandler.createSuboptionDisplayHandler( fieldset );
handler.update( 'PPL' );

t.ok( allWrappers.removeClass.withArgs( 'selected notselected' ).calledOnce, 'all wappers unstyled' );
t.ok( allInfoTexts.removeClass.withArgs( 'opened' ).calledOnce, 'all infotexts closed' );

t.ok( activeWrapper.addClass.withArgs( 'selected' ).calledOnce, 'active wrapper styled' );
t.ok( activeInfoText.addClass.withArgs( 'opened' ).calledOnce, 'active infotext opened' );
t.ok( fieldset.css.withArgs( 'min-height', '472px' ).calledOnce, 'height of fieldset adjusted per active infotext' );

t.end();
} );
2 changes: 1 addition & 1 deletion skins/cat17/src/sass/layouts/_borders-system.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fieldset {
margin-top: 0;
padding: 11px 0 14px 4px;
}
.oden {
.iban-decision {
display: inline-block;
margin-bottom: 12px;
}
Expand Down
17 changes: 5 additions & 12 deletions skins/cat17/src/scripts/donationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,7 @@ $( function () {
function addressIsValid() {
var validity = store.getState().validity,
formContent = store.getState().donationFormContent;
return formContent.addressType === 'anonym' || (
// @fixme: Move checking of salutation and title into reducer/store/validator
validity.address &&
formContent.salutation != ''
);
return formContent.addressType === 'anonym' || validity.address;
}

function bankDataIsValid() {
Expand All @@ -270,7 +266,6 @@ $( function () {

function formDataIsValid() {
var validity = store.getState().validity;
//console.log(validity.paymentData + " " + addressIsValid() + " " + bankDataIsValid());
return validity.paymentData && addressIsValid() && bankDataIsValid();
}

Expand All @@ -286,7 +281,7 @@ $( function () {
} else if ( formContent.addressType === 'firma' ) {
store.dispatch( actions.newMarkEmptyFieldsInvalidAction(
[ 'companyName', 'street', 'postcode', 'city', 'email' ],
[ 'firstName', 'lastName' ]
[ 'salutation', 'firstName', 'lastName' ]
) );
}
}
Expand Down Expand Up @@ -342,22 +337,20 @@ $( function () {
donatorType.addClass('completed').removeClass('disabled invalid');
var validators = state.donationInputValidation;
if (
state.donationFormContent.addressType == 'personal' &&
state.donationFormContent.addressType === 'personal' &&
(
(validators.email.dataEntered && !validators.email.isValid) ||
(validators.city.dataEntered && !validators.city.isValid) ||
(validators.firstName.dataEntered && !validators.firstName.isValid) ||
(validators.lastName.dataEntered && !validators.lastName.isValid) ||
(validators.street.dataEntered && !validators.street.isValid) ||
(validators.postcode.dataEntered && !validators.postcode.isValid) ||
(validators.salutation.dataEntered && !validators.salutation.isValid) ||
(validators.firstName.dataEntered && !validators.firstName.isValid)
(validators.salutation.dataEntered && !validators.salutation.isValid)
)
||
state.donationFormContent.addressType == 'firma' &&
state.donationFormContent.addressType === 'firma' &&
(
(validators.companyName.dataEntered && !validators.companyName.isValid) ||
(validators.firstName.dataEntered && !validators.firstName.isValid) ||
(validators.email.dataEntered && !validators.email.isValid) ||
(validators.city.dataEntered && !validators.city.isValid) ||
(validators.street.dataEntered && !validators.street.isValid) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<label for="bic" class="sr-only">{$ 'bic' | trans $}</label>
</div>

<span class="oden">{$ 'payment_type_BEZ_iban_decision' | trans $}</span>
<span class="iban-decision">{$ 'payment_type_BEZ_iban_decision' | trans $}</span>

<div class="field-grp">
<input type="text" id="account-number" name="konto" placeholder="{$ 'account_number' | trans | e( 'html_attr' ) $}">
Expand All @@ -18,5 +18,8 @@
<label for="bank-code" class="sr-only">{$ 'bank_code' | trans $}</label>
</div>

<span id="bank-name"></span>
<input type="hidden" name="bankname" id="field-bank-name" value="" />

<!-- ToDo: wikimedia-team, decide and translate to german -->
<span class="error-text">Generic text of error.</span>

0 comments on commit 9ed26e2

Please sign in to comment.