From 5877c2f128b18714662fe808e62ca1c192e8db10 Mon Sep 17 00:00:00 2001 From: futa-ikeda <51409893+futa-ikeda@users.noreply.github.com> Date: Thu, 2 Jan 2025 15:55:00 -0500 Subject: [PATCH] Add link to version in DOI select (#2449) - Ticket: [ENG-6804] - Feature flag: n/a ## Purpose - Add a link to the version when selecting a different version in the DOI selection dropdown ## Summary of Changes - Add link to preprint DOI dropdown - Update tests --- app/preprints/-components/preprint-doi/component-test.ts | 8 ++++++++ app/preprints/-components/preprint-doi/template.hbs | 8 ++++++++ translations/en-us.yml | 1 + 3 files changed, 17 insertions(+) diff --git a/app/preprints/-components/preprint-doi/component-test.ts b/app/preprints/-components/preprint-doi/component-test.ts index 4c81f23ec8..f22f44463c 100644 --- a/app/preprints/-components/preprint-doi/component-test.ts +++ b/app/preprints/-components/preprint-doi/component-test.ts @@ -9,12 +9,15 @@ import { ModelInstance } from 'ember-cli-mirage'; import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; import PreprintModel from 'ember-osf-web/models/preprint'; import { ReviewsState } from 'ember-osf-web/models/provider'; +import { OsfLinkRouterStub } from 'ember-osf-web/tests/integration/helpers/osf-link-router-stub'; module('Integration | Component | preprint-doi', function(hooks) { setupRenderingTest(hooks); setupMirage(hooks); test('it renders', async function(assert) { + this.owner.unregister('service:router'); + this.owner.register('service:router', OsfLinkRouterStub); this.store = this.owner.lookup('service:store'); server.loadFixtures('preprint-providers'); const mirageProvider = server.schema.preprintProviders.find('osf') as ModelInstance; @@ -62,6 +65,9 @@ module('Integration | Component | preprint-doi', function(hooks) { .hasText('Version 2 (Rejected)', 'Dropdown has passed in currentVersiom selected by default'); assert.dom('[data-test-preprint-version="2"]').exists('Version 2 is shown'); + assert.dom('[data-test-view-version-link]').exists('View in OSF button exists'); + assert.dom('[data-test-view-version-link]').hasText('View version 2', 'View version link has correct text'); + // 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'); @@ -86,6 +92,8 @@ module('Integration | Component | preprint-doi', function(hooks) { }); test('it renders statuses', async function(assert) { + this.owner.unregister('service:router'); + this.owner.register('service:router', OsfLinkRouterStub); this.store = this.owner.lookup('service:store'); server.loadFixtures('preprint-providers'); const mirageProvider = server.schema.preprintProviders.find('osf') as ModelInstance; diff --git a/app/preprints/-components/preprint-doi/template.hbs b/app/preprints/-components/preprint-doi/template.hbs index 278c1336d9..05df9f3f7e 100644 --- a/app/preprints/-components/preprint-doi/template.hbs +++ b/app/preprints/-components/preprint-doi/template.hbs @@ -27,6 +27,14 @@

{{t 'preprints.detail.no_versions'}}

{{/if}} {{#if this.selectedVersion}} + + {{t 'preprints.detail.view_version' number=this.selectedVersion.version}} + {{#if this.selectedVersion.preprintDoiUrl}} {{#if this.selectedVersion.preprintDoiCreated}}