Skip to content

Commit

Permalink
remove console logs in tests #2766
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Nov 20, 2018
2 parents 3365fff + c6f6877 commit 6505f50
Show file tree
Hide file tree
Showing 1,778 changed files with 299,440 additions and 111 deletions.
2 changes: 1 addition & 1 deletion assets/build/css/caldera-forms-front.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/caldera-forms-front.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/caldera-forms-front.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//**
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-20 *//**
* Simple event bindings for form state
*
* In general, access through CFState.events() not directly.
Expand Down
2 changes: 1 addition & 1 deletion assets/js/entry-viewer-2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//**
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-20 *//**
* API Client for Caldera Forms API for a single form
*
* @since 1.5.0
Expand Down
2 changes: 1 addition & 1 deletion assets/js/parsley.min.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-20 *//*!
* Parsley.js
* Version 2.8.1 - built Sat, Feb 3rd 2018, 2:27 pm
* http://parsleyjs.org
Expand Down
2 changes: 1 addition & 1 deletion assets/js/vue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-19 *//*!
/*! GENERATED SOURCE FILE caldera-forms - v1.8.0-alpha.1 - 2018-11-20 *//*!
* Vue.js v2.1.6
* (c) 2014-2016 Evan You
* Released under the MIT License.
Expand Down
6 changes: 6 additions & 0 deletions classes/render/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,12 @@ public static function enqueue_form_assets(){
),
'nonce' => wp_create_nonce('wp_rest')
),
'strings' => array(
'cf2FileField' => array(
'removeFile' => esc_attr__('Remove file', 'caldera-forms'),
'defaultButtonText' => esc_attr__('Drop files or click to select files to Upload', 'caldera-forms')
)
),
'nonce' => array(
'field' => Caldera_Forms_Render_Nonce::nonce_field_name(),
),
Expand Down
8,138 changes: 8,134 additions & 4 deletions clients/blocks/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/blocks/build/index.min.js.map

Large diffs are not rendered by default.

53,953 changes: 53,938 additions & 15 deletions clients/privacy/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/privacy/build/index.min.js.map

Large diffs are not rendered by default.

41,673 changes: 41,668 additions & 5 deletions clients/pro/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/pro/build/index.min.js.map

Large diffs are not rendered by default.

35,734 changes: 35,702 additions & 32 deletions clients/render/build/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clients/render/build/index.min.js.map

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions clients/render/components/CalderaFormsFieldGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {FileInput} from "./Fields/FileInput";
* @constructor
*/
export const CalderaFormsFieldGroup = (props) => {
const {field, onChange, shouldDisable, shouldShow, hasMessage, isError, message, getFieldConfig} = props;
const {field, onChange, shouldDisable, shouldShow, hasMessage, isError, message, getFieldConfig, strings} = props;
const {
type,
outterIdAttr,
Expand Down Expand Up @@ -54,7 +54,15 @@ export const CalderaFormsFieldGroup = (props) => {
switch (type) {
case 'file':
const fileProps = FileInput.fieldConfigToProps(getFieldConfig(fieldIdAttr));
return <FileInput

let multiUploadText = '';
if(fileProps.multiUploadText === false || fileProps.multiUploadText === null){
multiUploadText = strings.cf2FileField.defaultButtonText;
} else {
multiUploadText = fileProps.multiUploadText;
}

return <FileInput
onChange={onChange}
field={field}
shouldDisable={shouldDisable}
Expand All @@ -69,7 +77,8 @@ export const CalderaFormsFieldGroup = (props) => {
previewHeight={fileProps.previewHeight}
previewWidth={fileProps.previewWidth}
multiple={fileProps.multiple}
multiUploadText={fileProps.multiUploadText}
multiUploadText={multiUploadText}
strings={strings.cf2FileField}
/>
case'text':
default:
Expand Down Expand Up @@ -203,7 +212,8 @@ CalderaFormsFieldGroup.propTypes = {
error: PropTypes.bool,
message: PropTypes.string
}),
getFieldConfig: PropTypes.func.isRequired
getFieldConfig: PropTypes.func.isRequired,
strings: PropTypes.object
};

/**
Expand Down
12 changes: 8 additions & 4 deletions clients/render/components/CalderaFormsFieldRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {CalderaFormsFieldGroup} from "./CalderaFormsFieldGroup";
* @constructor
*/
export const CalderaFormsFieldRender = (props) => {
const {field, onChange, shouldDisable, shouldShow,getFieldConfig,message,hasMessage} = props;
const {field, onChange, shouldDisable, shouldShow,getFieldConfig,message,hasMessage,strings} = props;
const {
type,
outterIdAttr,
Expand All @@ -35,6 +35,7 @@ export const CalderaFormsFieldRender = (props) => {
getFieldConfig={getFieldConfig}
message={message}
hasMessage={hasMessage}
strings={strings}
/>
</RenderComponentViaPortal>
</Fragment>
Expand All @@ -55,7 +56,10 @@ export const CalderaFormsFieldPropType = PropTypes.shape({
fieldIdAttr: PropTypes.string.isRequired,
fieldLabel: PropTypes.string.isRequired,
fieldCaption: PropTypes.string.isRequired,
isRequired: PropTypes.boola,
isRequired: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object
]),
fieldPlaceHolder: PropTypes.string.isRequired,
fieldDefault: PropTypes.string,
fieldValue: PropTypes.oneOfType(
Expand Down Expand Up @@ -83,8 +87,8 @@ CalderaFormsFieldRender.propTypes = {
message: PropTypes.shape({
error: PropTypes.bool,
message: PropTypes.string
})

}),
strings: PropTypes.object
};

/**
Expand Down
19 changes: 16 additions & 3 deletions clients/render/components/CalderaFormsRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class CalderaFormsRender extends Component {
}

/**
* Get the field config, by fieldIdAtte
* Get the field config, by fieldIdAttr
*
* @since 1.8.0
*
Expand Down Expand Up @@ -389,7 +389,18 @@ export class CalderaFormsRender extends Component {
}

})
};
}

/**
* Get translatable strings Set in Caldera_Forms_Render_Assets::enqueue_form_assets()
*
* @since 1.8.0
*
* @return {Object}
*/
getStrings() {
return this.props.strings;
}


/** @inheritDoc */
Expand Down Expand Up @@ -424,6 +435,7 @@ export class CalderaFormsRender extends Component {
this.subscribe(fieldIdAttr);
const props = {
field,
strings: this.getStrings(),
onChange: this.getHandler(fieldIdAttr),
shouldShow: state[shouldShowKey(fieldIdAttr)],
shouldDisable: state[shouldDisableKey(fieldIdAttr)],
Expand Down Expand Up @@ -464,6 +476,7 @@ CalderaFormsRender.propTypes = {
),
formIdAttr: PropTypes.string.isRequired,
shouldBeValidating: PropTypes.bool.isRequired,
messages: PropTypes.object
messages: PropTypes.object,
strings: PropTypes.object
};

38 changes: 20 additions & 18 deletions clients/render/components/Fields/FileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import Dropzone from 'react-dropzone';
*/
export const FileInput = (props) => {

const {shouldDisable, onChange, accept, field, describedById, style, className, multiple, multiUploadText, inputProps, text, usePreviews, previewHeight, previewWidth} = props;

const {onChange, accept, field, describedById, style, className, multiUploadText, multiple, inputProps, usePreviews, previewHeight, previewWidth,strings} = props;
let {shouldDisable} = props;
const {
outterIdAttr,
fieldId,
Expand All @@ -38,12 +38,14 @@ export const FileInput = (props) => {

inputProps.id = fieldIdAttr;

if(valueSet && !multiple){
shouldDisable = true;
inputProps.disabled = true;
}

return (

<div className="cf2-dropzone" data-field={fieldId}>
{valueSet && !multiple ?
<div className="cf2-one-file-notice">{text.multipleDisabled}</div>
:
<Dropzone
onDrop={onChange}
className={className}
Expand All @@ -59,11 +61,11 @@ export const FileInput = (props) => {
className="btn btn-block"
aria-controls={buttonControls}
aria-expanded={valueSet}
disabled={shouldDisable}
>
{multiUploadText}
</button>
</Dropzone>
}

{valueSet &&
<ul
Expand All @@ -88,7 +90,7 @@ export const FileInput = (props) => {
className="cf2-file-remove"
onClick={(e) => onChange(e, file)}
>
<span className="screen-reader-text sr-text">{text.removeFile}</span>
<span className="screen-reader-text sr-text">{strings.removeFile}</span>
</button>

<div>
Expand Down Expand Up @@ -136,7 +138,10 @@ FileInput.propTypes = {
PropTypes.number
]),
text: PropTypes.object,
multiUploadText: PropTypes.string,
multiUploadText: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string
]),
message: PropTypes.shape({
error: PropTypes.bool,
message: PropTypes.string
Expand All @@ -154,6 +159,10 @@ FileInput.propTypes = {
PropTypes.bool,
PropTypes.string
]),
isRequired: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.object
]),
};

/**
Expand All @@ -168,12 +177,9 @@ FileInput.defaultProps = {
error: false,
message: ''
},
text: {
removeFile: 'Remove file',
multipleDisabled: 'Only one file upload allowed'
},
inputProps: {
type: 'file'
type: 'file',
disabled: 'false'
},
disableClick: false,
className: 'cf2-file form-control'
Expand All @@ -194,8 +200,7 @@ FileInput.fieldConfigToProps = (fieldConfig) => {
};
const configOptionProps = [
'multiple',
'multiUploadText',
'text'
'multiUploadText'
];

if( ! props.field.hasOwnProperty('isRequired' ) ){
Expand Down Expand Up @@ -243,9 +248,6 @@ FileInput.fieldConfigToProps = (fieldConfig) => {

}

if (configOptions.multiUploadText === false) {
props.multiUploadText = 'Drop files or click to select files to Upload';
}

}

Expand Down
1 change: 1 addition & 0 deletions clients/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ domReady(function () {
theComponent = component
}}
messages={messages}
strings={CF_API_DATA.strings}
/>,
document.getElementById(`cf2-${idAttr}`)
);
Expand Down
8 changes: 8 additions & 0 deletions clients/tests/unit/render/CalderaFormsFieldGroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ describe('chooses inner field', () => {
type: "text",
};

const strings = {
cf2FileField: {
removeFile: 'Remove file',
defaultButtonText: 'Drop files or click to select files to Upload'
}
}

const getFieldConfig = (fieldIdAttr) =>{
return textFieldConfig;
};
Expand All @@ -198,6 +205,7 @@ describe('chooses inner field', () => {
onChange={handler}
field={fileFieldConfig.field}
getFieldConfig={getFieldConfig}
strings={strings.cf2FileField}
/>);
const testInstance = testRenderer.root;
expect(testInstance.findByType('input').props.type).toBe('file');
Expand Down
19 changes: 18 additions & 1 deletion clients/tests/unit/render/CalderaFormsRender.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ export const formRenderTestProps = {
"control": "cf2_file5bdb63e874357"
}
],
"shouldBeValidating": false
"shouldBeValidating": false,
"strings": {
"cf2FileField": {
"removeFile": "Remove file",
"defaultButtonText": "Drop files or click to select files to Upload"
}
}
};

describe('Form render methods', () => {
Expand Down Expand Up @@ -458,5 +464,16 @@ describe('Form render methods', () => {
expect( component.state( 'messages')).toEqual( {});
});

test( 'Get default file field translatable Strings', () => {
const props = {...formRenderTestProps};
const component = shallow(
<CalderaFormsRender
{...props}
/>
);
expect(component.instance().getStrings()).toBeDefined();
expect(component.instance().getStrings()).toBeTruthy();
});

});

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export class MockFileFieldRenderer extends React.Component {
error: false,
isInvalid: false,
shouldDisable: false,
field: props.field
field: props.field,
strings: props.strings
};
this.onChange = this.onChange.bind(this);
this.setField = this.setField.bind(this);
Expand Down Expand Up @@ -49,7 +50,7 @@ export class MockFileFieldRenderer extends React.Component {
}

render() {
const {value, message, error, isInvalid, shouldDisable, field} = this.state;
const {value, message, error, isInvalid, shouldDisable, field, strings} = this.state;
const messageProp = {error,message};

return (
Expand All @@ -64,6 +65,7 @@ export class MockFileFieldRenderer extends React.Component {
isInvalid={isInvalid}
message={messageProp}
usePreviews={this.props.usePreviews}
strings={strings}
/>
</div>
)
Expand Down
Loading

0 comments on commit 6505f50

Please sign in to comment.