-
Notifications
You must be signed in to change notification settings - Fork 56
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-6459][ENG-6637][ENG-6638] Add Create new preprint version button #2423
Merged
futa-ikeda
merged 5 commits into
CenterForOpenScience:feature/preprints-doi-versioning
from
futa-ikeda:new-version-button
Dec 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
292eba5
Add "Create new version" button to preprint detail page
futa-ikeda 208079b
Use datePublished to determine ability to create a new version
futa-ikeda 5ede8c4
Fix test
futa-ikeda 85eb8ac
Implement withdrawn preprint detail test
futa-ikeda a1316e8
Fix preprint tombstone page
futa-ikeda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { currentRouteName } from '@ember/test-helpers'; | ||
import { ModelInstance } from 'ember-cli-mirage'; | ||
import { setupMirage } from 'ember-cli-mirage/test-support'; | ||
import { TestContext } from 'ember-test-helpers'; | ||
import { module, skip, test } from 'qunit'; | ||
|
||
import { setupOSFApplicationTest, visit } from 'ember-osf-web/tests/helpers'; | ||
import PreprintProviderModel from 'ember-osf-web/models/preprint-provider'; | ||
import PreprintModel from 'ember-osf-web/models/preprint'; | ||
import { PreprintProviderReviewsWorkFlow, ReviewsState } from 'ember-osf-web/models/provider'; | ||
import { Permission } from 'ember-osf-web/models/osf-model'; | ||
|
||
interface PreprintDetailTestContext extends TestContext { | ||
provider: ModelInstance<PreprintProviderModel>; | ||
preprint: ModelInstance<PreprintModel>; | ||
} | ||
|
||
module('Acceptance | preprints | detail', hooks => { | ||
setupOSFApplicationTest(hooks); | ||
setupMirage(hooks); | ||
|
||
hooks.beforeEach(async function(this: PreprintDetailTestContext) { | ||
server.loadFixtures('preprint-providers'); | ||
const provider = server.schema.preprintProviders.find('osf') as ModelInstance<PreprintProviderModel>; | ||
provider.update({ | ||
reviewsWorkflow: PreprintProviderReviewsWorkFlow.PRE_MODERATION, | ||
assertionsEnabled: true, | ||
}); | ||
|
||
const preprint = server.create('preprint', { | ||
id: 'test', | ||
provider, | ||
currentUserPermissions: Object.values(Permission), | ||
title: 'Test Preprint', | ||
description: 'This is a test preprint', | ||
}); | ||
this.provider = provider; | ||
this.preprint = preprint; | ||
}); | ||
|
||
test('Accepted preprint detail page', async function(this: PreprintDetailTestContext, assert) { | ||
this.preprint.update({ | ||
reviewsState: ReviewsState.ACCEPTED, | ||
}); | ||
await visit('/preprints/osf/test'); | ||
assert.equal(currentRouteName(), 'preprints.detail', 'Current route is preprint detail'); | ||
|
||
// Check page title | ||
const pageTitle = document.getElementsByTagName('title')[0].innerText; | ||
assert.equal(pageTitle, 'OSF Preprints | Test Preprint', 'Page title is correct'); | ||
|
||
// Check preprint title | ||
assert.dom('[data-test-preprint-title]').exists('Title is displayed'); | ||
assert.dom('[data-test-preprint-title]').hasText('Test Preprint', 'Title is correct'); | ||
|
||
// Check edit and new version buttons | ||
assert.dom('[data-test-edit-preprint-button]').exists('Edit button is displayed'); | ||
assert.dom('[data-test-edit-preprint-button]').containsText('Edit', 'Edit button text is correct'); | ||
assert.dom('[data-test-create-new-version-button]').exists('New version button is displayed'); | ||
|
||
// Check preprint authors | ||
assert.dom('[data-test-contributor-name]').exists('Authors are displayed'); | ||
|
||
// TODO: Check author assertions | ||
|
||
// Check preprint status banner | ||
assert.dom('[data-test-status]').exists('Status banner is displayed'); | ||
assert.dom('[data-test-status]').containsText('accepted', 'Status is correct'); | ||
}); | ||
|
||
test('Pre-mod: Rejected preprint detail page', async function(this: PreprintDetailTestContext, assert) { | ||
this.provider.update({ | ||
reviewsWorkflow: PreprintProviderReviewsWorkFlow.PRE_MODERATION, | ||
}); | ||
this.preprint.update({ | ||
reviewsState: ReviewsState.REJECTED, | ||
}); | ||
await visit('/preprints/osf/test'); | ||
assert.equal(currentRouteName(), 'preprints.detail', 'Current route is preprint detail'); | ||
|
||
// Check page title. Should be same as accepted preprint | ||
const pageTitle = document.getElementsByTagName('title')[0].innerText; | ||
assert.equal(pageTitle, 'OSF Preprints | Test Preprint', 'Page title is correct'); | ||
|
||
// Check preprint title. Should be same as accepted preprint | ||
assert.dom('[data-test-preprint-title]').exists('Title is displayed'); | ||
assert.dom('[data-test-preprint-title]').hasText('Test Preprint', 'Title is correct'); | ||
|
||
// Check edit and new version buttons | ||
assert.dom('[data-test-edit-preprint-button]').exists('Edit button is displayed'); | ||
assert.dom('[data-test-edit-preprint-button]') | ||
.hasText('Edit and resubmit', 'Edit button text indicates resubmission'); | ||
assert.dom('[data-test-create-new-version-button]').doesNotExist('New version button is not displayed'); | ||
|
||
// Check preprint authors | ||
assert.dom('[data-test-contributor-name]').exists('Authors are displayed'); | ||
|
||
// Check preprint status banner | ||
assert.dom('[data-test-status]').exists('Status banner is displayed'); | ||
assert.dom('[data-test-status]').containsText('rejected', 'Status is correct'); | ||
}); | ||
|
||
|
||
skip('Withdrawn preprint detail page', async function(this: PreprintDetailTestContext, _) { | ||
// TODO: Implement test | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't know withdrawal can have pending and rejected states. I need to check BE to see if we are handling this properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@futa-ikeda for pre-moderation, "accepted" is correct but for post moderation, it should be "pending" or " accepted". I am not 100% sure how frontend maps backend wording.
See: https://openscience.atlassian.net/browse/ENG-6467. I think FE can probably just use the
is_lateset_version
without caring about the review state?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, interesting... I see what you are saying about some of the reviews_states for pre-mod vs. post-mod lining up to be the same state (ie: for pre-mod,
"reviews_state": "pending"
=>"is_published": false
, but for post-moderation, either"reviews_state": "pending"
or"accepted"
=>"is_published": true
). I'm not sure if we can fully ignore thereviews_state
flag here though, as we shouldn't be allowing a new version for "pre-moderation and rejected" and "pre-moderation and pending moderator approval", right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, as discussed, let's rely on
date_published
instead ofis_published
. There will be a BE fix to make sureis_latest_version
checksdate_published
instead ofis_published
.