-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-6459][ENG-6637][ENG-6638] Add Create new preprint version button (…
…#2423) - Ticket: [ENG-6459] [ENG-6637] [ENG-6638] - Feature flag: n/a ## Purpose - Add a new "Create new version" button to the preprint detail page ## Summary of Changes - Add a new `canCreateNewVersion` attr to preprint model - Only admins can create a new version - Only preprints that is the latest version can create a new version - Only preprints that are were published at some point (whether they are withdrawn or not, doesn't matter) - Update tombstone page for preprint versions
- Loading branch information
1 parent
47ea434
commit 5515ddc
Showing
7 changed files
with
186 additions
and
18 deletions.
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
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,152 @@ | ||
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, 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'); | ||
server.loadFixtures('citation-styles'); | ||
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('Accepted preprint, prior version detail page', async function(this: PreprintDetailTestContext, assert) { | ||
this.preprint.update({ | ||
reviewsState: ReviewsState.ACCEPTED, | ||
isLatestVersion: false, | ||
}); | ||
await visit('/preprints/osf/test'); | ||
|
||
// 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]') | ||
.doesNotExist('New version button is not displayed for prior versions'); | ||
|
||
// 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, | ||
datePublished: null, | ||
}); | ||
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'); | ||
}); | ||
|
||
|
||
test('Withdrawn preprint, latest version detail page', async function(this: PreprintDetailTestContext, assert) { | ||
this.preprint.update({ | ||
dateWithdrawn: new Date(), | ||
}); | ||
await visit('/preprints/osf/test'); | ||
|
||
// Check page title | ||
const pageTitle = document.getElementsByTagName('title')[0].innerText; | ||
assert.equal(pageTitle, 'OSF Preprints | Withdrawn: Test Preprint', 'Page title is correct'); | ||
|
||
// Check new version button and no edit button | ||
assert.dom('[data-test-edit-preprint-button]').doesNotExist('Edit button is not displayed'); | ||
assert.dom('[data-test-create-new-version-button]') | ||
.exists('New version button is displayed for latest withdrawn preprint version'); | ||
}); | ||
|
||
test('Withdrawn preprint, prior version detail page', async function(this: PreprintDetailTestContext, assert) { | ||
this.preprint.update({ | ||
dateWithdrawn: new Date(), | ||
isLatestVersion: false, | ||
}); | ||
await visit('/preprints/osf/test'); | ||
|
||
// Check no new version button and no edit button | ||
assert.dom('[data-test-edit-preprint-button]').doesNotExist('Edit button is not displayed'); | ||
assert.dom('[data-test-create-new-version-button]') | ||
.doesNotExist('New version button is not displayed for prior withdrawn preprint version'); | ||
}); | ||
}); |
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