Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6803] Preprint-doi select dropdown should have current version selected by default #2448

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions app/preprints/-components/preprint-doi/component-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ module('Integration | Component | preprint-doi', function(hooks) {

const provider = await this.store.findRecord('preprint-provider', mirageProvider.id);
this.set('versions', versions);
this.set('currentVersion', versions[1]);
this.set('provider', provider);

await render(hbs`
<Preprints::-Components::PreprintDoi
@currentVersion={{this.currentVersion}}
@versions={{this.versions}}
@provider={{this.provider}}
/>
Expand All @@ -57,22 +59,24 @@ module('Integration | Component | preprint-doi', function(hooks) {
// check dropdown exists
assert.dom('[data-test-version-select-dropdown]').exists('Version select dropdown exists');
assert.dom('[data-test-version-select-dropdown]')
.hasText('Version 3 (Rejected)', 'Dropdown has latest version selected by default');
.hasText('Version 2 (Rejected)', 'Dropdown has passed in currentVersiom selected by default');
assert.dom('[data-test-preprint-version="2"]').exists('Version 2 is shown');

// check version3 has no DOI
assert.dom('[data-test-no-doi-text]').exists('No DOI text exists');
assert.dom('[data-test-no-doi-text]').hasText('DOI created after moderator approval', 'No DOI text is correct');

// check version2 has DOI, but no preprintDoiCreated date
await click('[data-test-version-select-dropdown]');
await click('[data-test-preprint-version="2"]');
// check version2 has DOI text
assert.dom('[data-test-no-doi-text]').doesNotExist('No DOI text does not exist');
assert.dom('[data-test-unlinked-doi-url]').exists('Preprint DOI URL exists');
assert.dom('[data-test-unlinked-doi-description]').exists('Preprint DOI description exists');
assert.dom('[data-test-unlinked-doi-description]')
// eslint-disable-next-line max-len
.hasText('DOIs are minted by a third party, and may take up to 24 hours to be registered.', 'Description is correct');

// check version3 has DOI, but no preprintDoiCreated date
await click('[data-test-version-select-dropdown]');
await click('[data-test-preprint-version="3"]');
assert.dom('[data-test-unlinked-doi-url]').doesNotExist('Unlinked preprint DOI URL does not exist');
assert.dom('[data-test-no-doi-text]').exists('No DOI text exists');
assert.dom('[data-test-no-doi-text]').hasText('DOI created after moderator approval', 'No DOI text is correct');

// check version1 has DOI and preprintDoiCreated date
await click('[data-test-version-select-dropdown]');
await click('[data-test-preprint-version="1"]');
Expand Down Expand Up @@ -100,11 +104,13 @@ module('Integration | Component | preprint-doi', function(hooks) {
const versions = await preprint.queryHasMany('versions');

const provider = await this.store.findRecord('preprint-provider', mirageProvider.id);
this.set('currentVersion', versions[0]);
this.set('versions', versions);
this.set('provider', provider);

await render(hbs`
<Preprints::-Components::PreprintDoi
@currentVersion={{this.currentVersion}}
@versions={{this.versions}}
@provider={{this.provider}}
/>
Expand Down
3 changes: 2 additions & 1 deletion app/preprints/-components/preprint-doi/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PreprintProviderModel from 'ember-osf-web/models/preprint-provider';
interface InputArgs {
versions: PreprintModel[];
provider: PreprintProviderModel;
currentVersion: PreprintModel;
}

export default class PreprintAbstract extends Component<InputArgs> {
Expand All @@ -18,7 +19,7 @@ export default class PreprintAbstract extends Component<InputArgs> {
provider = this.args.provider;
documentType = this.provider.documentType.singularCapitalized;

@tracked selectedVersion = this.args.versions[0];
@tracked selectedVersion = this.args.currentVersion;

reviewStateLabelKeyMap = VersionStatusSimpleLabelKey;

Expand Down
4 changes: 4 additions & 0 deletions app/preprints/-components/preprint-doi/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
margin-bottom: 12px;
width: 200px;
}

.current-version {
font-weight: bold;
}
1 change: 1 addition & 0 deletions app/preprints/-components/preprint-doi/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
as |version|
>
<span
local-class={{if (eq version.version @currentVersion.version) 'current-version'}}
data-test-preprint-version={{version.version}}
>
{{#let (get this.reviewStateLabelKeyMap version.reviewsState) as |reviewStateLabelKey|}}
Expand Down
6 changes: 5 additions & 1 deletion app/preprints/-components/preprint-tombstone/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
</div>
{{/if}}
<Preprints::-Components::PreprintAbstract @preprint={{@preprint}} />
<Preprints::-Components::PreprintDoi @versions={{@versions}} @provider={{@provider}} />
<Preprints::-Components::PreprintDoi
@currentVersion={{@preprint}}
@versions={{@versions}}
@provider={{@provider}}
/>
<Preprints::-Components::PreprintLicense @preprint={{@preprint}} />
<Preprints::-Components::PreprintDiscipline @subjects={{@subjects}} />
<Preprints::-Components::PreprintTag @preprint={{@preprint}} />
Expand Down
1 change: 1 addition & 0 deletions app/preprints/detail/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
</div>
{{/if}}
<Preprints::-Components::PreprintDoi
@currentVersion={{this.model.preprint}}
@versions={{this.model.versions}}
@provider={{this.model.provider}}
/>
Expand Down
Loading