Skip to content

Commit

Permalink
added acceptance tests for doi creation and updates. #280
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jan 4, 2020
1 parent fadcb83 commit 9239a08
Show file tree
Hide file tree
Showing 26 changed files with 493 additions and 423 deletions.
12 changes: 7 additions & 5 deletions app/components/model-validation-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export default Component.extend({
didReceiveAttrs() {
this._super(...arguments);

let errors = this.model.get('validations.errors');
if (this.model.get('state') !== 'draft') {
let errors = this.model.get('validations.errors');

if (errors.length > 0) {
A(errors).forEach((item) => {
console.log(item);
});
if (errors.length > 0) {
A(errors).forEach((item) => {
console.log(item);
});
}
}
},
});
1 change: 0 additions & 1 deletion app/models/custom-inflector-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ inflector.uncountable('status');
inflector.uncountable('media');
inflector.uncountable('settings');
inflector.uncountable('auth');
inflector.irregular('prefix', 'prefixes');

// Modules must have an export, so we just export an empty object here
export default {};
6 changes: 3 additions & 3 deletions app/models/doi.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { A } from '@ember/array';
const Validations = buildValidations({
details: [
validator('belongs-to', {
disabled: computed('model.mode', 'model.state', 'model.prefix', function() {
disabled: computed('model.mode', 'model.state', function() {
return ![ 'new', 'edit' ].includes(this.model.get('mode')) || this.get('model.state') === 'draft';
}),
}),
Expand Down Expand Up @@ -59,7 +59,7 @@ const Validations = buildValidations({
}),
validator('presence', {
presence: true,
isWarning: computed('model.state', 'model.prefix', function() {
isWarning: computed('model.state', function() {
return this.get('model.state') === 'draft';
}),
}),
Expand All @@ -70,7 +70,7 @@ const Validations = buildValidations({
publisher: [
validator('presence', {
presence: true,
isWarning: computed('model.state', 'model.prefix', function() {
isWarning: computed('model.state', function() {
return this.get('model.state') === 'draft';
}),
disabled: computed('model.mode', function() {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/doi-affiliation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</span>
</div>
{{else}}
<div class="power-select-fragment">
<div class="power-select-fragment" data-test-affiliation>
{{#form.element controlType="power-select" disabled=disabled value=fragment.name options=organizations as |el|}}
{{#el.control onChange=(action "selectRor") search=(action "searchRor") placeholder="Select Affiliation" searchPlaceholder="Type to search..." allowClear=true as |item|}}
{{if item.name item.name fragment.name}}
Expand Down
16 changes: 8 additions & 8 deletions app/templates/components/doi-creator.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@
{{/if}}

<div class="radio-fragment">
<RadioButton @value="Personal" @groupValue={{nameType}} @radioClass="radio select-person" @changed={{action "selectNameType"}} @disabled={{isReadonlyNameType}} /><span class="subtitle">Person</span> <RadioButton @value="Organizational" @groupValue={{nameType}} @radioClass="radio select-organisation" @changed={{action "selectNameType"}} @disabled={{isReadonlyNameType}} /><span class="subtitle">Organization</span>
<RadioButton @value="Personal" @groupValue={{nameType}} @radioClass="radio select-person" @changed={{action "selectNameType"}} @disabled={{isReadonlyNameType}}/><span class="subtitle">Person</span> <RadioButton @value="Organizational" @groupValue={{nameType}} @radioClass="radio select-organisation" @changed={{action "selectNameType"}} @disabled={{isReadonlyNameType}} /><span class="subtitle">Organization</span>
</div>

{{#if (gt index 0)}}
{{#if showPersonal}}
<div>
<label for="givenName" class="subtitle">Given Name</label>
<input type="text" class="form-control given-name-field no-error no-success" value={{fragment.givenName}} oninput={{action "updateGivenName" value="target.value"}} readonly={{isReadonlyNameParts}}/>
<input type="text" class="form-control given-name-field no-error no-success" value={{fragment.givenName}} oninput={{action "updateGivenName" value="target.value"}} readonly={{isReadonlyNameParts}} data-test-given-name/>
</div>

<div>
<label for="familyName" class="subtitle">Family Name</label>
<input type="text" class="form-control family-name-field no-error no-success" value={{fragment.familyName}} oninput={{action "updateFamilyName" value="target.value"}} readonly={{isReadonlyNameParts}}/>
<input type="text" class="form-control family-name-field no-error no-success" value={{fragment.familyName}} oninput={{action "updateFamilyName" value="target.value"}} readonly={{isReadonlyNameParts}} data-test-family-name/>
</div>
{{/if}}

<div>
<label for="name" class="subtitle">Name{{if showPersonal ' (from Given Name and Family Name)'}}</label>
</div>
<div class="input-group">
<input type="text" class="form-control creator-field no-error no-success" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}}/>
<input type="text" class="form-control name-field no-error no-success" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}} data-test-name/>
<span class="input-group-btn">
<BsButton @outline={{true}} @onClick={{action "deleteCreator" index}}>{{fa-icon "trash"}}</BsButton>
</span>
Expand All @@ -42,7 +42,7 @@
{{#if showPersonal}}
<div>
<label for="givenName" class="subtitle">Given Name</label>
<input type="text" class="form-control given-name-field {{if (not (v-get fragment 'givenName' 'messages')) 'no-error'}}" value={{fragment.givenName}} oninput={{action "updateGivenName" value="target.value"}} readonly={{isReadonlyNameParts}}/>
<input type="text" class="form-control given-name-field {{if (not (v-get fragment 'givenName' 'messages')) 'no-error'}}" value={{fragment.givenName}} oninput={{action "updateGivenName" value="target.value"}} readonly={{isReadonlyNameParts}} data-test-given-name/>

{{#if (v-get fragment 'givenName' 'errors')}}
<div class="help-block help-block-fragment">{{v-get fragment 'givenName' 'message'}}</div>
Expand All @@ -55,7 +55,7 @@

<div>
<label for="familyName" class="subtitle">Family Name</label>
<input type="text" class="form-control family-name-field {{if (not (v-get fragment 'familyName' 'messages')) 'no-error'}}" value={{fragment.familyName}} oninput={{action "updateFamilyName" value="target.value"}} readonly={{isReadonlyNameParts}}/>
<input type="text" class="form-control family-name-field {{if (not (v-get fragment 'familyName' 'messages')) 'no-error'}}" value={{fragment.familyName}} oninput={{action "updateFamilyName" value="target.value"}} readonly={{isReadonlyNameParts}} data-test-family-name/>

{{#if (v-get fragment 'familyName' 'errors')}}
<div class="help-block help-block-fragment">{{v-get fragment 'familyName' 'message'}}</div>
Expand All @@ -69,14 +69,14 @@
<div>
<label for="name" class="subtitle">Name (from Given Name and Family Name)</label>
</div>
<input type="text" class="form-control creator-field no-error no-success" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}}/>
<input type="text" class="form-control name-field no-error no-success" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}} data-test-name/>

<div class="help-block help-block-fragment no-error no-success">The main researchers involved in producing the data, or the authors of the publication, in priority order.</div>
{{else}}
<div>
<label for="name" class="subtitle">Name</label>
</div>
<input type="text" class="form-control creator-field {{if (not (v-get fragment 'name' 'messages')) 'no-error'}}" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}}/>
<input type="text" class="form-control name-field {{if (not (v-get fragment 'name' 'messages')) 'no-error'}}" value={{fragment.name}} oninput={{action "updateName" value="target.value"}} readonly={{isReadonly}}/>

{{#if (v-get fragment 'name' 'errors')}}
<div class="help-block help-block-fragment">{{v-get fragment 'name' 'message'}}</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/doi-description.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{#if (gt index 0)}}
<div class="input-group">
<textarea class="form-control description-field {{if (not isSeriesInformation) 'no-error'}}" rows="8" style="resize:none" value={{fragment.description}}
oninput={{action "updateDescription" value="target.value"}}/>
oninput={{action "updateDescription" value="target.value"}} data-test-description/>
<span class="input-group-addon">
<BsButton @outline={{true}} @onClick={{action "deleteDescription" index}}>{{fa-icon "trash" pull="left" style="margin:0;"}}</BsButton>
</span>
</div>
{{else}}
<textarea class="form-control description-field {{if (not isSeriesInformation) 'no-error'}}" rows="8" style="resize:none" value={{fragment.description}}
oninput={{action "updateDescription" value="target.value"}}/>
oninput={{action "updateDescription" value="target.value"}} data-test-description/>
{{/if}}
{{#if (v-get fragment 'description' 'warnings')}}
<div class="help-block help-block-fragment description-field">{{v-get fragment 'description' 'warningMessage'}}</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/doi-doi.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-md-9">
<div class="input-group">
<span class="input-group-addon">
{{#form.element controlType="power-select" formLayout="vertical" property="prefix" options=prefixes destination=prefix searchEnabled=false as |el|}}
{{#form.element controlType="power-select" id="prefix-field" formLayout="vertical" property="prefix" options=prefixes destination=prefix searchEnabled=false as |el|}}
{{#el.control onChange=(action "selectPrefix") searchPlaceholder="Select Prefix" optionLabelPath=id as |item|}}
{{if item.id item.id item}}
{{/el.control}}
Expand All @@ -12,7 +12,7 @@
{{form.element
controlType="text"
class="suffix"
id="suffix-field"
id="suffix"
formLayout="vertical"
property="suffix"
onChange=(action "selectSuffix")
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/doi-name-identifier.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{#if (gt index 0)}}
<div class="input-group">
<input type="text" class="form-control name-identifier-field no-error {{if (not fragment.nameIdentifier) 'no-success'}}" value={{fragment.nameIdentifier}} oninput={{action "updateNameIdentifier" value="target.value"}}/>
<input type="text" class="form-control name-identifier-field no-error {{if (not fragment.nameIdentifier) 'no-success'}}" value={{fragment.nameIdentifier}} oninput={{action "updateNameIdentifier" value="target.value"}} data-test-name-identifier/>
<span class="input-group-btn">
<BsButton @outline={{true}} @onClick={{action "deleteNameIdentifier" index}}>{{fa-icon "trash"}}</BsButton>
</span>
</div>
{{else}}
<input type="text" class="form-control name-identifier-field {{if (not (v-get fragment 'nameIdentifier' 'messages')) 'no-error'}} {{if (not fragment.nameIdentifier) 'no-success'}}" value={{fragment.nameIdentifier}} oninput={{action "updateNameIdentifier" value="target.value"}}/>
<input type="text" class="form-control name-identifier-field {{if (not (v-get fragment 'nameIdentifier' 'messages')) 'no-error'}} {{if (not fragment.nameIdentifier) 'no-success'}}" value={{fragment.nameIdentifier}} oninput={{action "updateNameIdentifier" value="target.value"}} data-test-name-identifier/>

{{#if (v-get fragment 'nameIdentifier' 'errors')}}
<div class="help-block help-block-fragment name-identifier-field">{{v-get fragment 'nameIdentifier' 'message'}}</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/doi-title.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{#if (gt index 0)}}
<div class="input-group">
<input type="text" class="form-control title-field no-error no-success" value={{fragment.title}} oninput={{action "updateTitle" value="target.value"}}/>
<input type="text" class="form-control title-field no-error no-success" value={{fragment.title}} oninput={{action "updateTitle" value="target.value"}} data-test-title/>
<span class="input-group-btn">
<BsButton @outline={{true}} @onClick={{action "deleteTitle" index}}>{{fa-icon "trash"}}</BsButton>
</span>
</div>
<div class="help-block help-block-fragment no-error no-success">One or more names or titles by which the resource is known.</div>
{{else}}
<input type="text" class="form-control title-field" value={{fragment.title}} oninput={{action "updateTitle" value="target.value"}}/>
<input type="text" class="form-control title-field" value={{fragment.title}} oninput={{action "updateTitle" value="target.value"}} data-test-title/>

{{#if (v-get fragment 'title' 'errors')}}
<div class="help-block help-block-fragment">{{v-get fragment 'title' 'message'}}</div>
Expand Down
3 changes: 2 additions & 1 deletion app/templates/components/doi-types.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#form.element
controlType="power-select"
label="Resource Type General"
id="resource-type"
id="resource-type-general"
property="types.resourceTypeGeneral"
helpText="The general type of the resource."
options=resourceTypesGeneral
Expand All @@ -17,6 +17,7 @@
{{form.element
controlType="text"
label="Resource Type (optional)"
id="resource-type"
property="types.resourceType"
helpText="A description of the resource, the preferred format is a single term of some detail."
required=false
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/doi-upload.hbs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<label class="control-label col-md-3">Metadata</label>
<div class="col-md-9">
<div class="btn-toolbar btn-sm btn-file">
<FileUpload @name="files" @multiple={{false}} @accept="application/xml,application/json,text/plain,.bib,.ris" @onfileadd={{action "didSelectFiles"}}>
<FileUpload @name="files" @id="upload-file" @multiple={{false}} @accept="application/xml,application/json,text/plain,.bib,.ris" @onfileadd={{action "didSelectFiles"}}>
<span class="btn btn-sm">
{{fa-icon "upload"}} Upload File
</span>
</FileUpload>
</div>

<Textarea @property="xml" @rows={{15}} @showValidationOn="focusOut" @helpText="Metadata that describe the resource. Upload a file with metadata in DataCite XML format, or one of the other supported formats. The DOI in the metadata will be replaced with the DOI in the DOI field if different." @required={{false}} as |el|>
<Textarea @property="xml" @rows={{15}} @showValidationOn="focusOut" @id="metadata-field" @helpText="Metadata that describe the resource. Upload a file with metadata in DataCite XML format, or one of the other supported formats. The DOI in the metadata will be replaced with the DOI in the DOI field if different." @required={{false}} as |el|>
<el.control @class="form-control metadata" />
</Textarea>
</div>
2 changes: 1 addition & 1 deletion app/templates/components/model-search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
</div>
{{/if}}

<h3 class="member-results" data-test-results>{{format-number model.meta.total}} {{titleize (pluralize model.meta.total modelName without-count=true)}}</h3>
<h3 class="member-results" data-test-results>{{format-number model.meta.total}} {{pluralize model.meta.total modelName without-count=true}}</h3>
{{/if}}
5 changes: 2 additions & 3 deletions app/templates/dois/show/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
</div>
</div>
<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{model}} @onSubmit={{action "submit" model}} as |form|>
<form.element @controlType="text" @label="DOI" @property="doi" @helpText="The globally unique string that identifies
the resource and can't be changed." @disabled={{true}} />
<form.element @controlType="text" @label="DOI" @id="doi" @property="doi" @helpText="The globally unique string that identifies the resource and can't be changed." @disabled={{true}} />

<DoiState @model={{model}} @form={{form}} />

Expand All @@ -33,7 +32,7 @@ the resource and can't be changed." @disabled={{true}} />
<ModelValidationErrors @model={{model}} @form={{form}} />

<div class="col-md-9 col-md-offset-3">
<button type="submit" id="update-doi" class="btn btn-sm btn-fill" disabled={{v-get model 'isInvalid'}}>Update DOI</button>
<button type="submit" id="doi-update" class="btn btn-sm btn-fill" disabled={{and (v-get model 'isInvalid') (not-eq model.state 'draft')}}>Update DOI</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
Expand Down
6 changes: 3 additions & 3 deletions app/templates/dois/show/modify.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>

<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{model}} @onSubmit={{action "submit" model}} as |form|>
<form.element @controlType="text" @label="DOI" @property="doi" @helpText="The globally unique string that identifies the resource and can't be changed." @disabled={{true}} />
<form.element @controlType="text" @label="DOI" @id="doi" @property="doi" @helpText="The globally unique string that identifies the resource and can't be changed." @disabled={{true}} />

<DoiState @model={{model}} @form={{form}} />
<form.element @id="url" @controlType="text" @label="URL" @property="url" @helpText="The location of the landing page with more information about the resource." @required={{false}} />
Expand All @@ -22,9 +22,9 @@
<ModelValidationErrors @model={{model}} @form={{form}} />

<div class="col-md-9 col-md-offset-3">
<button type="submit" class="btn btn-sm btn-fill" disabled={{v-get model 'isInvalid'}}>Update DOI</button>
<button type="submit" id="doi-modify" class="btn btn-sm btn-fill" disabled={{and (v-get model 'isInvalid') (not-eq model.state 'draft')}}>Update DOI</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion app/templates/prefixes/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</div>

<div class="col-md-9 panel-list" id="content">
<ModelSearch @model={{model}} @sortable={{true}} @link="prefixes" />
<ModelSearch @model={{model}} @name="Prefix" @sortable={{true}} @link="prefixes" />

{{#if model}}
{{#each model as |prefix|}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/providers/show/prefixes/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
{{/if}}
</div>
<div class="col-md-9 panel-list" id="content">
<ModelSearch @model={{model.prefixes}} @sortable={{true}} @link="providers.show.prefixes" />
<ModelSearch @model={{model.prefixes}} @name="Prefix" @sortable={{true}} @link="providers.show.prefixes" />

{{#if model.prefixes}}
{{#each model.prefixes as |providerPrefix|}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/repositories/show/dois/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ModelValidationErrors @model={{model.doi}} @form={{form}} />

<div class="col-md-9 col-md-offset-3">
<button type="submit" id="create" class="btn btn-sm btn-fill" disabled={{v-get model 'isInvalid'}}>Create DOI</button>
<button type="submit" id="doi-create" class="btn btn-sm btn-fill" disabled={{and (v-get model 'isInvalid') (not-eq model.state 'draft')}}>Create DOI</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/repositories/show/dois/upload.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<BsForm @formLayout="horizontal" @horizontalLabelGridClass="col-md-3" @model={{model.doi}} @onSubmit={{action "submit" model.doi}} as |form|>
<DoiDoi @model={{model.doi}} @repository={{model.repository}} @form={{form}} />

<form.element @controlType="text" @label="URL" @property="url" @helpText="The location of the landing page with more information about the resource." @required={{false}} />
<form.element @controlType="text" @label="URL" @id="url" @property="url" @helpText="The location of the landing page with more information about the resource." @required={{false}} />

<DoiUpload @model={{model.doi}} @form={{form}} />

<ModelValidationErrors @model={{model.doi}} @form={{form}} />

<div class="col-md-9 col-md-offset-3">
<button type="submit" class="btn btn-sm btn-fill" disabled={{v-get model 'isInvalid'}}>Create DOI</button>
<button type="submit" id="doi-create" class="btn btn-sm btn-fill" disabled={{and (v-get model 'isInvalid') (not-eq model.state 'draft')}}>Create DOI</button>
<button {{action "cancel"}} class="btn btn-sm">Cancel</button>
</div>
</BsForm>
Expand Down
Loading

0 comments on commit 9239a08

Please sign in to comment.