Skip to content

Commit b3b7ca0

Browse files
committed
Merge branch 'hotfix/21.6.2'
2 parents c544052 + 1021818 commit b3b7ca0

File tree

10 files changed

+61
-42
lines changed

10 files changed

+61
-42
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [21.6.2] - 2021-07-02
8+
### Fixed
9+
- [hotfix] draft-registration's node-license validations
10+
11+
### Removed
12+
- node-license year validator (issues with multiple validator assigned to same value path)
13+
714
## [21.6.1] - 2021-06-29
815
### Fixed
916
- Fix missing save/cancel buttons on the registration's license/node-license editable field
@@ -1759,7 +1766,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
17591766
### Added
17601767
- Quick Files
17611768

1762-
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/21.6.1...develop
1769+
[Unreleased]: https://github.com/CenterForOpenScience/ember-osf-web/compare/21.6.2...develop
1770+
[21.6.2]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.6.2
17631771
[21.6.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.6.1
17641772
[21.6.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.6.0
17651773
[21.5.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/21.5.1

app/packages/registration-schema/validations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export function buildMetadataValidations() {
162162
set(validationObj, DraftMetadataProperties.Description, notBlank);
163163
set(validationObj, DraftMetadataProperties.License, notBlank);
164164
set(validationObj, DraftMetadataProperties.Subjects, validateSubjects());
165-
set(validationObj, DraftMetadataProperties.NodeLicenseProperty, [validateNodeLicense(), validateNodeLicenseYear()]);
165+
// TODO: unsure why array of validation functions breaks validations
166+
set(validationObj, DraftMetadataProperties.NodeLicenseProperty, validateNodeLicense());
166167
return validationObj;
167168
}

lib/osf-components/addon/components/validated-input/base-component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Model from '@ember-data/model';
44
import Component from '@ember/component';
55
import { computed, defineProperty } from '@ember/object';
6+
import { dependentKeyCompat } from '@ember/object/compat';
67
import { alias, oneWay } from '@ember/object/computed';
78
import { inject as service } from '@ember/service';
89
import { isEmpty } from '@ember/utils';
@@ -68,7 +69,12 @@ export default abstract class BaseValidatedInput<M extends Model> extends Compon
6869
return this.placeholder || this.intl.t(this.isRequired ? 'general.required' : 'general.optional');
6970
}
7071

71-
@computed('shouldShowMessages', 'value', 'isInvalid', 'isValidating')
72+
@dependentKeyCompat
73+
get _isInvalid() {
74+
return this.changeset ? Boolean(this.changeset.error[this.valuePath as string]) : this.isInvalid;
75+
}
76+
77+
@computed('shouldShowMessages', 'value', '_isInvalid', 'isInvalid', 'isValidating')
7278
get validationStatus(): ValidationStatus {
7379
const {
7480
shouldShowMessages,
@@ -95,10 +101,6 @@ export default abstract class BaseValidatedInput<M extends Model> extends Compon
95101
return this.changeset ? this.changeset.isValidating(this.valuePath as string) : this.isValidating;
96102
}
97103

98-
get _isInvalid() {
99-
return this.changeset ? Boolean(this.changeset.error[this.valuePath as string]) : this.isInvalid;
100-
}
101-
102104
init() {
103105
super.init();
104106
if (this.changeset) {

lib/registries/addon/drafts/draft/-components/managers/license-picker-manager/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class LicensePickerManager extends Component implements LicenseMa
7373
} else {
7474
this.draftManager.metadataChangeset.set('nodeLicense', null);
7575
}
76-
this.onMetadataInput();
76+
taskFor(this.draftManager.updateDraftRegistrationAndSave).perform();
7777
}
7878

7979
@action

lib/registries/addon/drafts/draft/draft-registration-manager.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,14 @@ export default class DraftRegistrationManager {
177177
@restartableTask
178178
@waitFor
179179
async onMetadataInput() {
180-
await timeout(5000); // debounce
181-
this.updateMetadataChangeset();
180+
await timeout(3000); // debounce
181+
await taskFor(this.updateDraftRegistrationAndSave).perform();
182+
}
183+
184+
@restartableTask
185+
@waitFor
186+
async updateDraftRegistrationAndSave() {
187+
this.copyMetadataChangesToDraft();
182188
try {
183189
await this.draftRegistration.save();
184190
} catch (e) {
@@ -222,7 +228,7 @@ export default class DraftRegistrationManager {
222228
});
223229
}
224230

225-
updateMetadataChangeset() {
231+
copyMetadataChangesToDraft() {
226232
const { metadataChangeset, draftRegistration } = this;
227233
Object.values(DraftMetadataProperties).forEach(metadataKey => {
228234
set(

mirage/factories/registration-provider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export default Factory.extend<MirageRegistrationProvider & RegistrationProviderT
4141
afterCreate(provider, server) {
4242
provider.update({
4343
licensesAcceptable: [
44-
server.create('license', { name: 'MIT License' }),
44+
server.create('license', {
45+
name: 'Mozilla Public License 2.0',
46+
requiredFields: [],
47+
}),
4548
server.create('license', {
4649
name: 'No license',
4750
requiredFields: [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-osf-web",
3-
"version": "21.6.1",
3+
"version": "21.6.2",
44
"description": "Ember front-end for the Open Science Framework",
55
"license": "Apache-2.0",
66
"author": "Center for Open Science <support@cos.io>",

tests/acceptance/settings/profile/names-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { currentURL, fillIn, visit } from '@ember/test-helpers';
22
import { setupMirage } from 'ember-cli-mirage/test-support';
33
import { percySnapshot } from 'ember-percy';
4-
import { module, test, skip } from 'qunit';
4+
import { module, test } from 'qunit';
55

66
import { click, setupOSFApplicationTest } from 'ember-osf-web/tests/helpers';
77
import { CurrentUserStub } from 'ember-osf-web/tests/helpers/require-auth';
@@ -89,7 +89,7 @@ module('Acceptance | settings | profile | name', hooks => {
8989
});
9090

9191
// skip: unskip after reworking validated-input after
92-
skip('validation works', async assert => {
92+
test('validation works', async assert => {
9393
const givenName = 'Peggy';
9494
const middleNames = 'Herbert Gavin';
9595
const familyName = 'Doyle';

tests/engines/registries/acceptance/draft/draft-test.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
find,
88
settled,
99
triggerKeyEvent,
10+
blur,
1011
waitUntil,
1112
findAll,
1213
} from '@ember/test-helpers';
@@ -877,33 +878,31 @@ module('Registries | Acceptance | draft form', hooks => {
877878
.hasValue(new Date().getUTCFullYear().toString(), 'License: Year autofills to current year');
878879
assert.dom('[data-test-required-field="copyrightHolders"]')
879880
.hasText('', 'License: CopyrightHolders does not autofill');
880-
const missingFields = 'Copyright Holders';
881-
const validationErrorMsg = t('validationErrors.node_license_missing_fields',
881+
let missingFields = 'Copyright Holders';
882+
let validationErrorMsg = t('validationErrors.node_license_missing_fields',
882883
{ missingFields, numOfFields: 1 }).toString();
883884
assert.dom('[data-test-validation-errors="nodeLicense"]')
884885
.containsText(validationErrorMsg, 'NodeLicense validation error when copyright holder is empty');
885886

886-
// TODO: Fix node-license validation in test
887887
// Input invalid Nodelicense fields
888-
// await fillIn('[data-test-required-field="year"]', '');
889-
// await blur('[data-test-required-field="year"]');
890-
// await this.pauseTest();
891-
// missingFields = 'Year, Copyright Holders';
892-
// validationErrorMsg = t('validationErrors.node_license_missing_fields',
893-
// { missingFields, numOfFields: 2 }).toString();
894-
// assert.dom('[data-test-validation-errors="nodeLicense"]')
895-
// .containsText(
896-
// validationErrorMsg,
897-
// 'NodeLicense validation error when year and copyrightholder are empty',
898-
// );
899-
// await percySnapshot(
900-
// 'Registries | Acceptance | draft form | metadata editing | metadata: invalid nodelicense');
888+
await fillIn('[data-test-required-field="year"]', '');
889+
await blur('[data-test-required-field="year"]');
890+
missingFields = 'Year, Copyright Holders';
891+
validationErrorMsg = t('validationErrors.node_license_missing_fields',
892+
{ missingFields, numOfFields: 2 }).toString();
893+
assert.dom('[data-test-validation-errors="nodeLicense"]')
894+
.containsText(
895+
validationErrorMsg,
896+
'NodeLicense validation error when year and copyrightholder are empty',
897+
);
898+
await percySnapshot(
899+
'Registries | Acceptance | draft form | metadata editing | metadata: invalid nodelicense',
900+
);
901901

902902
// validation errors for nodelicense should show on review page
903-
// await click('[data-test-link="review"]');
904-
//
905-
// assert.dom('[data-test-validation-errors="nodeLicense"]').exists('NodeLicense errors exist on Review page');
906-
// await percySnapshot('Registries | Acceptance | draft form | metadata editing | review: invalid nodelicense');
903+
await click('[data-test-link="review"]');
904+
assert.dom('[data-test-validation-errors="nodeLicense"]').exists('NodeLicense errors exist on Review page');
905+
await percySnapshot('Registries | Acceptance | draft form | metadata editing | review: invalid nodelicense');
907906

908907
// Return to metadata page to address empty fields
909908
await click('[data-test-link="metadata"]');

tests/engines/registries/acceptance/overview/overview-test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { click as untrackedClick, fillIn } from '@ember/test-helpers';
33
import { ModelInstance } from 'ember-cli-mirage';
44
import { setupMirage } from 'ember-cli-mirage/test-support';
55
import config from 'ember-get-config';
6+
import { t } from 'ember-intl/test-support';
67
import { percySnapshot } from 'ember-percy';
78
import { selectChoose, selectSearch } from 'ember-power-select/test-support';
89
import { TestContext } from 'ember-test-helpers';
@@ -562,17 +563,16 @@ module('Registries | Acceptance | overview.overview', hooks => {
562563
await click('[data-test-edit-button="license"]');
563564

564565
assert.dom('[data-test-license-edit-form]').isVisible();
565-
await selectSearch('[data-test-power-select-dropdown]', 'MIT');
566-
assert.dom('.ember-power-select-options').hasText('MIT License');
566+
await selectSearch('[data-test-power-select-dropdown]', 'Mozilla');
567+
assert.dom('.ember-power-select-options').hasText('Mozilla Public License 2.0');
567568
await selectSearch('[data-test-power-select-dropdown]', 'No');
568569
assert.dom('.ember-power-select-options').hasText('No license');
569570
await selectChoose('[data-test-power-select-dropdown]', 'No license');
570571

571-
// TODO: Fix nodeLicense validation in test
572-
// const missingFields = 'Copyright Holders';
573-
// const validationErrorMsg = t('validationErrors.node_license_missing_fields',
574-
// { missingFields, numOfFields: 1 }).toString();
575-
// assert.dom('.help-block').hasText(validationErrorMsg, 'validation works');
572+
const missingFields = 'Copyright Holders';
573+
const validationErrorMsg = t('validationErrors.node_license_missing_fields',
574+
{ missingFields, numOfFields: 1 }).toString();
575+
assert.dom('.help-block').hasText(validationErrorMsg, 'validation works');
576576

577577
await fillIn('[data-test-required-field="copyrightHolders"]', 'Jane Doe, John Doe');
578578
await click('[data-test-save-license]');

0 commit comments

Comments
 (0)